/* ============================================================
   西骏供应链台账 — Apple / iOS / macOS 设计语言
   SF Pro · 浅色玻璃感 · 系统蓝 · 大圆角 · 克制留白
   ============================================================ */

:root {
  --sys-blue:       #007AFF;
  --sys-blue-2:     #0056D6;
  --sys-green:      #34C759;
  --sys-orange:     #FF9500;
  --sys-red:        #FF3B30;
  --sys-purple:     #AF52DE;
  --sys-pink:       #FF2D92;
  --sys-teal:       #5AC8FA;
  --sys-indigo:     #5856D6;
  --sys-yellow:     #FFCC00;

  --label:          #1D1D1F;
  --label-2:        #3C3C43;
  --label-3:        rgba(60, 60, 67, 0.6);
  --label-4:        rgba(60, 60, 67, 0.3);

  --bg:             #F5F5F7;      /* Apple.com light background */
  --bg-elevated:    #FFFFFF;
  --bg-grouped:     #F2F2F7;      /* iOS grouped background */
  --bg-secondary:   #FAFAFC;

  --separator:      rgba(60, 60, 67, 0.10);
  --separator-2:    rgba(60, 60, 67, 0.18);

  --radius-xl:      22px;
  --radius-lg:      16px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-xs:      6px;

  --shadow-1:       0 1px 2px rgba(0,0,0,.04);
  --shadow-2:       0 4px 16px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-3:       0 10px 40px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow-hover:   0 8px 24px rgba(0,122,255,.15), 0 2px 6px rgba(0,0,0,.05);

  --blur:           saturate(180%) blur(20px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
               'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 1.47;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
  letter-spacing: -0.01em;
}

a { color: var(--sys-blue); text-decoration: none; transition: opacity .2s; }
a:hover { opacity: .75; }

::selection { background: rgba(0,122,255,.25); }

/* ========= Layout ========= */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: rgba(246, 246, 248, 0.8);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--separator);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar .brand {
  padding: 22px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar .brand-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 15px;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 14px rgba(0,122,255,.3), inset 0 1px 0 rgba(255,255,255,.15);
}
.sidebar .brand-text { font-size: 15px; font-weight: 600; line-height: 1.2; color: var(--label); letter-spacing: -0.02em; }
.sidebar .brand-text small {
  display: block;
  font-weight: 400;
  color: var(--label-3);
  font-size: 11px;
  margin-top: 3px;
  letter-spacing: 0;
}

.sidebar nav {
  flex: 1;
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  color: var(--label-2);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: all .15s ease;
}
.sidebar nav a:hover {
  background: rgba(120, 120, 128, 0.12);
  color: var(--label);
  opacity: 1;
}
.sidebar nav a.active {
  background: var(--sys-blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,122,255,.25);
}
.sidebar nav a.active:hover { background: var(--sys-blue); opacity: .95; }
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2; }
.sidebar nav a .count-dot {
  margin-left: auto;
  background: var(--sys-red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  line-height: 16px;
}
.sidebar nav a.active .count-dot { background: rgba(255,255,255,.25); }

.sidebar .user-box {
  padding: 12px 14px;
  border-top: 1px solid var(--separator);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .user-box .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007AFF, #5856D6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,122,255,.25);
}
.sidebar .user-box .user-info { flex: 1; min-width: 0; }
.sidebar .user-box .name { font-size: 13px; font-weight: 600; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.sidebar .user-box .role { font-size: 11px; color: var(--label-3); margin-top: 1px; }
.sidebar .user-box form { margin: 0; }
.sidebar .user-box button {
  background: transparent;
  border: none;
  color: var(--label-3);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: all .15s;
}
.sidebar .user-box button:hover { background: rgba(255,59,48,.12); color: var(--sys-red); }
.sidebar .user-box button svg { width: 16px; height: 16px; }

.main { flex: 1; overflow-x: auto; min-width: 0; background: var(--bg); }
.main-inner { padding: 32px 40px; width: 100%; }

/* ========= Top bar ========= */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 20px;
}
.topbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--label);
  display: flex; align-items: center; gap: 10px;
}
.topbar h1 svg { width: 24px; height: 24px; color: var(--sys-blue); }
.topbar .subtitle { font-size: 14px; color: var(--label-3); margin-top: 2px; letter-spacing: -0.01em; }
.topbar .actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ========= Card ========= */
.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-2); }
.card h2 {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 600;
  color: var(--label);
  letter-spacing: -0.02em;
}
.card .card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.card .card-title h2 { margin: 0; }
.card-header {
  margin: -24px -24px 0;
  padding: 18px 24px;
  border-bottom: 1px solid var(--separator);
}
.card.no-pad { padding: 0; }
.card.no-pad .card-header { margin: 0; }
.card.no-pad table.ledger { margin: 0; border: 0; }

