/* ==========================================================================
   PLUS Avto Kurs — boshqaruv paneli
   Rang ma'lumot tashiydi: yashil to'langan, sariq kutmoqda, qizil kechikkan.
   ========================================================================== */

:root {
  --bg:        #eef1f5;
  --surface:   #ffffff;
  --surface-2: #f6f8fa;
  --ink:       #10202e;
  --ink-2:     #45586b;
  --muted:     #6f8296;
  --line:      #d9e1ea;
  --line-2:    #c3cfdb;

  --brand:     #0f4c81;
  --brand-ink: #ffffff;
  --brand-sub: #e4edf6;

  --ok:        #14713f;
  --ok-bg:     #e2f3e9;
  --warn:      #9a5f06;
  --warn-bg:   #fdf0d9;
  --bad:       #b3302a;
  --bad-bg:    #fce8e6;

  --shadow:    0 1px 2px rgba(16, 32, 46, .06), 0 8px 24px -12px rgba(16, 32, 46, .18);
  --shadow-lg: 0 24px 60px -20px rgba(16, 32, 46, .35);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --cond: "IBM Plex Sans Condensed", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;

  --sidebar: 244px;
  --speed: .18s;
}

[data-theme="dark"] {
  --bg:        #0d1520;
  --surface:   #151f2c;
  --surface-2: #1b2735;
  --ink:       #e7eef5;
  --ink-2:     #b3c2d1;
  --muted:     #7f93a8;
  --line:      #24313f;
  --line-2:    #334456;

  --brand:     #57a5e6;
  --brand-ink: #08121c;
  --brand-sub: #1a2c3f;

  --ok:        #4cc283;
  --ok-bg:     #13301f;
  --warn:      #e3ab4d;
  --warn-bg:   #35270d;
  --bad:       #f0786a;
  --bad-bg:    #3a1613;

  --shadow:    0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px -14px rgba(0, 0, 0, .8);
  --shadow-lg: 0 30px 70px -22px rgba(0, 0, 0, .85);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Tema almashganda butun sahifa emas, faqat ranglar yumshoq o'tsin */
body, .card, .sidebar, .topbar, .tbl, input, select, textarea {
  transition: background-color var(--speed) ease, border-color var(--speed) ease,
              color var(--speed) ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --------------------------------------------------------------- Layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.brand img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.brand b { font-family: var(--cond); font-size: 19px; letter-spacing: .01em; display: block; line-height: 1.1; }
.brand span { font-size: 11.5px; color: var(--muted); }

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group { margin-top: 16px; }
.nav-group:first-child { margin-top: 0; }
.nav-group > p {
  margin: 0 0 6px 10px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 1px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--brand); color: var(--brand-ink); }
.nav a.on .ic { opacity: 1; }
.nav .ic { width: 18px; text-align: center; opacity: .75; flex: 0 0 18px; }
.nav .tag {
  margin-left: auto;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
}
.nav a.on .tag { background: rgba(0,0,0,.25); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-family: var(--cond); font-size: 20px; margin: 0; font-weight: 600; }
.topbar .sp { flex: 1; }

.content { padding: 22px; max-width: 1400px; width: 100%; }

.burger { display: none; }

@media (max-width: 960px) {
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform var(--speed) ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(8,16,24,.5); z-index: 50;
  }
  .burger { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
}

/* --------------------------------------------------------------- Bo'laklar */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.card-h {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-h h2 { margin: 0; font-size: 15.5px; font-weight: 600; font-family: var(--cond); letter-spacing: .01em; }
.card-h .sp { flex: 1; }
.card-b { padding: 18px; }

.sec-title {
  margin: 26px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.sec-title:first-child { margin-top: 0; }

/* Bosh panel: bugungi tushum + oxirgi 7 kun */
.hero {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--r);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.hero .lbl { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.hero .num {
  font-family: var(--cond);
  font-size: clamp(38px, 6vw, 58px);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.hero .num small { font-size: .38em; font-weight: 500; color: var(--muted); margin-left: 8px; }
.hero .meta { font-size: 13px; color: var(--ink-2); margin-top: 8px; }

.spark { display: flex; align-items: flex-end; gap: 5px; height: 62px; }
.spark i {
  width: 22px;
  background: var(--brand-sub);
  border-radius: 3px 3px 0 0;
  display: block;
  min-height: 3px;
  position: relative;
}
.spark i.now { background: var(--brand); }
.spark-wrap { display: flex; flex-direction: column; gap: 6px; }
.spark-days { display: flex; gap: 5px; }
.spark-days span { width: 22px; text-align: center; font-size: 10.5px; color: var(--muted); }

/* Ko'rsatkich kartalari */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.stat {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px 16px;
  color: inherit;
  box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--line-2); text-decoration: none; }
a.stat:hover .v { color: var(--brand); }
.stat .v {
  font-family: var(--cond);
  font-size: 27px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat .k { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat.is-bad { border-left: 3px solid var(--bad); }
.stat.is-bad .v { color: var(--bad); }
.stat.is-ok  { border-left: 3px solid var(--ok); }
.stat.is-ok .v { color: var(--ok); }
.stat.is-warn { border-left: 3px solid var(--warn); }
.stat.is-warn .v { color: var(--warn); }

/* --------------------------------------------------------------- Jadval */

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .money { font-family: var(--cond); font-size: 15px; font-weight: 600; }
.tbl tr.row-bad { box-shadow: inset 3px 0 0 var(--bad); }
.tbl tr.row-off td { opacity: .5; }
.tbl tr.row-off .money { text-decoration: line-through; }
.tbl .nowrap { white-space: nowrap; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; font-family: var(--cond); }

/* --------------------------------------------------------------- Belgilar */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500;
  padding: 3px 9px 3px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.badge.ok   { color: var(--ok);   background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad  { color: var(--bad);  background: var(--bad-bg); }
.badge.mute { color: var(--muted); background: var(--surface-2); }
.badge.info { color: var(--brand); background: var(--brand-sub); }

/* --------------------------------------------------------------- Tugmalar */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 500; font-size: 14px;
  padding: 8px 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-pri:hover { background: var(--brand); filter: brightness(1.1); }
.btn-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-bad:hover { background: var(--bad); filter: brightness(1.08); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: var(--ok); filter: brightness(1.08); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 7px 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------- Shakllar */

.field { margin-bottom: 15px; }
.field > label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 5px; color: var(--ink-2);
}
.field .req { color: var(--bad); }

input[type=text], input[type=number], input[type=date], input[type=password],
input[type=search], input[type=tel], input[type=email], select, textarea {
  width: 100%;
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  outline: 2px solid color-mix(in srgb, var(--brand) 25%, transparent);
  outline-offset: 0;
}
input[type=file] { font-size: 13px; }
textarea { min-height: 76px; resize: vertical; }
select { cursor: pointer; }

.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.err { font-size: 12.5px; color: var(--bad); margin-top: 4px; font-weight: 500; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--bad); }

.form-grid { display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.filters .field { margin: 0; }
.filters select, .filters input { min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

/* --------------------------------------------------------------- Xabarlar */

.toasts { position: fixed; right: 18px; top: 18px; z-index: 200; display: grid; gap: 8px; max-width: 380px; }
.toast {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-sm); padding: 12px 15px; box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: slide-in .22s ease both;
}
.toast.success { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--bad); }
.toast.warning { border-left-color: var(--warn); }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } }

/* --------------------------------------------------------------- Kirish */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px; box-shadow: var(--shadow-lg);
}
.login-card img { width: 54px; height: 54px; border-radius: 12px; }
.login-card h1 { font-family: var(--cond); font-size: 24px; margin: 14px 0 3px; }
.login-card p.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }

/* --------------------------------------------------------------- Tafsilot */

.detail-head { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.avatar {
  width: 62px; height: 62px; border-radius: 12px; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--cond); font-size: 22px; font-weight: 600; color: var(--muted);
}
.detail-head h2 { margin: 0; font-family: var(--cond); font-size: 24px; }
.detail-head .sub { color: var(--muted); font-size: 13.5px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.kv dd.big { font-family: var(--cond); font-size: 17px; font-weight: 600; }
.kv .line { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 3px 0; }

.two-col { display: grid; gap: 14px; grid-template-columns: 340px 1fr; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- Boshqa */

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 14px; }
.pager a, .pager span {
  padding: 6px 11px; border-radius: var(--r-sm); font-size: 13.5px;
  border: 1px solid var(--line); color: var(--ink-2);
}
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager .on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.pager .off { opacity: .4; }

.theme-btn, .burger {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  width: 36px; height: 36px; border-radius: var(--r-sm); cursor: pointer;
  display: inline-grid; place-items: center; font-size: 16px; padding: 0;
}
.theme-btn:hover, .burger:hover { background: var(--surface-2); }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="light"] .theme-btn .moon, :root:not([data-theme="dark"]) .theme-btn .moon { display: none; }

.who { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.who .nm { font-weight: 600; line-height: 1.15; }
.who .rl { color: var(--muted); font-size: 12px; }
@media (max-width: 620px) { .who .txt { display: none; } }

.branch-pick select { min-width: 170px; padding: 7px 10px; font-size: 13.5px; }

.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 100px; gap: 12px; align-items: center; font-size: 13.5px; }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-family: var(--cond); font-size: 15px; }

.chart-box { height: 280px; position: relative; }

.note {
  font-size: 13px; color: var(--ink-2); background: var(--surface-2);
  border-left: 3px solid var(--line-2); padding: 10px 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.note.warn { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.note.bad { border-left-color: var(--bad); background: var(--bad-bg); color: var(--bad); }

@media print {
  .sidebar, .topbar, .btn-row, .filters, .pager { display: none !important; }
  .content { padding: 0; }
  .card { border: 0; box-shadow: none; }
}
