/* TEZOZ admin — ichki operatsion vosita: zich, sokin jadvallar; to'q sariq faqat asosiy amal va faol holat uchun. */

@font-face { font-family: 'Jakarta'; src: url('fonts/PlusJakartaSans_400Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('fonts/PlusJakartaSans_600SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('fonts/PlusJakartaSans_700Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #f1efec;
  --line: #e4e1dc;
  --line-strong: #cfcac2;
  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #6f6a64;
  --accent: #ea580c;
  --accent-ink: #1c0a00;
  --accent-soft: #fde7d9;
  --accent-text: #b43f04;
  --focus: #2563eb;
  /* holatlar (har doim matn bilan birga) */
  --st-0: #57534e; --st-0-bg: #ecebe8;
  --st-1: #8a5a00; --st-1-bg: #fbefd2;
  --st-2: #1d5fb8; --st-2-bg: #dfeafb;
  --st-3: #17733f; --st-3-bg: #dcf1e3;
  --bad: #b42318; --bad-bg: #fde5e2;
  /* grafik (dataviz: 1–3 slotlar, barcha juftlar tekshirilgan) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --radius: 8px;
  --row-h: 44px;
  --font: 'Jakarta', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121110;
    --surface: #1b1a18;
    --surface-2: #24221f;
    --line: #2f2c29;
    --line-strong: #45413c;
    --ink: #f2efea;
    --ink-2: #c4bfb7;
    --ink-3: #a29c93;
    --accent: #f26b1d;
    --accent-ink: #1c0a00;
    --accent-soft: #3a2113;
    --accent-text: #ff9a5c;
    --focus: #6ea2ff;
    --st-0: #c4bfb7; --st-0-bg: #2c2a27;
    --st-1: #f0bf5a; --st-1-bg: #3a2e12;
    --st-2: #7fb0f5; --st-2-bg: #172a45;
    --st-3: #6fd29a; --st-3-bg: #143322;
    --bad: #ff8a80; --bad-bg: #3d1714;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: -0.01em; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.small { font-size: 12px; }

/* ---------------------------------------------------------------- brend */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: 0.04em; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); flex: none; }
.brand-sub { font-weight: 600; font-size: 12px; letter-spacing: 0.02em; color: var(--ink-3); text-transform: lowercase; }

/* ---------------------------------------------------------------- kirish */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: min(360px, 100%); display: grid; gap: 14px; }
.login-box .brand { margin-bottom: 8px; font-size: 20px; }

