/* AstraBit CRM — landing brand: emerald + teal, navy headings, Roboto */
:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6eaef;
  --border-strong: #d5dbe3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-200: #a7f3d0;
  --teal: #2dd4bf;
  --chart-muted: #cbd5e1;
  --green: #059669;
  --green-50: #ecfdf5;
  --red: #dc2626;
  --red-50: #fef2f2;
  --red-200: #fecaca;
  --amber: #d97706;
  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --blue: #2563eb;
  --blue-50: #eff6ff;
  --blue-200: #bfdbfe;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px -8px rgba(15, 23, 42, .08);
  --shadow-btn: 0 8px 18px -8px rgba(16, 185, 129, .55);
  --sidebar: 256px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-2: #0f1727;
  --border: #1f2a3d;
  --border-strong: #2b3a52;
  --text: #e5edf7;
  --text-2: #c3cfdd;
  --muted: #8b9ab0;
  --chart-muted: #475569;
  --primary: #10b981;
  --primary-600: #34d399;
  --primary-700: #6ee7b7;
  --primary-50: rgba(16, 185, 129, .12);
  --primary-100: rgba(16, 185, 129, .2);
  --primary-200: rgba(16, 185, 129, .35);
  --green: #34d399;
  --green-50: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-50: rgba(248, 113, 113, .12);
  --red-200: rgba(248, 113, 113, .35);
  --amber: #fbbf24;
  --amber-50: rgba(251, 191, 36, .12);
  --amber-200: rgba(251, 191, 36, .35);
  --blue: #60a5fa;
  --blue-50: rgba(96, 165, 250, .12);
  --blue-200: rgba(96, 165, 250, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-btn: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text-2);
  font: 14px/1.55 "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--primary-700); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; color: var(--text); }
h1 { font-size: 26px; font-weight: 900; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
b, strong { color: var(--text); }
.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- brand wordmark: "Astra" green, "Bit" navy, as on the landing */
.wordmark { font-weight: 900; font-size: 22px; letter-spacing: -.02em; color: var(--text); white-space: nowrap; }
.wordmark .a { color: var(--primary); }
.eyebrow {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--primary-50); border: 1px solid var(--primary-200); color: var(--primary-600);
}

/* ---------- layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 40; transition: transform .2s; padding-bottom: 24px;
}
.sidebar .brand { display: flex; align-items: center; height: 64px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.nav { padding: 8px 12px; }
.nav-section { padding: 18px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav a, .nav .nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; margin: 1px 0; border-radius: var(--radius-sm);
  color: var(--text-2); font: inherit; font-weight: 500; background: none; border: 0; text-align: left; cursor: pointer;
}
.nav a:hover, .nav .nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-50); color: var(--primary-600); font-weight: 700; }
.nav .badge { margin-left: auto; }
.nav .ico { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.nav a:hover .ico, .nav .nav-link:hover .ico { color: var(--text-2); }
.nav a.active .ico { color: var(--primary); }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 64px; background: var(--surface);
  border-bottom: 1px solid var(--border); box-shadow: 0 4px 14px -12px rgba(15, 23, 42, .25);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
}
.topbar form.search { flex: 1; max-width: 440px; position: relative; min-width: 0; }
.topbar form.search .input { padding-right: 38px; background: var(--surface-2); }
.topbar form.search .input:focus { background: var(--surface); }
.kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none;
  font: 600 11px/1 ui-monospace, monospace; color: var(--muted); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 3px 6px; background: var(--surface);
}
.topbar form.search .input:focus + .kbd { display: none; }
@media (max-width: 960px) { .kbd { display: none; } }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar .user .name { line-height: 1.25; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--radius-sm);
  background: none; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.avatar:hover { color: #fff; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin-bottom: 2px; }
.page-head .sub { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .input, .actions .select { width: auto; }
.backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 10px 40px rgba(15, 23, 42, .25); }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .user .name { display: none; }
  h1 { font-size: 22px; }
}

/* ---------- cards & grids */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; min-width: 0;
}
.card > h2:first-child, .card > h3:first-child, .card-head { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-side { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
  .g4 > .kpi { padding: 14px; margin-bottom: 0; }
  .g4 > .kpi .value { font-size: 18px; }
  .grid { gap: 12px; }
  .page-head { align-items: flex-start; }
}

.kpi { padding: 18px 20px; }
.kpi .label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.kpi .value { font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 900; color: var(--text); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.good .value { color: var(--green); }
.kpi.bad .value { color: var(--red); }
.kpi.warn .value { color: var(--amber); }

.stat-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row .k { color: var(--muted); }
.stat-row .v { font-weight: 600; color: var(--text); text-align: right; }

/* ---------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); white-space: nowrap;
}
.table td { color: var(--text-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tr.void td { opacity: .45; text-decoration: line-through; }
.table.compact th, .table.compact td { padding: 7px 9px; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 20px; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 20px; }

/* journal */
.journal th, .journal td { text-align: center; padding: 7px 6px; font-size: 13px; }
.journal th:first-child, .journal td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 180px; }
.cell-abs { background: var(--red-50); color: var(--red); font-weight: 700; }
.cell-grade { font-weight: 700; color: var(--text); }

/* ---------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
form > .field + .field, form > .form-grid + .field, form > .field + .form-grid, form > .field + div > .field { margin-top: 14px; }
.field label { display: block; font-weight: 600; color: var(--text); margin-bottom: 6px; font-size: 13px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .error { font-size: 12px; color: var(--red); margin-top: 5px; }
.field.check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field.check .help, .field.check .error { flex-basis: 100%; margin-top: 0; padding-left: 26px; }
.field.check label { margin: 0; font-weight: 500; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; min-height: 42px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input.color { padding: 4px; width: 64px; }
.input.sm, .select.sm { padding: 6px 10px; min-height: 34px; font-size: 13px; }
textarea.input { min-height: 80px; resize: vertical; }
.checkbox { width: 18px; height: 18px; accent-color: var(--primary); }
.errorlist { color: var(--red); margin: 0 0 12px; padding-left: 18px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { min-width: 140px; flex: 1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 150px; }

/* ---------- buttons: emerald primary, white outlined secondary */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer;
  white-space: nowrap; text-decoration: none; background: var(--primary); color: #fff; min-height: 42px;
  box-shadow: var(--shadow-btn); transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--primary-600); color: #fff; }
