:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-muted: #f1f0ec;
  --border: #e2e0d8;
  --text: #1f1e1a;
  --text-secondary: #6b6a63;
  --text-muted: #9a988f;
  --accent: #0f6e56;
  --accent-bg: #e1f5ee;
  --success: #0f6e56;
  --success-bg: #e1f5ee;
  --warning: #854f0b;
  --warning-bg: #faeeda;
  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  flex-shrink: 0;
}

.sidebar .brand {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 1.5rem;
}

.sidebar nav a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 2px;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
}

.main { flex: 1; padding: 2rem; max-width: 1100px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 0.75rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface-muted);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); margin: 0 0 4px; }
.stat-card .value { font-size: 22px; font-weight: 600; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 10px; font-size: 12px; }
td { padding: 8px 10px; border-top: 1px solid var(--border); }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius);
}
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.muted { background: var(--surface-muted); color: var(--text-secondary); }

label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
}

.field { margin-bottom: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button, .btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
button:hover, .btn:hover { background: var(--surface-muted); text-decoration: none; }
button.primary { border-color: var(--accent); color: var(--accent); }
button.danger { color: var(--danger); }

.radio-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.radio-option.selected { border-color: var(--accent); background: var(--accent-bg); }
.radio-option p { margin: 0; font-size: 13px; }
.radio-option .hint { color: var(--text-secondary); font-size: 11px; margin-top: 2px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.success { background: var(--success); }
.dot.warning { background: var(--warning); }
.dot.muted { background: var(--text-muted); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 1rem; font-size: 13px; }
.flash.success { background: var(--success-bg); color: var(--success); }
.flash.danger { background: var(--danger-bg); color: var(--danger); }
.flash.warning { background: var(--warning-bg); color: var(--warning); }
.flash.info { background: var(--surface-muted); color: var(--text-secondary); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-secondary); font-size: 12px; margin-bottom: 1.25rem; }

/* Dashboard account rows: avatar + counts + capacity bar + 7-day mini chart */
.account-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.account-row:first-of-type { border-top: none; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.account-row-main { flex: 1; min-width: 0; }

.account-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.account-row-name { font-size: 14px; font-weight: 500; margin: 0; }

.account-row-counts {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 6px;
}
.account-row-counts strong { color: var(--text); font-weight: 600; }

.capacity-bar {
  height: 6px;
  background: var(--surface-muted);
  border-radius: 3px;
  overflow: hidden;
  max-width: 280px;
}
.capacity-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.capacity-label { font-size: 10px; color: var(--text-muted); margin: 3px 0 0; }

.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
  width: 70px;
  flex-shrink: 0;
}
.mini-chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 1px;
  min-height: 2px;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  margin-left: 6px;
  opacity: 0.6;
}
.live-dot.pulse {
  animation: livePulse 0.6s ease-out;
}
@keyframes livePulse {
  0% { opacity: 1; transform: scale(1.6); }
  100% { opacity: 0.6; transform: scale(1); }
}

/* Compact one-line-per-account row (dashboard) */
.account-row-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.account-row-compact:first-of-type { border-top: none; }

.avatar-sm {
  width: 26px;
  height: 26px;
  font-size: 10px;
}

.account-row-compact-name {
  font-size: 13px;
  font-weight: 500;
  width: 150px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-row-compact-counts {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  white-space: nowrap;
}

.capacity-bar-compact {
  flex: 1;
  min-width: 40px;
  max-width: none;
}

.mini-chart-compact {
  width: 52px;
  height: 20px;
  flex-shrink: 0;
}

/* Compact recent-activity rows */
.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.activity-row:first-of-type { border-top: none; }

.activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.activity-dot.success { background: var(--success); }
.activity-dot.danger { background: var(--danger); }
.activity-dot.muted { background: var(--text-muted); }

.activity-time {
  width: 44px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.activity-desc { flex: 1; }
.activity-account { color: var(--text-muted); }

.activity-status.success { color: var(--success); }
.activity-status.danger { color: var(--danger); }
.activity-status.muted { color: var(--text-muted); }
