/* ───────────────────────── Design tokens ───────────────────────── */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9ecf1;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-weak: #eef0ff;
  --accent-ink: #3730a3;
  --on-accent: #ffffff;
  --success: #067647; --success-bg: #ecfdf3; --success-bd: #abefc6;
  --warning: #b54708; --warning-bg: #fffaeb; --warning-bd: #fedf89;
  --danger: #b42318;  --danger-bg: #fef3f2;  --danger-bd: #fecdca;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .22);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #182032;
  --surface-3: #1f2940;
  --border: #243049;
  --border-strong: #33415e;
  --text: #f2f4f7;
  --text-2: #d0d5dd;
  --muted: #98a2b3;
  --faint: #667085;
  --accent: #7c7cff;
  --accent-hover: #9393ff;
  --accent-weak: #1e2250;
  --accent-ink: #c7c9ff;
  --on-accent: #0b0f17;
  --success: #47cd89; --success-bg: #0e2a1d; --success-bd: #175c3a;
  --warning: #fdb022; --warning-bg: #2e2110; --warning-bd: #6a4a12;
  --danger: #f97066;  --danger-bg: #2f1512;  --danger-bd: #6e2a22;
  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ───────────────────────── Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .money { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }

/* ───────────────────────── Splash & login ───────────────────────── */
.splash { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 24px; background: var(--bg); z-index: 50; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 14px; letter-spacing: .02em;
}
.brand-mark.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.brand-mark.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }

.login { min-height: 100%; }
.login-card { width: 100%; max-width: 380px; }
.login-head { text-align: center; margin-bottom: 28px; }
.login-head .brand-mark { margin: 0 auto 18px; }
.login-head h1 { font-size: 22px; }
.login-head p { color: var(--muted); margin-top: 6px; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.login-foot { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--faint); }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-weak); color: var(--accent-ink); padding: 12px 14px; border-radius: 12px; font-size: 13px; margin-bottom: 18px; }
.notice svg.i { margin-top: 1px; }
.notice.error { background: var(--danger-bg); color: var(--danger); }