/* ========= KPI — Apple Health / Stocks style ========= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--bg-elevated);
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
  transition: all .2s;
  cursor: default;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}
.kpi .kpi-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 10px;
}
.kpi .label {
  font-size: 13px;
  color: var(--label-3);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.kpi .icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 2px 6px rgba(0,0,0,.08);
}
.kpi .icon svg { width: 18px; height: 18px; stroke-width: 2.2; }
.kpi .value {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--label);
  font-feature-settings: 'tnum';
}
.kpi .sub {
  font-size: 12px;
  color: var(--label-3);
  margin-top: 6px;
  letter-spacing: -0.01em;
}
.kpi .sub .up { color: var(--sys-green); font-weight: 600; }
.kpi .sub .down { color: var(--sys-red); font-weight: 600; }

.kpi.primary .icon { background: linear-gradient(135deg, #007AFF, #5856D6); }
.kpi.success .icon { background: linear-gradient(135deg, #34C759, #30B94D); }
.kpi.success .value { color: #248A3D; }
.kpi.warning .icon { background: linear-gradient(135deg, #FF9500, #FF7A00); }
.kpi.warning .value { color: #C77800; }
.kpi.danger .icon  { background: linear-gradient(135deg, #FF3B30, #FF2D55); }
.kpi.danger .value  { color: #D70015; }
.kpi.purple .icon { background: linear-gradient(135deg, #AF52DE, #5856D6); }
.kpi.purple .value { color: #8944AB; }
.kpi.cyan .icon   { background: linear-gradient(135deg, #5AC8FA, #32ADE6); }
.kpi.cyan .value  { color: #0071A4; }

/* ========= Table ========= */
.table-wrap {
  overflow-x: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
table.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ledger th, table.ledger td {
  padding: 14px 18px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--separator);
  letter-spacing: -0.01em;
}
table.ledger thead th {
  background: transparent;
  font-weight: 500;
  color: var(--label-3);
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: none;
  letter-spacing: 0;
}
table.ledger tbody tr { transition: background .12s; }
table.ledger tbody tr:hover { background: rgba(0,122,255,.04); }
table.ledger tbody tr:last-child td { border-bottom: 0; }
table.ledger td.num, table.ledger th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
table.ledger td a { color: var(--sys-blue); font-weight: 500; }
table.ledger td a:hover { opacity: .75; }

/* ========= Badge — iOS segmented style ========= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 100px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.badge::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.ok    { background: rgba(52,199,89,.14);  color: #248A3D; }
.badge.warn  { background: rgba(255,149,0,.15);  color: #C77800; }
.badge.err   { background: rgba(255,59,48,.14);  color: #D70015; }
.badge.muted { background: rgba(120,120,128,.14);color: var(--label-2); }
.badge.info  { background: rgba(0,122,255,.12);  color: #0056D6; }

/* ========= Button — iOS rounded rect ========= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 0;
  background: var(--sys-blue);
  color: #fff;
  transition: all .15s ease;
  line-height: 1.2;
  text-decoration: none;
  letter-spacing: -0.01em;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,122,255,.15);
}
.btn:hover { background: #0A84FF; text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,122,255,.3); color: #fff; }
.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(0,122,255,.15); }
.btn.secondary {
  background: rgba(120,120,128,.12);
  color: var(--label);
  box-shadow: none;
}
.btn.secondary:hover { background: rgba(120,120,128,.2); color: var(--label); box-shadow: none; transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--sys-blue); box-shadow: none; }
.btn.ghost:hover { background: rgba(0,122,255,.08); box-shadow: none; }
.btn.danger { background: var(--sys-red); box-shadow: 0 1px 2px rgba(255,59,48,.15); }
.btn.danger:hover { background: #FF2D20; box-shadow: 0 4px 12px rgba(255,59,48,.3); }
.btn.sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.btn svg { width: 14px; height: 14px; }
.btn.sm svg { width: 12px; height: 12px; }

/* ========= Form — iOS style ========= */
form.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px 28px;
}
form.form-grid .full { grid-column: 1 / -1; }
form.form-grid label {
  display: block;
  font-size: 13px;
  color: var(--label-2);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
form.form-grid label .required { color: var(--sys-red); margin-left: 2px; }
form.form-grid input,
form.form-grid select,
form.form-grid textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--separator-2);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--label);
  transition: all .15s;
  letter-spacing: -0.01em;
}
form.form-grid input:hover, form.form-grid select:hover, form.form-grid textarea:hover { border-color: rgba(0,122,255,.4); }
form.form-grid input:focus,
form.form-grid select:focus,
form.form-grid textarea:focus {
  outline: 0;
  border-color: var(--sys-blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,.15);
}
form.form-grid input[readonly], form.form-grid select:disabled {
  background: var(--bg-grouped);
  color: var(--label-3);
  cursor: not-allowed;
}
form.form-grid textarea { resize: vertical; min-height: 90px; font-family: inherit; }
form.form-grid .help { font-size: 12px; color: var(--label-3); margin-top: 6px; letter-spacing: -0.01em; }
form.form-grid .form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--separator);
}

