@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
  --bg: #0A0D11;
  --panel: #11161C;
  --panel2: #19212A;
  --edge: #232D37;
  --edge2: #2E3A46;
  --nav: #1B4CA8;
  --nav2: #2C6BD6;
  --text: #E3E9EF;
  --dim: #7C8B99;
  --dim2: #55697A;
  --red: #C4483A;
  --teal: #2E9E86;
  --blue: #3D7FD6;
  --amber: #D99A20;
  --violet: #7A5CA8;
  --ok: #3D9970;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(27,76,168,.16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Vazirmatn, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--blue); text-decoration: none; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ── auth ── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 14px; padding: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.auth-title { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.auth-sub { font-size: 12px; color: var(--dim); line-height: 1.9; margin: 0 0 18px; }
.auth-logo { width: 52px; height: 52px; border-radius: 12px;
  background: linear-gradient(140deg, var(--nav2), var(--nav));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(27,76,168,.45); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--dim); }

input, select, textarea {
  background: var(--bg); border: 1px solid var(--edge); color: var(--text);
  border-radius: 8px; padding: 10px 11px; font-size: 14px; width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--nav2); outline-offset: 1px; }
input:disabled, select:disabled { opacity: .45; }

.btn { border: none; border-radius: 8px; padding: 10px 16px; font-size: 13px; font-weight: 700;
  font-family: inherit; cursor: pointer; background: var(--panel2); color: var(--text); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(140deg, var(--nav2), var(--nav)); color: #fff; }
.btn-ghost { background: transparent; color: var(--dim); padding: 4px 8px; }
.btn-danger { background: transparent; color: var(--red); padding: 4px 8px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.err-box { background: #2A1512; color: #E8A79B; border: 1px solid var(--red);
  border-radius: 8px; padding: 10px; font-size: 12px; line-height: 1.8; }
.ok-box { background: #10251F; color: #9FD9C8; border: 1px solid var(--teal);
  border-radius: 8px; padding: 12px; font-size: 12px; line-height: 2; }

/* ── shell ── */
.topbar { position: sticky; top: 0; z-index: 30;
  background: linear-gradient(90deg, var(--nav), var(--nav2));
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  box-shadow: 0 2px 14px rgba(0,0,0,.4); }
.topbar-title { color: #fff; font-weight: 700; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chip { background: rgba(255,255,255,.16); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 8px; }
.burger { display: none; background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }

.layout { display: flex; }
.sidebar { width: 208px; flex-shrink: 0; background: var(--panel);
  border-left: 1px solid var(--edge); padding: 14px 10px; min-height: calc(100vh - 45px); }
.nav-group { margin-bottom: 18px; }
.nav-group > h4 { font-size: 11px; color: var(--dim2); margin: 0 0 6px; padding: 0 12px; font-weight: 500; }
.nav-btn { display: block; width: 100%; text-align: right; background: none; border: none;
  color: var(--dim); font-family: inherit; font-size: 13px; padding: 9px 12px;
  border-radius: 8px; cursor: pointer; border-right: 2px solid transparent; }
.nav-btn.active { background: var(--panel2); color: #fff; font-weight: 700; border-right-color: var(--nav2); }

.main { flex: 1; padding: 18px 16px 40px; min-width: 0; }
.page-title { text-align: center; font-size: 18px; font-weight: 800; margin: 0 0 4px; }
.page-sub { text-align: center; font-size: 12px; color: var(--dim); margin: 0 0 16px; }

/* ── cards ── */
.card { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 16px; }
.card + .card { margin-top: 14px; }
.card-pill { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 99px;
  border: 1px solid var(--blue); color: var(--blue); }
.pill.red { border-color: var(--red); color: #E08878; }
.pill.teal { border-color: var(--teal); color: #7FCFBB; }
.pill.amber { border-color: var(--amber); color: #E7BC6A; }
.card-sub { font-size: 12px; color: var(--dim); line-height: 1.9; margin: 0 0 14px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.split { display: grid; grid-template-columns: 2fr 3fr; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

/* ── KPI ── */
.kpi { position: relative; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 12px; padding: 15px 15px 15px 15px; overflow: hidden; }
.kpi::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--blue); }
.kpi.red::before { background: var(--red); }
.kpi.teal::before { background: var(--teal); }
.kpi.amber::before { background: var(--amber); }
.kpi-label { font-size: 12px; color: var(--dim); margin-bottom: 10px; }
.kpi-value { font-size: 24px; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.kpi-unit { font-size: 11px; color: var(--dim); margin-right: 5px; font-weight: 400; }
.kpi-foot { font-size: 11px; color: var(--dim2); margin-top: 8px; }

.empty { text-align: center; color: var(--dim); font-size: 13px; line-height: 2.1; padding: 40px 12px; }
.empty b { color: var(--text); }

/* ── charts ── */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: Vazirmatn, sans-serif; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; justify-content: center; }
.legend span { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── line schematic ── */
.schematic { overflow-x: auto; padding-bottom: 6px; }
.sch-row { display: flex; align-items: flex-end; gap: 5px; }
.sch-block { flex: 1; min-width: 86px; height: 104px;
  background: linear-gradient(180deg, var(--panel2), #141B22);
  border: 1px solid var(--edge); border-radius: 8px; padding: 4px;
  display: flex; flex-direction: column; justify-content: flex-end; cursor: pointer; }
.sch-block:hover { border-color: var(--edge2); }
.sch-fill { border-radius: 5px; width: 100%;
  background: linear-gradient(180deg, #D9614F, var(--red)); }
.sch-val { font-size: 10px; color: var(--dim); text-align: center; padding-bottom: 3px; }
.sch-labels { display: flex; gap: 5px; margin-top: 7px; }
.sch-label { flex: 1; min-width: 86px; text-align: center; font-size: 10px;
  color: var(--dim); line-height: 1.5; }

/* ── tables ── */
.table-wrap { overflow-x: auto; max-height: 620px; overflow-y: auto; border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 10px; font-size: 12px; text-align: center; border-bottom: 1px solid var(--edge); white-space: nowrap; }
th { background: var(--panel2); color: var(--dim); font-weight: 700; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: rgba(255,255,255,.03); }
.num { font-weight: 700; }
.num.red { color: #E08878; }
.num.blue { color: #7FB0EC; }

/* ── list rows ── */
.rec { background: var(--panel2); border-radius: 9px; padding: 12px;
  display: flex; justify-content: space-between; gap: 12px; border-right: 3px solid var(--red); }
.rec.planned { border-right-color: var(--blue); }
.rec + .rec { margin-top: 8px; }
.rec-title { font-size: 13px; font-weight: 700; }
.rec-meta { font-size: 11px; color: var(--dim); margin-top: 4px; line-height: 1.8; }
.rec-note { font-size: 11px; margin-top: 4px; color: var(--dim); }
.rec-right { text-align: left; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.scroll { max-height: 470px; overflow-y: auto; }

/* ── config rows ── */
.cfg-row { background: var(--panel2); border-radius: 9px; padding: 12px; }
.cfg-row + .cfg-row { margin-top: 10px; }
.cfg-head { display: flex; align-items: center; gap: 8px; }
.cfg-idx { font-size: 11px; color: var(--dim); width: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-right: 26px; }
.chip-edit { display: flex; align-items: center; gap: 4px; background: var(--bg);
  border: 1px solid var(--edge); border-radius: 7px; padding: 3px 8px; }
.chip-edit input { background: transparent; border: none; width: 110px; font-size: 12px; padding: 3px; }
.chip-x { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 13px; }

/* ── badges ── */
.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.badge.over { background: #2A1512; color: #E8908090; color: #E89080; }
.badge.soon { background: #2A2412; color: #E8C77A; }
.badge.ok { background: #10251F; color: #8FD3BE; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 140px; }

.toast { position: fixed; bottom: 18px; left: 18px; z-index: 60;
  background: var(--panel2); border: 1px solid var(--edge2); border-radius: 10px;
  padding: 11px 16px; font-size: 13px; box-shadow: 0 8px 26px rgba(0,0,0,.6); }
.toast.err { border-color: var(--red); color: #E8A79B; }

@media (max-width: 980px) {
  .split, .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .burger { display: block; }
  .sidebar { display: none; position: fixed; z-index: 40; top: 45px; right: 0; bottom: 0;
    box-shadow: -8px 0 30px rgba(0,0,0,.6); overflow-y: auto; }
  .sidebar.open { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 14px 12px 40px; }
  .kpi-value { font-size: 21px; }
}
@media (max-width: 620px) {
  .g4.kpis { grid-template-columns: 1fr 1fr; }
}