/* ---------------------------------------------------------------- tugmalar va maydonlar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--bad) 88%, #000); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; min-height: 44px; font-size: 14px; }

.field { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.field input, .field select, .field textarea, .search input {
  min-height: 38px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 400; font-size: 14px; width: 100%;
}
.field textarea { padding: 8px 10px; min-height: 64px; resize: vertical; }
.field input:focus, .search input:focus, .field select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.field-hint { font-weight: 400; color: var(--ink-3); }
.field-hint.warn { color: var(--bad); }
.form-error { margin: 0; color: var(--bad); font-size: 13px; }

/* ---------------------------------------------------------------- qobiq */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100%; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px;
  padding: 20px 12px 16px; border-right: 1px solid var(--line); background: var(--surface);
}
.side > .brand { padding: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border-radius: var(--radius);
  text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 13px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current='page'] { background: var(--surface-2); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .badge { margin-left: auto; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.side-stats { margin: auto 0 0; padding: 12px 10px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; font-size: 12px; }
.side-stats dt { color: var(--ink-3); }
.side-stats dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.side-foot { display: flex; align-items: center; gap: 8px; padding: 0 2px 0 10px; font-size: 12px; }
.side-foot .muted { flex: 1; min-width: 0; }

.main { min-width: 0; padding: 20px 24px 48px; }
.page-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-self: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.toolbar:empty { display: none; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); stroke: var(--ink-3); fill: none; stroke-width: 2; }

/* segmentli filtr */
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button {
  min-height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
  font-weight: 600; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 0 0 1px var(--line); }

/* ---------------------------------------------------------------- jadval */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th {
  background: var(--surface); text-align: left; font-weight: 600; font-size: 11px;
  letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid th.num { text-align: right; }
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; height: var(--row-h); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tr.row.clickable { cursor: pointer; }
.grid tr.row.clickable:hover td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.grid tr.row[aria-expanded='true'] td { background: var(--surface-2); border-bottom-color: transparent; }
.grid tr.detail > td { background: var(--surface-2); padding: 4px 12px 16px; cursor: default; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .primary { font-weight: 600; color: var(--ink); }
.grid .sub { display: block; color: var(--ink-3); font-size: 12px; }
.grid .actions { text-align: right; white-space: nowrap; }
.grid .actions .btn + .btn { margin-left: 4px; }
.cell-clip { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-3); }
.more { display: flex; justify-content: center; padding: 14px 0 0; }

/* holat belgisi */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.st-0 { color: var(--st-0); background: var(--st-0-bg); }
.pill.st-1 { color: var(--st-1); background: var(--st-1-bg); }
.pill.st-2 { color: var(--st-2); background: var(--st-2-bg); }
.pill.st-3 { color: var(--st-3); background: var(--st-3-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.accent { color: var(--accent-text); background: var(--accent-soft); }

/* buyurtma holati: 4 bosqichli yo'l (ilovadagi 4 bosqich bilan bir xil) */
.track { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; max-width: 560px; }
.track button {
  position: relative; min-height: 44px; padding: 14px 6px 6px; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-3); font-weight: 600; font-size: 12px; text-align: left; cursor: pointer;
}
.track button::before { content: ''; position: absolute; left: 6px; right: 6px; top: 4px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.track button.done { color: var(--ink-2); }
.track button.done::before { background: var(--ink-3); }
.track button.current { color: var(--ink); cursor: default; }
.track button.current::before { background: var(--accent); }
.track button:hover:not(.current) { background: var(--surface); }

/* tafsilot ichidagi tuzilma (karta emas — oddiy ustunlar) */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px 32px; padding-top: 8px; }
.detail-grid h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.detail-grid .span { grid-column: 1 / -1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.lines { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.lines li { display: flex; gap: 12px; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line-strong); }
.lines li:last-child { border-bottom: 0; }
.lines .total { font-weight: 700; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form .field { min-width: 110px; }
.inline-form .grow { flex: 1 1 180px; }
.link { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }
.copy { border: 0; background: none; padding: 0 4px; color: var(--ink-3); cursor: pointer; font-size: 12px; font-weight: 600; }
.copy:hover { color: var(--ink); }
.warn-mark { color: var(--bad); font-weight: 700; }

/* ---------------------------------------------------------------- AI sarfi */
.stat-row { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 0 0 16px; padding: 0; }
.stat-row div { display: grid; gap: 2px; }
.stat-row dt { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat-row dd { margin: 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.sw-1 { background: var(--series-1); } .sw-2 { background: var(--series-2); } .sw-3 { background: var(--series-3); }
.chart { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 14px 8px; margin-bottom: 20px; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 12px; color: var(--ink-2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart .s1 { fill: var(--series-1); } .chart .s2 { fill: var(--series-2); } .chart .s3 { fill: var(--series-3); }
.chart .gap { stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .col.dim { opacity: .45; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px; padding: 8px 10px; border-radius: 8px;
  background: var(--ink); color: var(--bg); font-size: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / .2);
}
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.tip div span:last-child { margin-left: auto; }
.section-title { margin: 24px 0 10px; font-size: 14px; font-weight: 700; }
details.table-toggle summary { cursor: pointer; font-size: 13px; color: var(--ink-2); font-weight: 600; margin-bottom: 8px; }

/* ---------------------------------------------------------------- dialog va bildirish */
.dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
.dialog::backdrop { background: rgb(20 18 16 / .45); }
.dialog form { display: grid; gap: 14px; padding: 20px; margin: 0; }
.dialog h2 { margin: 0; font-size: 16px; }
.dialog p { margin: 0; color: var(--ink-2); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg);
  font-size: 13px; font-weight: 600; box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}
.toast.bad { background: var(--bad); color: #fff; }
.loading { padding: 40px 0; text-align: center; color: var(--ink-3); }
.banner { padding: 10px 12px; border-radius: var(--radius); background: var(--bad-bg); color: var(--bad); font-size: 13px; margin-bottom: 12px; }

/* ---------------------------------------------------------------- telefon */
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    min-width: 0;
    position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 0; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side > .brand { padding: 0; }
  .side-stats { display: none; }
  .side-foot { margin-left: auto; padding: 0; }
  .side-foot .muted { display: none; }
  .nav { order: 3; width: calc(100% + 32px); margin: 0 -16px; padding: 0 12px; display: flex; overflow-x: auto; gap: 0; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: none; min-height: 44px; border-radius: 0; padding: 0 10px; }
  .nav a[aria-current='page'] { background: transparent; box-shadow: inset 0 -2px 0 var(--accent); }
  .nav svg { display: none; }
  .main { padding: 16px 16px calc(40px + env(safe-area-inset-bottom, 0px)); }
  .search { max-width: none; flex-basis: 100%; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .seg button { min-height: 34px; }

  /* jadval → qatorlar ro'yxati (har qator blok; ustun nomi data-label dan) */
  .table-wrap.stack { background: transparent; border: 0; overflow: visible; }
  .stack table.grid, .stack .grid tbody, .stack .grid tr, .stack .grid td { display: block; width: 100%; }
  .stack .grid thead { display: none; }
  .stack .grid tr.row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; width: 100%;
  }
  .stack .grid tr.row[aria-expanded='true'] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: var(--surface-2); }
  .stack .grid tr.row td { padding: 0; border: 0; height: auto; width: auto; background: transparent !important; }
  .stack .grid td[data-label]:not(.m-main):not(.m-side)::before { content: attr(data-label) ': '; color: var(--ink-3); font-size: 12px; }
  .stack .grid td.m-main { grid-column: 1; }
  .stack .grid td.m-side { grid-column: 2; grid-row: 1; text-align: right; }
  .stack .grid td.m-hide { display: none; }
  .stack .grid td:not(.m-main):not(.m-side) { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); }
  .stack .grid td.actions { text-align: left; padding-top: 8px; }
  .stack .grid tr.detail > td { height: auto; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; padding: 4px 12px 14px; }
  .stack .cell-clip { max-width: none; white-space: normal; }
  .stack .grid .num { text-align: left; }
  .stack .grid td.m-side.num { text-align: right; }
}