/* ========= Filter bar ========= */
.filter-bar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
  padding: 16px 18px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.filter-bar .field { display: flex; flex-direction: column; gap: 6px; }
.filter-bar .field label {
  font-size: 12px;
  color: var(--label-3);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.filter-bar .field input, .filter-bar .field select {
  padding: 7px 12px;
  border: 1px solid var(--separator-2);
  border-radius: 8px;
  font-size: 13px;
  min-width: 160px;
  background: var(--bg-elevated);
  color: var(--label);
  font-family: inherit;
  transition: all .15s;
}
.filter-bar .field input:hover, .filter-bar .field select:hover { border-color: rgba(0,122,255,.4); }
.filter-bar .field input:focus, .filter-bar .field select:focus {
  outline: 0;
  border-color: var(--sys-blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,.15);
}

/* ========= Login — Apple sign-in inspired ========= */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(at 20% 10%, rgba(0,122,255,.10), transparent 55%),
    radial-gradient(at 80% 80%, rgba(175,82,222,.08), transparent 55%),
    #F5F5F7;
  padding: 20px;
  position: relative;
}
.login-card {
  background: rgba(255,255,255,0.8);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 44px 42px 38px;
  border-radius: var(--radius-xl);
  width: 420px;
  max-width: 100%;
  border: 1px solid rgba(255,255,255,.8);
  box-shadow:
    0 20px 60px rgba(0,0,0,.08),
    0 4px 20px rgba(0,0,0,.04),
    inset 0 1px 0 rgba(255,255,255,.6);
}
.login-card .login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  text-align: center;
}
.login-card .login-brand .mark {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 22px;
  box-shadow: 0 10px 30px rgba(0,122,255,.35), inset 0 1px 0 rgba(255,255,255,.2);
  letter-spacing: -0.02em;
}
.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--label);
}
.login-card .sub { color: var(--label-3); font-size: 13px; letter-spacing: -0.01em; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { font-size: 13px; color: var(--label-2); font-weight: 500; display: block; margin-bottom: 6px; letter-spacing: -0.01em; }
.login-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--separator-2);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: rgba(255,255,255,.9);
  color: var(--label);
  transition: all .15s;
  letter-spacing: -0.01em;
}
.login-card input:focus {
  outline: 0;
  border-color: var(--sys-blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,.15);
}
.login-card button {
  padding: 12px;
  background: var(--sys-blue);
  color: #fff;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  transition: all .15s;
  margin-top: 8px;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 14px rgba(0,122,255,.3);
}
.login-card button:hover { background: #0A84FF; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,122,255,.4); }
.login-card .error {
  color: var(--sys-red);
  font-size: 13px;
  padding: 10px 14px;
  background: rgba(255,59,48,.08);
  border-radius: 8px;
}
.login-card .hint {
  font-size: 12px;
  color: var(--label-2);
  margin-top: 22px;
  line-height: 1.9;
  padding: 14px 16px;
  background: var(--bg-grouped);
  border-radius: 10px;
  letter-spacing: -0.01em;
}
.login-card .hint strong { color: var(--label); font-weight: 600; display: block; margin-bottom: 6px; font-size: 12px; }

/* ========= Alert ========= */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.alert.ok { background: rgba(52,199,89,.12); color: #248A3D; }
.alert.err { background: rgba(255,59,48,.1); color: #D70015; }
.alert svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ========= Notifications ========= */
.notif-item {
  padding: 16px 22px;
  border-bottom: 1px solid var(--separator);
  transition: background .15s;
}
.notif-item:hover { background: rgba(0,122,255,.04); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: rgba(0,122,255,.04); position: relative; }
.notif-item.unread::before {
  content: '';
  position: absolute;
  left: 9px; top: 22px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--sys-blue);
}
.notif-item strong { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.notif-item .meta {
  font-size: 12px;
  color: var(--label-3);
  margin-top: 5px;
  display: flex; gap: 10px; align-items: center;
  letter-spacing: -0.01em;
}

/* ========= Detail grid ========= */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  font-size: 14px;
}
.detail-grid .row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--separator);
  letter-spacing: -0.01em;
}
.detail-grid .row .k { color: var(--label-3); min-width: 140px; font-size: 13px; flex-shrink: 0; }
.detail-grid .row .v { color: var(--label); font-weight: 500; word-break: break-all; }

