@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Medium.ttf) format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1b1f27;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --side: #161a23;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Vazirmatn, Tahoma, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.ltr { direction: ltr; unicode-bidi: plaintext; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #c9cdd6; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-weight: 700; font-size: 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #6366f1, #22d3ee); display: grid; place-items: center; font-size: 15px; }
.side a { color: inherit; padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 10px; }
.side a:hover { background: #222838; color: #fff; }
.side a.active { background: #2a3146; color: #fff; }
.side .spacer { flex: 1; }
.side .who { padding: 10px 12px; font-size: 12.5px; color: #8b92a3; border-top: 1px solid #262c3a; margin-top: 8px; }
.side .who button { background: none; border: 0; color: #c9cdd6; cursor: pointer; padding: 0; margin-inline-start: 6px; }
.main { padding: 28px 32px 60px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 20px; font-weight: 700; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.two { grid-template-columns: 2fr 1fr; }
@media (max-width: 1000px) { .two { grid-template-columns: 1fr; } }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-top: 10px; direction: ltr; }
.chart .bar { flex: 1; background: var(--accent); opacity: .85; border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.chart .bar:hover { opacity: 1; }
.chart .bar[data-zero] { background: var(--line); }
.chart-axis { direction: ltr; display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 6px; }

/* tables */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; background: #fafafb; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }
td.num { font-variant-numeric: tabular-nums; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: var(--muted); font-size: 12.5px; }

/* bits */
.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: #f3f4f6; color: #374151; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.list-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.list-row:last-child { border-bottom: 0; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: #cbd0d8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
label.field > span { font-size: 12.5px; color: var(--muted); }
label.field small { color: var(--muted); font-size: 12px; }
label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 18, 26, .45); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal { background: var(--panel); border-radius: 12px; width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.secret { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; word-break: break-all; margin: 10px 0; }

/* toast */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 18px; border-radius: 8px; z-index: 30; font-size: 13px; }
#toast.bad { background: var(--bad); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 30% 20%, #e0e7ff, var(--bg) 60%); }
.login form { width: min(360px, 100%); background: var(--panel); padding: 28px; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(30, 41, 59, .08); }
.login .brand { color: var(--ink); padding: 0 0 18px; }
.login input { width: 100%; }
.login .btn { width: 100%; padding: 9px; }
.err { color: var(--bad); font-size: 13px; min-height: 20px; margin-bottom: 8px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { padding: 4px 10px; width: 100%; }
  .side .spacer { display: none; }
  .main { padding: 18px 14px; }
  .row2 { grid-template-columns: 1fr; }
}
