:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-alt: #f0efec;
  --border: rgba(0, 0, 0, 0.1);
  --text: #1a1a18;
  --text-secondary: #6b6b68;
  --text-success: #3B6D11;
  --text-warning: #854F0B;
  --text-danger: #A32D2D;
  --text-info: #185FA5;
  --accent: #1a1a18;
  --radius: 8px;
  --radius-lg: 12px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* Layout */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 210px;
  background: var(--surface-alt);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 16px 16px 14px;
  border-bottom: 0.5px solid var(--border);
}

.brand-name {
  font-size: 15px;
  font-weight: 500;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar nav {
  padding: 8px 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}

.nav-link:hover {
  background: rgba(0, 0, 0, .05);
  color: var(--text);
}

.nav-link.active {
  background: rgba(0, 0, 0, .07);
  color: var(--text);
  font-weight: 500;
}

.nav-icon {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 0.5px solid var(--border);
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 500;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 0.5px solid var(--border);
  background: var(--surface);
}

.topbar-title {
  font-size: 15px;
  font-weight: 500;
}

.topbar-user {
  font-size: 12px;
  color: var(--text-secondary);
}

.content {
  padding: 20px;
  overflow: auto;
  flex: 1;
}

/* Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.login-brand {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 2px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.card-table {
  padding: 0;
  overflow-x: auto;
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
}

/* Metrics */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.metric-num {
  font-size: 24px;
  font-weight: 500;
}

/* Two column */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: var(--surface-alt);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.badge-success {
  background: #EAF3DE;
  color: #3B6D11;
}

.badge-warning {
  background: #FAEEDA;
  color: #854F0B;
}

.badge-danger {
  background: #FCEBEB;
  color: #A32D2D;
}

.badge-info {
  background: #E6F1FB;
  color: #185FA5;
}

/* Colors */
.text-success {
  color: var(--text-success);
}

.text-warning {
  color: var(--text-warning);
}

.text-danger {
  color: var(--text-danger);
}

.text-info {
  color: var(--text-info);
}

.text-muted {
  color: #6b7280;
}

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
}

.alert-danger {
  background: #FCEBEB;
  color: #A32D2D;
  border: 0.5px solid #F7C1C1;
}

/* Buttons */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  font-size: 13px;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  font-family: inherit;
}

button:hover,
.btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-control,
input[type=text],
input[type=email],
input[type=password],
input[type=number],
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.3);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-title {
  font-size: 16px;
  font-weight: 500;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
  width: auto;
}

/* Reminders */
.reminder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 0.5px solid var(--border);
}

.reminder-row:last-child {
  border-bottom: none;
}

.reminder-name {
  font-weight: 500;
  font-size: 12px;
}

.reminder-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.reminder-due {
  font-size: 12px;
  color: var(--text-danger);
  font-weight: 500;
  text-align: right;
}

/* Activity */
.activity-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 12px;
}

.activity-row:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.dot-success {
  background: #3B6D11;
}

.dot-warning {
  background: #854F0B;
}

.dot-danger {
  background: #A32D2D;
}

.dot-muted {
  background: #6b7280;
}

.activity-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* History */
.history-item {
  padding: 9px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 12px;
}

.history-change {
  font-weight: 500;
}

.history-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 13px;
  margin-top: 3px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 22px;
  width: 100%;
  max-width: 440px;
}

.modal-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Empty */
.empty-text {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  padding: 16px;
}

@media (max-width: 768px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
}