/* ========= Preview box ========= */
.preview-box {
  background: linear-gradient(135deg, rgba(0,122,255,.05), rgba(88,86,214,.04));
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 20px;
}
.preview-box h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--label);
  display: flex; align-items: center; gap: 8px;
  letter-spacing: -0.01em;
}

/* ========= Progress bar ========= */
.bar-row { margin-bottom: 16px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row .bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.bar-row .bar-label .name { font-weight: 500; color: var(--label); }
.bar-row .bar-label .val { color: var(--label-3); font-variant-numeric: tabular-nums; }
.bar-row .bar-track {
  background: rgba(120,120,128,.15);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}
.bar-row .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
  background: var(--sys-blue);
}
.bar-row:nth-child(2) .bar-fill { background: var(--sys-green); }
.bar-row:nth-child(3) .bar-fill { background: var(--sys-orange); }
.bar-row:nth-child(4) .bar-fill { background: var(--sys-purple); }
.bar-row:nth-child(5) .bar-fill { background: var(--sys-teal); }
.bar-row:nth-child(6) .bar-fill { background: var(--sys-pink); }
.bar-row:nth-child(n+7) .bar-fill { background: var(--sys-indigo); }

/* ========= Chart containers ========= */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-grid .card { margin-bottom: 0; }
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 340px; }

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
}
.legend-list .row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.legend-list .swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-list .row .name { flex: 1; color: var(--label); font-weight: 500; letter-spacing: -0.01em; }
.legend-list .row .val  { color: var(--label-3); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}

/* ========= Chart containers ========= */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-box {
  position: relative;
  height: 280px;
  width: 100%;
}
.chart-box.sm { height: 220px; }
.chart-box canvas { max-width: 100%; }

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--separator);
}
.legend-list .row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.legend-list .swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-list .name { flex: 1; color: var(--label); font-weight: 500; }
.legend-list .val { color: var(--label-3); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-box { height: 260px; }
}
@media (min-width: 1400px) {
  .chart-box { height: 320px; }
}

/* ========= Segmented tabs (iOS style) ========= */
.seg-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(120,120,128,.12);
  border-radius: 10px;
  margin-bottom: 16px;
}
.seg-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--label-2);
  border-radius: 7px;
  transition: all .15s;
  letter-spacing: -0.01em;
  text-decoration: none;
  line-height: 1.4;
}
.seg-tab:hover { color: var(--label); text-decoration: none; opacity: 1; }
.seg-tab.active {
  background: #fff;
  color: var(--label);
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 1px rgba(0,0,0,.04);
}
.seg-tab .seg-count {
  background: rgba(120,120,128,.2);
  color: var(--label-2);
  font-size: 11px;
  font-weight: 600;
  padding: 0 7px;
  border-radius: 8px;
  min-width: 20px;
  text-align: center;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}
.seg-tab.active .seg-count {
  background: var(--sys-blue);
  color: #fff;
}
.seg-tab .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.seg-tab .dot-pending { background: var(--sys-orange); }
.seg-tab .dot-done    { background: var(--sys-green); }

