/* JTT satış paneli — beton boz fon, kraft kisə rəngi cari dövr üçün */

@font-face { font-family: "Archivo"; font-weight: 400; font-display: swap;
  src: url(fonts/archivo-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Archivo"; font-weight: 400; font-display: swap;
  src: url(fonts/archivo-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Archivo"; font-weight: 600; font-display: swap;
  src: url(fonts/archivo-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Archivo"; font-weight: 600; font-display: swap;
  src: url(fonts/archivo-latin-ext-600-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap;
  src: url(fonts/archivo-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap;
  src: url(fonts/archivo-latin-ext-700-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  --concrete: #E7E8E4;
  --slab: #F6F6F3;
  --ink: #1D2A2F;
  --muted: #5F6C74;
  --line: #D3D6D2;
  --kraft: #A6773A;
  --kraft-soft: #E8D6B8;
  --prev: #BCC3C1;
  --up: #2B7553;
  --down: #AE412C;
  --focus: #2F6E9E;
  --radius-lg: 14px;
  --radius-sm: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --concrete: #172024; --slab: #1F2A2F; --ink: #E5E8E4; --muted: #9AA6AC; --line: #314047;
    --kraft: #C99A5B; --kraft-soft: #4A3C29; --prev: #4D5C62; --up: #5FB98C; --down: #E07A62; --focus: #7FB4DE;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Archivo", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.45;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--ink); background: var(--concrete);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); background: var(--slab); border-radius: var(--radius-lg);
  padding: 28px 24px; display: grid; gap: 14px; border: 1px solid var(--line);
}
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.login-sub { color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.login-card input {
  font: inherit; padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--concrete); color: var(--ink);
}
.login-card button[type="submit"] {
  margin-top: 4px; padding: 12px; border: 0; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--slab); font-weight: 600;
}
.login-error { color: var(--down); min-height: 1.2em; font-size: 14px; }

/* ---------- layout ---------- */
#app { max-width: 1080px; margin: 0 auto; padding: 18px 16px 40px; }
.top { margin-bottom: 18px; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.org { color: var(--muted); font-size: 14px; }
.title { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.subtitle { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.ghost { background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 12px; color: var(--muted); }

.months {
  display: flex; gap: 6px; overflow-x: auto; margin: 16px -16px 0; padding: 2px 16px 6px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.months::-webkit-scrollbar { display: none; }
.months button {
  flex: 0 0 auto; scroll-snap-align: start; border: 1px solid var(--line); background: var(--slab);
  border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 14px; color: var(--muted);
}
.months button.year { margin-right: 10px; border-style: dashed; }
.months button[aria-pressed="true"] { background: var(--ink); color: var(--slab); border-color: var(--ink); }

.views { display: inline-flex; gap: 4px; background: var(--slab); padding: 3px; border-radius: 10px; margin-top: 14px; }
.views button { border: 0; background: none; padding: 8px 16px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.views button[aria-selected="true"] { background: var(--ink); color: var(--slab); }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2, .list-title { font-size: 18px; font-weight: 700; }
.hint, .note, .others { color: var(--muted); font-size: 13px; }

/* ---------- müqayisə: əsas element ---------- */
.compare { margin-bottom: 26px; }
.compare-grid { display: grid; gap: 10px; }
.metric {
  background: var(--slab); border-radius: var(--radius-lg); padding: 16px 16px 14px;
  display: grid; grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 4px;
}
.metric-name { font-weight: 600; color: var(--muted); grid-column: 1 / -1; }
.metric-value { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.metric-value small { font-size: 20px; font-weight: 600; margin-left: 2px; }
.delta { align-self: end; font-weight: 700; font-size: 17px; white-space: nowrap; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); }
.bars { grid-column: 1 / -1; display: grid; gap: 5px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.bar { height: 12px; border-radius: 3px; background: var(--kraft); min-width: 2px; transform-origin: left; }
.bar.prev { background: var(--prev); height: 8px; }
.bar-label { min-width: 9.5em; text-align: right; }
.metric-extra { grid-column: 1 / -1; color: var(--muted); font-size: 13px; margin-top: 6px; }

@media (prefers-reduced-motion: no-preference) {
  .compare.loaded .bar { animation: grow .55s cubic-bezier(.2,.7,.2,1) both; }
  .compare.loaded .bar.prev { animation-delay: .08s; }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

/* ---------- aylar qrafiki ---------- */
.trend { margin-bottom: 26px; }
.trend-chart { background: var(--slab); border-radius: var(--radius-lg); padding: 14px 10px 8px; overflow-x: auto; }
.trend-chart svg { display: block; }
.trend-chart .col { cursor: pointer; }
.trend-chart .col rect.b { fill: var(--prev); }
.trend-chart .col.sel rect.b { fill: var(--kraft); }
.trend-chart .col:hover rect.b, .trend-chart .col:focus rect.b { fill: var(--kraft-soft); }
.trend-chart .col.sel:hover rect.b { fill: var(--kraft); }
.trend-chart text { fill: var(--muted); font-size: 12px; font-family: inherit; }
.trend-chart .col.sel text { fill: var(--ink); font-weight: 700; }
.trend-chart .val { font-size: 11px; }
.trend-chart .col:focus { outline: none; }
.trend-chart .col:focus-visible rect.hit { stroke: var(--focus); stroke-width: 2; }

/* ---------- TOP siyahılar ---------- */
.tabs, .sorts { display: flex; gap: 4px; background: var(--slab); padding: 3px; border-radius: 10px; }
.tabs button, .sorts button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tabs button[aria-selected="true"], .sorts button[aria-pressed="true"] { background: var(--ink); color: var(--slab); }
.top-lists { display: grid; gap: 16px; }
.top-list { background: var(--slab); border-radius: var(--radius-lg); padding: 16px; }
.top-list .list-title { margin-bottom: 8px; }
.top-list ol { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.top-list li {
  counter-increment: r; display: grid; grid-template-columns: 1.6em 1fr auto; gap: 2px 10px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.top-list li:first-child { border-top: 0; }
.top-list li::before { content: counter(r); color: var(--muted); font-weight: 600; grid-row: 1 / span 3; }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-value { font-weight: 700; text-align: right; white-space: nowrap; }
.row-sub { grid-column: 2 / 4; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.row-sub .up { color: var(--up); } .row-sub .down { color: var(--down); }
.row-bar { grid-column: 2 / 4; height: 5px; background: var(--concrete); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.row-bar span { display: block; height: 100%; background: var(--kraft); }
.others { margin-top: 10px; }
.empty { color: var(--muted); padding: 12px 0; }

/* mobil: siyahılar tab ilə; geniş ekranda yan-yana */
.top-list:not(.active) { display: none; }
@media (min-width: 880px) {
  #app { padding: 28px 28px 48px; }
  .title { font-size: 44px; }
  .compare-grid { grid-template-columns: repeat(3, 1fr); }
  .tabs { display: none; }
  .top-lists { grid-template-columns: 1fr 1fr; }
  .top-list:not(.active) { display: block; }
}

/* ---------- mallar üzrə struktur ---------- */
.structure { margin-bottom: 26px; }
.structure .note { margin: -4px 0 12px; }
.stack { display: flex; height: 44px; border-radius: 10px; overflow: hidden; background: var(--slab); }
.stack span { display: block; height: 100%; min-width: 2px; border-right: 2px solid var(--concrete); }
.stack span:last-child { border-right: 0; }
.legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px 18px; grid-template-columns: 1fr; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: baseline; font-size: 14px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; align-self: center; }
.legend b { font-weight: 700; text-align: right; min-width: 3.6em; }
.legend .lv { color: var(--muted); text-align: right; white-space: nowrap; }
@media (min-width: 880px) { .legend { grid-template-columns: 1fr 1fr; } }

/* ---------- mallar cədvəli ---------- */
.prod-table-sec { margin-bottom: 10px; }
.prod-table-sec .note { margin-top: 10px; }
.table-wrap { background: var(--slab); border-radius: var(--radius-lg); padding: 6px 14px; }
.prod-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prod-table th, .prod-table td { padding: 10px 8px; text-align: right; white-space: nowrap; }
.prod-table th.t-name, .prod-table td.t-name { text-align: left; white-space: normal; }
.prod-table thead th { border-bottom: 1px solid var(--line); }
.prod-table th button { border: 0; background: none; padding: 0; font-weight: 600; color: var(--muted); font-size: 13px; }
.prod-table th button[aria-sort] { color: var(--ink); }
.prod-table th button[aria-sort="descending"]::after { content: " ▾"; }
.prod-table th button[aria-sort="ascending"]::after { content: " ▴"; }
.prod-table tbody tr + tr td { border-top: 1px solid var(--line); }
.prod-table td.t-name { font-weight: 600; overflow-wrap: anywhere; }
.prod-table td.t-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.prod-table .neg { color: var(--down); }
.prod-table .muted { color: var(--muted); }
.prod-table tfoot td { border-top: 2px solid var(--ink); font-weight: 700; }
.approx { color: var(--muted); font-weight: 400; margin-right: 2px; }

/* telefonda: hər mal bir kart */
@media (max-width: 720px) {
  .table-wrap { padding: 4px 14px; }
  .prod-table thead { display: block; }
  .prod-table thead tr { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .prod-table thead tr::before { content: "Sırala:"; color: var(--muted); font-size: 13px; }
  .prod-table thead th { display: block; padding: 0; border: 0; }
  .prod-table tbody, .prod-table tfoot { display: block; }
  .prod-table tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2px 10px; padding: 10px 0; }
  .prod-table tbody tr + tr { border-top: 1px solid var(--line); }
  .prod-table td { display: block; padding: 0; text-align: left; border: 0 !important; white-space: normal; }
  .prod-table td.t-name { grid-column: 1 / -1; font-size: 15px; margin-bottom: 4px; }
  .prod-table td[data-l]::before { content: attr(data-l); display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
  .prod-table tfoot tr { border-top: 2px solid var(--ink); }
  .prod-table tfoot td { font-weight: 700; }
}

/* ---------- debitorlar ---------- */
.debt-sum { margin-bottom: 26px; }
.debt-card { background: var(--slab); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 4px; }
.debt-card .metric-value { font-size: 30px; }
.debt-card.warn .metric-value { color: var(--down); }
.search {
  width: 100%; font: inherit; padding: 10px 12px; margin-bottom: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--slab); color: var(--ink);
}
.debt-table td.t-name button {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 600; text-align: left; color: var(--ink);
}
.debt-table td.t-name button::before { content: "▸ "; color: var(--muted); }
.debt-table td.t-name button[aria-expanded="true"]::before { content: "▾ "; }
.debt-table .old { color: var(--down); font-weight: 600; }
.debt-table tr.detail > td { padding: 4px 0 14px; white-space: normal; text-align: left; }
.docs { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--concrete); border-radius: 10px; overflow: hidden; }
.prod-table .docs th, .prod-table .docs td { padding: 7px 10px; text-align: right; white-space: nowrap; border: 0; font-weight: 400; }
.prod-table .docs th { color: var(--muted); font-weight: 600; }
.prod-table .docs td:first-child, .prod-table .docs th:first-child { text-align: left; white-space: normal; }
.prod-table .docs td:last-child, .prod-table .docs th:last-child { text-align: left; }
.prod-table .docs tbody tr + tr td { border-top: 1px solid var(--line); }
.docs .neg { color: var(--up); }
@media (max-width: 720px) {
  .debt-table tr.detail > td { grid-column: 1 / -1; }
  .prod-table .docs, .prod-table .docs tbody, .prod-table .docs td { display: block; }
  .prod-table .docs thead { display: none; }
  .prod-table .docs tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 10px; }
  .prod-table .docs td, .prod-table .docs td:last-child { padding: 0; text-align: left; border: 0 !important; }
  .prod-table .docs td:nth-child(even) { text-align: right; }
  .prod-table .docs td[data-m]::before { content: attr(data-m) ": "; color: var(--muted); }
  .prod-table .docs tbody tr + tr { border-top: 1px solid var(--line); }
}

/* borc yaşı: zolaq və legend düymələri */
#debt-legend li { display: block; }
.stack button.seg { border: 0; border-right: 2px solid var(--concrete); padding: 0; height: 100%; cursor: pointer; }
.stack button.seg:last-child { border-right: 0; }
.stack button.seg.dim { opacity: .35; }
.stack button.seg.on { box-shadow: inset 0 -5px 0 var(--ink); }
.legend button.leg {
  all: unset; box-sizing: border-box; width: 100%; cursor: pointer; border-radius: 6px; padding: 3px 4px;
  display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: baseline; font-size: 14px;
}
.legend button.leg:hover { background: var(--slab); }
.legend button.leg.on { background: var(--slab); font-weight: 600; }
.legend button.leg:disabled { cursor: default; opacity: .5; }
.legend button.leg:focus-visible { outline: 2px solid var(--focus); }
.filter-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--kraft-soft); color: var(--ink); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-weight: 600;
}
.filter-bar .ghost { background: var(--slab); color: var(--ink); }

.foot { margin-top: 28px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
