@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --ink: #1b2236;
  --muted: #7a8499;
  --line: #e4e8f1;
  --soft: #f1f4fb;
  --brand: #4a6cf7;
  --brand-2: #7a5cf5;
  --ok: #12a05c;
  --warn: #d98a00;
  --bad: #d64545;
  --side: #141a2e;
  --side-ink: #b7c0d9;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 4px 16px rgba(20, 30, 60, 0.05);
  --radius: 14px;
}

:root[data-theme="dark"] {
  --bg: #0f1320;
  --card: #181e30;
  --ink: #e8ebf5;
  --muted: #8e98b3;
  --line: #262d44;
  --soft: #1e2539;
  --brand: #7b95ff;
  --brand-2: #a08bff;
  --ok: #3ccf86;
  --warn: #f0b04a;
  --bad: #f2756b;
  --side: #0b0f1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.85 "Vazirmatn", Tahoma, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }

.side {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--side), #0e1224);
  color: var(--side-ink);
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 22px; color: #fff; font-size: 18px; font-weight: 800; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 16px; }

.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--side-ink); font-weight: 500; transition: background 0.15s, color 0.15s; }
.side nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.side nav a.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 14px rgba(74, 108, 247, 0.35); }

.who { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 13px; }
.who .name { color: #fff; font-weight: 700; margin-bottom: 4px; }
.who .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.who a, .who button { color: var(--side-ink); background: transparent; border: 0; padding: 4px 8px; border-radius: 8px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.who a:hover, .who button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }

main { flex: 1; padding: 26px 32px 48px; min-width: 0; max-width: 1400px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.page-head .hint { color: var(--muted); font-size: 12px; }

h3 { margin: 28px 0 10px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* ---------- surfaces ---------- */
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.box > h3:first-child { margin-top: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.card::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--brand)); opacity: 0.85; }
.card .label { color: var(--muted); font-size: 12.5px; }
.card .value { font-size: 26px; font-weight: 800; direction: ltr; text-align: start; line-height: 1.5; }
.card .sub { color: var(--muted); font-size: 12px; }
.card.ok { --accent: var(--ok); }
.card.warn { --accent: var(--warn); }
.card.bad { --accent: var(--bad); }

/* ---------- tables ---------- */
.wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { background: var(--soft); color: var(--muted); font-weight: 600; font-size: 12.5px; position: sticky; top: 0; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--soft); }
tr:last-child td { border-bottom: 0; }
td.num, td.ltr { direction: ltr; text-align: right; }  /* محتوای لاتین هم‌لبهٔ عنوان ستون راست‌چین بماند */
td.num { font-variant-numeric: tabular-nums; }
td.wide { white-space: normal; min-width: 180px; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px !important; }

/* ---------- forms ---------- */
form.inline { display: inline; }
form.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
input[type=checkbox] { width: 17px; height: 17px; padding: 0; accent-color: var(--brand); }
textarea { width: 100%; min-height: 120px; direction: ltr; font-family: Consolas, monospace; font-size: 13px; }

button, .btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: 0;
  border-radius: 10px;
  padding: 8px 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}
button:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 40%, transparent); }
button:active { transform: translateY(1px); }
button.ghost { background: var(--soft); color: var(--ink); border: 1px solid var(--line); box-shadow: none; padding: 6px 12px; font-weight: 500; }
button.ghost:hover { border-color: var(--brand); color: var(--brand); }
button.danger { background: color-mix(in srgb, var(--bad) 12%, var(--card)); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); box-shadow: none; padding: 6px 12px; font-weight: 600; }
button.danger:hover { background: var(--bad); color: #fff; }
button.small { padding: 4px 10px; font-size: 12.5px; }

/* ---------- status & progress ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.open, .badge.running { color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }
.badge.done, .badge.active { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.failed, .badge.disabled, .badge.banned { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge.cancelled, .badge.skipped, .badge.retried { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

.progress { height: 8px; min-width: 110px; background: var(--soft); border-radius: 999px; overflow: hidden; display: flex; direction: ltr; }
.progress i { display: block; height: 100%; }
.progress .done { background: var(--ok); }
.progress .run { background: var(--brand); opacity: 0.7; }
.pct { font-size: 11.5px; color: var(--muted); direction: ltr; text-align: start; }

/* ---------- charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; direction: ltr; }
.bars div { flex: 1; background: linear-gradient(180deg, var(--brand), var(--brand-2)); min-height: 3px; border-radius: 4px 4px 0 0; opacity: 0.9; transition: height 0.4s, opacity 0.15s; }
.bars div:hover { opacity: 1; }
.axis { display: flex; justify-content: space-between; direction: ltr; color: var(--muted); font-size: 11px; margin-top: 4px; }

/* ---------- messages ---------- */
.flash { position: fixed; top: 18px; inset-inline-start: 50%; transform: translateX(50%); z-index: 50; padding: 10px 18px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); font-weight: 600; max-width: 90vw; animation: pop 0.25s ease-out; }
.flash.ok { border-color: var(--ok); color: var(--ok); }
.flash.error { border-color: var(--bad); color: var(--bad); }
@keyframes pop { from { opacity: 0; transform: translate(50%, -10px); } }
.flash.hide { opacity: 0; transition: opacity 0.4s; }

.keybox { direction: ltr; text-align: left; font-family: Consolas, monospace; font-size: 14px; word-break: break-all; padding: 12px 14px; border: 1px dashed var(--warn); border-radius: 10px; background: var(--soft); margin-top: 8px; user-select: all; }
.notice { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--card)); }

.pager { margin: 14px 0; display: flex; gap: 14px; align-items: center; color: var(--muted); }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: embed; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }

/* ---------- login ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), var(--bg); }
.login { width: min(380px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); }
.login .brand { color: var(--ink); justify-content: center; margin-bottom: 6px; }
.login p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login button { justify-content: center; padding: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; gap: 6px; }
  .brand { margin: 0 6px; }
  .side nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; padding-bottom: 4px; }
  .side nav a { white-space: nowrap; padding: 7px 10px; }
  .who { margin: 0 0 0 auto; padding: 0; border: 0; }
  main { padding: 16px 14px 40px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card .value { font-size: 22px; }
}