/* ───────────────────────── Auth ───────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 44px 56px; color: #fff;
  background:
    radial-gradient(900px 520px at -10% -10%, rgba(99, 102, 241, .9) 0%, transparent 60%),
    radial-gradient(760px 480px at 110% 110%, rgba(67, 56, 202, .9) 0%, transparent 55%),
    #1e1b4b;
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent 75%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent 75%);
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-logo { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.auth-logo img { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); }
.auth-hero { max-width: 460px; }
.auth-hero h2 { font-size: 36px; line-height: 1.12; letter-spacing: -.03em; font-weight: 600; }
.auth-hero p { margin-top: 16px; color: rgba(255, 255, 255, .74); font-size: 15.5px; }
.auth-points { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: center; color: rgba(255, 255, 255, .92); }
.auth-points .tick { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .12); flex: none; }
.auth-points svg.i { width: 16px; height: 16px; }
.auth-brand-foot { font-size: 12.5px; color: rgba(255, 255, 255, .55); }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-mobile-logo { display: none; }
.auth-head { margin-bottom: 24px; }
.auth-head h1 { font-size: 27px; letter-spacing: -.025em; line-height: 1.2; }
.auth-head p { color: var(--muted); margin-top: 6px; }
.auth-head.center { text-align: center; }
.auth-tabs { margin-bottom: 22px; }
.auth-tabs button { height: 36px; }
.auth-switch { text-align: center; margin-top: 22px; color: var(--muted); }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; font-size: 12.5px; color: var(--faint); text-align: center; }
.auth-legal { margin-top: 36px; font-size: 12px; color: var(--faint); text-align: center; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; font-size: inherit; display: inline-flex; align-items: center; gap: 6px; }
.link-btn:hover { text-decoration: underline; }
.link-btn svg.i { width: 15px; height: 15px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12.5px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google { color: var(--text); }
.auth-icon { width: 58px; height: 58px; border-radius: 16px; background: var(--accent-weak); color: var(--accent); display: grid; place-items: center; margin: 0 auto 18px; }
.auth-icon svg.i { width: 26px; height: 26px; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }
.splash-logo { width: 64px; height: 64px; border-radius: 18px; }
@media (max-width: 960px) {
  .auth { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .auth-brand { display: none; }
  .auth-main { justify-content: flex-start; padding: calc(28px + env(safe-area-inset-top)) 18px 32px; }
  .auth-mobile-logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15.5px; margin-bottom: 22px; }
  .auth-mobile-logo img { width: 34px; height: 34px; border-radius: 9px; }
  .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 26px 22px; box-shadow: var(--shadow); }
  .auth-head h1 { font-size: 23px; }
}

/* ───────────────────────── App shell ───────────────────────── */
.app { min-height: 100%; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; z-index: 20;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-name { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.brand-sub { font-size: 12px; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11.5px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent-ink); }
.nav-item.active svg.i { stroke: var(--accent); }
.sidebar-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.sync-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 10px; min-width: 0; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 2px 8px; min-width: 0; }
.side-user:empty { display: none; }
.side-user .li-title { font-size: 13px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-mark.has-logo { background: #fff; border: 1px solid var(--border); overflow: hidden; }
.top-avatar { border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview {
  width: 72px; height: 72px; border-radius: 16px; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--surface-2); border: 1px dashed var(--border-strong);
  color: var(--muted); font-weight: 700; font-size: 20px;
}
.logo-preview.has-logo { background: #fff; border-style: solid; border-color: var(--border); }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand .sidebar-close { display: none; margin-left: auto; }
.scrim { display: none; }
.sync-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.sync-pill .dot.on { background: var(--success); }
.sync-pill .dot.warn { background: var(--warning); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar { display: none; }
.view { max-width: 1180px; margin: 0 auto; padding: 32px 32px 64px; }
.bottom-nav { display: none; }

/* ───────────────────────── Page header ───────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; line-height: 1.2; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 14px; cursor: pointer; background: none; border: 0; padding: 0; }
.back-link:hover { color: var(--text); }

/* ───────────────────────── Cards ───────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-head .link { font-size: 13px; font-weight: 500; cursor: pointer; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-label .kpi-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.kpi-label .kpi-ic svg.i { width: 16px; height: 16px; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 12px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.two-col-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ───────────────────────── Lists ───────────────────────── */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-2); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-end { text-align: right; flex: none; }

.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 600; font-size: 13px; background: var(--accent-weak); color: var(--accent-ink); }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .empty-ic { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 12px; color: var(--muted); }
.empty h4 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

/* ───────────────────────── Tables ───────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }

/* ───────────────────────── Buttons ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-weight: 500; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(.95); background: var(--danger); color: #fff; }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn svg.i { width: 17px; height: 17px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; border: 0; background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ───────────────────────── Forms ───────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; grid-column: 1 / -1; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.req::after { content: " *"; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow-sm);
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.input::placeholder { color: var(--faint); }
.input-group { position: relative; }
.input-group > svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-group > .input { padding-left: 38px; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-prefix > .input { padding-left: 28px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input-group { flex: 1; min-width: 220px; }
.toolbar .select { width: auto; min-width: 150px; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.seg button { border: 0; background: none; height: 32px; padding: 0 14px; border-radius: 8px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.block { display: flex; }
.seg.block button { flex: 1; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--border-strong); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .count { opacity: .6; font-variant-numeric: tabular-nums; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bd); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.badge-accent { background: var(--accent-weak); color: var(--accent-ink); border-color: transparent; }

/* Checkbox */
.check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex: none; }

/* ───────────────────────── Tabs ───────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 10px 14px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

/* ───────────────────────── Profile ───────────────────────── */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-head h2 { font-size: 22px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px 24px; }
.meta dt { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.meta dd { margin: 0; font-weight: 500; word-break: break-word; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.stat-strip > div { padding: 14px 20px; border-right: 1px solid var(--border); }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-strip .l { font-size: 12.5px; color: var(--muted); }

/* ───────────────────────── Fee collection ───────────────────────── */
.fee-line { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.fee-line:last-child { border-bottom: 0; }
.fee-line .li-main { cursor: pointer; }
.fee-line .input-prefix { width: 130px; flex: none; }
.fee-line .input { height: 36px; text-align: right; }
.fee-line.off .li-title { color: var(--muted); }
.total-box { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.total-box .amount { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sum-rows { display: flex; flex-direction: column; gap: 8px; }
.sum-rows > div { display: flex; justify-content: space-between; gap: 12px; }

.picker { position: relative; }
.picker-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; z-index: 30; }

/* ───────────────────────── Attendance ───────────────────────── */
.att-row { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.att-row:last-child { border-bottom: 0; }
.att-toggle { display: inline-flex; gap: 4px; flex: none; }
.att-toggle button { width: 38px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.att-toggle button.on.P { background: var(--success-bg); border-color: var(--success-bd); color: var(--success); }
.att-toggle button.on.A { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger); }
.att-toggle button.on.L { background: var(--warning-bg); border-color: var(--warning-bd); color: var(--warning); }
.sticky-bar { position: sticky; bottom: 16px; margin-top: 16px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 5; }
.register { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.register th, .register td { padding: 0; text-align: center; border-bottom: 1px solid var(--border); }
.register th { color: var(--muted); font-weight: 500; height: 32px; min-width: 28px; background: var(--surface-2); }
.register td { height: 34px; }
.register .name { text-align: left; padding: 0 14px; position: sticky; left: 0; background: var(--surface); min-width: 170px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 500; z-index: 1; border-right: 1px solid var(--border); }
.register th.name { background: var(--surface-2); }
.register .pct { padding: 0 12px; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; }
.cell { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-weight: 600; font-size: 11px; }
.cell.P { background: var(--success-bg); color: var(--success); }
.cell.A { background: var(--danger-bg); color: var(--danger); }
.cell.L { background: var(--warning-bg); color: var(--warning); }
.cell.none { color: var(--faint); }

/* ───────────────────────── Chart ───────────────────────── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11.5px; font-family: var(--font); }
.chart .value-label { fill: var(--text); font-size: 11.5px; font-weight: 600; font-family: var(--font); }
.chart .bar { fill: var(--accent); transition: opacity .15s; }
.chart .bar.dim { opacity: .45; }
.chart .hit { fill: transparent; cursor: default; }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); padding: 7px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px; box-shadow: var(--shadow-lg); }
.chart-tip b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }

/* ───────────────────────── Modal / sheet ───────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 24px; z-index: 60; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }
.modal-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes up { from { transform: translateY(100%); } }

/* ───────────────────────── Toasts ───────────────────────── */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s ease-out; }
.toast svg.i { width: 17px; height: 17px; }
.toast.error { background: var(--danger); color: #fff; }

/* ───────────────────────── Receipt ───────────────────────── */
.receipt { max-width: 720px; margin: 0 auto; background: #fff; color: #101828; border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; }
.receipt .r-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 2px solid #101828; }
.receipt .r-inst { display: flex; gap: 14px; }
.receipt .r-inst .brand-mark { background: #4f46e5; color: #fff; width: 48px; height: 48px; font-size: 17px; }
.receipt .r-logo { width: 60px; height: 60px; object-fit: contain; border-radius: 10px; flex: none; }
.receipt h2 { font-size: 20px; }
.receipt .r-muted { color: #667085; font-size: 12.5px; }
.receipt .r-title { text-align: right; }
.receipt .r-title .tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .12em; color: #4f46e5; background: #eef0ff; padding: 4px 10px; border-radius: 6px; }
.receipt .r-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; padding: 20px 0; }
.receipt .r-meta dt { font-size: 11.5px; color: #667085; text-transform: uppercase; letter-spacing: .05em; }
.receipt .r-meta dd { margin: 2px 0 0; font-weight: 600; }
.receipt table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.receipt th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: #667085; font-weight: 600; padding: 10px 0; border-bottom: 1px solid #e4e7ec; }
.receipt td { padding: 11px 0; border-bottom: 1px solid #f2f4f7; }
.receipt .num { text-align: right; font-variant-numeric: tabular-nums; }
.receipt .r-total { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; padding: 14px 16px; background: #f5f6f8; border-radius: 10px; }
.receipt .r-total .amt { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.receipt .r-words { margin-top: 10px; font-size: 13px; color: #344054; }
.receipt .r-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 44px; }
.receipt .sign { text-align: center; min-width: 180px; border-top: 1px solid #98a2b3; padding-top: 6px; font-size: 12.5px; color: #667085; }
.receipt .paid-stamp { display: inline-block; border: 2px solid #067647; color: #067647; font-weight: 700; letter-spacing: .14em; padding: 4px 12px; border-radius: 6px; transform: rotate(-6deg); font-size: 13px; }

/* ───────────────────────── Responsive ───────────────────────── */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  /* Sidebar becomes a slide-out drawer */
  .sidebar {
    width: min(86vw, 320px); z-index: 70; border-right: 0;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-104%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    box-shadow: var(--shadow-lg); visibility: hidden;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; }
  .sidebar-brand { padding: 4px 4px 18px 8px; }
  .sidebar-brand .sidebar-close { display: grid; }
  .nav-item { padding: 12px; font-size: 15px; border-radius: 10px; }
  .nav-item svg.i { width: 20px; height: 20px; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(16, 24, 40, .5); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  .menu-btn { margin-left: -8px; }
  .desktop-only { display: none !important; }
  /* Page title shows in the top bar only after the big heading scrolls away */
  .topbar-title { opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; }
  body.scrolled .topbar-title { opacity: 1; transform: none; }
  .main { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 20; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 16px;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.6) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
  .topbar-right { gap: 2px; }
  .topbar-title { font-weight: 600; font-size: 16px; }
  .view { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 18px; }
  .page-head h1 { font-size: 21px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.6) blur(12px);
    border-top: 1px solid var(--border);
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 500; cursor: pointer; border-radius: 10px; }
  .bn-item svg.i { width: 22px; height: 22px; }
  .bn-item.active { color: var(--accent); }
  .btn { height: 42px; }
  .btn-sm { height: 34px; }
  .input, .select { height: 44px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .fee-line .input { height: 40px; }
  .toolbar .input-group { flex-basis: 100%; }
  .toolbar .select { flex: 1; min-width: 0; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .sticky-bar { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .overlay { place-items: end center; padding: 0; }
  .modal { max-width: none !important; border-radius: 20px 20px 0 0; max-height: 92vh; animation: up .22s ease-out; padding-bottom: env(safe-area-inset-bottom); }
  .receipt { padding: 22px; }
}
@media (max-width: 600px) {
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 21px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .two-col-even { grid-template-columns: minmax(0, 1fr); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > div:nth-child(2) { border-right: 0; }
  .stat-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .list-item, .fee-line, .att-row { padding-left: 16px; padding-right: 16px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .hide-sm { display: none !important; }

  /* Tables marked .stack turn into cards on phones */
  .table-wrap:has(> .table.stack) { overflow: visible; }
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tfoot { display: block; }
  .table.stack tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
  }
  .table.stack tbody tr:last-child { border-bottom: 0; }
  .table.stack td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; font-size: 14px; }
  .table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); margin-bottom: 1px; }
  .table.stack td.primary { grid-column: 1 / -1; grid-row: 1; font-size: 14.5px; }
  .table.stack tr:has(> td.pin) td.primary { grid-column: 1 / 3; }
  .table.stack td.pin { grid-column: 3; grid-row: 1; justify-self: end; }
  .table.stack td.span { grid-column: 1 / -1; }
  .table.stack td.act { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
  .table.stack td.act .btn { width: 100%; }
  .table.stack td:empty { display: none; }
  .table.stack tfoot tr { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
  .table.stack tfoot td { background: none; border: 0; }
  .table.stack tfoot td:last-child:not(:empty) { grid-column: -2 / -1; text-align: right; }
  .table.stack tbody tr.clickable:hover td { background: none; }
  .table.stack tbody tr.clickable:active { background: var(--surface-2); }
  .receipt .r-head { flex-direction: column; }
  .receipt .r-title { text-align: left; }
  .receipt .r-meta { grid-template-columns: 1fr; }
}
@media (min-width: 861px) { .hide-lg { display: none !important; } }

/* ───────────────────────── Print ───────────────────────── */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .sidebar, .topbar, .bottom-nav, .no-print, .toasts, #overlays { display: none !important; }
  .main { margin: 0; }
  .view { padding: 0; max-width: none; }
  .receipt { border: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
}