/* ========= Bulk selection bar ========= */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: hsl(221 83% 53% / 0.06);
  border: 1px solid hsl(221 83% 53% / 0.25);
  border-radius: 10px;
  margin-bottom: 12px;
  animation: bulkSlide .18s ease-out;
}
@keyframes bulkSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bulk-bar .bulk-info { font-size: 13px; color: var(--label); }
.bulk-bar .bulk-info strong { color: var(--sys-blue); font-size: 15px; margin: 0 2px; font-variant-numeric: tabular-nums; }
.bulk-bar .bulk-info a { font-size: 12px; }
.bulk-bar .bulk-actions { display: flex; gap: 8px; }

/* Row highlight when selected */
table.ledger tbody tr.row-selected {
  background: hsl(221 83% 53% / 0.08) !important;
}
table.ledger tbody tr.row-selected:hover {
  background: hsl(221 83% 53% / 0.12) !important;
}

/* Checkbox cell - compact */
table.ledger td input[type="checkbox"],
table.ledger th input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--sys-blue);
  margin: 0;
  vertical-align: middle;
}

/* ========= Meta cell (for timestamp + user) ========= */
.meta-cell { line-height: 1.35; }
.meta-cell .meta-time { font-size: 12px; color: var(--label); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.meta-cell .meta-user { font-size: 11px; color: var(--label-3); margin-top: 1px; }

/* ========= Empty ========= */
.empty {
  text-align: center;
  color: var(--label-3);
  padding: 60px 20px;
  font-size: 14px;
  letter-spacing: -0.01em;
}

/* ========= Helpers ========= */
.text-muted { color: var(--label-3); }
.text-sm { font-size: 12px; }
.text-ok { color: #248A3D; font-weight: 600; }
.text-err { color: #D70015; font-weight: 600; }
.text-warn { color: #C77800; font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }

/* ========= Responsive ========= */

/* Tablet / small laptop: tighten paddings, auto-reflow grids */
@media (max-width: 1024px) {
  .main-inner { padding: 24px 24px; }
  .kpi .value { font-size: 26px; }
  .topbar h1 { font-size: 24px; }
  form.form-grid { gap: 18px 20px; }
}

/* Collapsed sidebar: only on tablet / phone */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .brand { padding: 18px 12px; justify-content: center; }
  .sidebar .brand-text,
  .sidebar nav a span,
  .sidebar .user-box .user-info { display: none; }
  .sidebar nav { padding: 12px 8px; }
  .sidebar nav a {
    justify-content: center;
    padding: 10px;
  }
  .sidebar nav a .count-dot {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 16px;
    padding: 0 4px;
    margin: 0;
    font-size: 9px;
    line-height: 14px;
  }
  .sidebar .user-box { justify-content: center; padding: 10px; }
  .sidebar .user-box form { display: none; }
  .main-inner { padding: 20px 18px; max-width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .topbar .actions { flex-wrap: wrap; }
  .filter-bar { gap: 10px; padding: 14px; }
  .filter-bar .field input, .filter-bar .field select { min-width: 140px; }
  form.form-grid { grid-template-columns: 1fr; gap: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kpi { padding: 16px; }
  .kpi .value { font-size: 22px; }
  .kpi .label { font-size: 12px; }
  .card { padding: 16px; }
  .card-header { margin: -16px -16px 0; padding: 14px 16px; }
  .seg-tabs { overflow-x: auto; white-space: nowrap; max-width: 100%; }
  .seg-tab { flex-shrink: 0; }
  table.ledger th, table.ledger td { padding: 10px 12px; font-size: 13px; }
}

/* Phone */
@media (max-width: 560px) {
  .main-inner { padding: 14px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi .value { font-size: 20px; }
  .kpi .kpi-head .icon { width: 28px; height: 28px; border-radius: 8px; }
  .kpi .kpi-head .icon svg { width: 14px; height: 14px; }
  .card { padding: 14px; border-radius: 12px; }
  .card-header { margin: -14px -14px 0; padding: 12px 14px; }
  .card h2 { font-size: 15px; }
  .topbar h1 { font-size: 20px; }
  .topbar .subtitle { font-size: 12px; }
  form.form-grid .form-actions { flex-direction: column-reverse; }
  form.form-grid .form-actions .btn { width: 100%; }
  .btn { padding: 8px 14px; }
  .sidebar { width: 56px; }
  .chart-box { height: 200px; }
  .chart-box.sm { height: 180px; }
  .login-card { padding: 28px 22px; }
  .login-card .login-brand .mark { width: 44px; height: 44px; font-size: 17px; }
  .login-card h1 { font-size: 18px; }
}

/* Scrollbar — macOS overlay style */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,120,128,.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,120,128,.5); }