.btn:active { transform: translateY(1px); }
[data-theme="dark"] .btn:hover { background: #0ea371; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.btn.secondary:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--red); box-shadow: none; }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--primary); }
.btn.ghost { background: transparent; color: var(--primary-600); box-shadow: none; }
.btn.ghost:hover { background: var(--primary-50); color: var(--primary-700); }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 13px; box-shadow: none; }
.btn.block { width: 100%; }

/* ---------- badges, alerts */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge.green { background: var(--primary-50); color: var(--primary-600); border-color: var(--primary-200); }
.badge.red { background: var(--red-50); color: var(--red); border-color: var(--red-200); }
.badge.amber { background: var(--amber-50); color: var(--amber); border-color: var(--amber-200); }
.badge.blue { background: var(--blue-50); color: var(--blue); border-color: var(--blue-200); }
.badge.dot::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: middle; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; }
.alert.success { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-700); }
.alert.error { background: var(--red-50); border-color: var(--red-200); color: var(--red); }
.alert.warning { background: var(--amber-50); border-color: var(--amber-200); color: var(--amber); }
.alert.info { background: var(--primary-50); border-color: var(--primary-200); color: var(--text-2); }
.messages { position: fixed; right: 20px; top: 76px; z-index: 60; width: min(420px, calc(100vw - 32px)); }
.messages .alert { background-color: var(--surface); box-shadow: 0 12px 32px -12px rgba(15, 23, 42, .3); }

/* ---------- tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary-600); border-color: var(--primary); }
.tabs a:hover { color: var(--text); }

/* ---------- misc */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 11px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .meta { min-width: 0; }
.person .meta div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.progress { height: 8px; background: var(--primary-50); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.pill-color { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.steps li:last-child { border-bottom: 0; }
.steps .num {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); flex-shrink: 0;
}
.steps li.done .num { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps .txt { flex: 1; min-width: 0; }
.chart-box { position: relative; height: 300px; }
.timetable { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
@media (min-width: 1200px) { .timetable { grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); } }
.tt-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.tt-col.today { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.tt-col h3 { font-size: 13px; display: flex; justify-content: space-between; }
.tt-item { border-left: 4px solid var(--primary); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: 13px; }
.tt-item b { display: block; }
.kbd-hint { font-size: 12px; color: var(--muted); }
.popover { position: absolute; right: 20px; background: var(--surface); padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 5; }

/* ---------- auth pages: split like the landing hero */
.auth-wrap { min-height: 100vh; display: grid; grid-template-rows: 64px 1fr; background: var(--bg); }
.auth-top { display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.auth-body { display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 440px; padding: 28px; }
.auth-card.wide { max-width: 640px; }
.auth-card h1 { font-size: 28px; }
.auth-card h1 .a { color: var(--primary); }

/* period chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
}
.chip:hover { border-color: var(--primary-200); color: var(--primary-600); }
.chip.active { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-600); }
.filters label.flex { gap: 6px; font-size: 13px; }

/* quiet row action (e.g. "Bekor qilish" in money tables) */
.btn.quiet { background: transparent; color: var(--muted); border-color: transparent; box-shadow: none; }
.btn.quiet:hover { color: var(--red); background: var(--red-50); }
.btn.busy { opacity: .6; pointer-events: none; }
a.tel { color: inherit; border-bottom: 1px dashed var(--border-strong); }
a.tel:hover { color: var(--primary-600); border-color: var(--primary); }

/* error / empty states */
.state { text-align: center; padding: 48px 16px; max-width: 460px; margin: 0 auto; }
.state-code { font-size: 64px; font-weight: 900; line-height: 1; color: var(--primary); letter-spacing: -.03em; margin-bottom: 12px; }
.state h1 { font-size: 22px; }

.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; } .mb0 { margin-bottom: 0; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
details.box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; background: var(--surface-2); margin-bottom: 10px; }
details.box summary { cursor: pointer; font-weight: 700; color: var(--text); }
details.box[open] summary { margin-bottom: 12px; }
.chapter { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden; }
.chapter-head { background: var(--surface-2); padding: 11px 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chapter .lesson { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.att-row.absent { background: var(--red-50); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); }
.receipt { max-width: 420px; margin: 24px auto; background: #fff; color: #0f172a; padding: 24px; border: 1px dashed #94a3b8; border-radius: var(--radius-sm); }
@media print {
  .sidebar, .topbar, .no-print, .messages { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
