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

:root {
  --bg: #f6f6f4; --card: #ffffff; --ink: #111111; --muted: #6b6b6b; --line: #e6e6e2;
  --accent: #111111; --accent-ink: #ffffff; --soft: #efefec;
  --warn: #b26a00; --warn-bg: #fff4dd; --ok: #1f7a4d; --ok-bg: #e6f4ec; --info-bg: #eef1f6;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
:root[data-palette="purple"] { --accent: #5b3fd1; --soft: #efecfb; --info-bg: #efecfb; }
:root[data-palette="navy"] { --accent: #1d3a6e; --soft: #e9eef7; --info-bg: #e9eef7; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f10; --card: #19191b; --ink: #f2f2f0; --muted: #9a9a9a; --line: #2a2a2d;
    --accent: #f2f2f0; --accent-ink: #111111; --soft: #232326;
    --warn: #f0b04a; --warn-bg: #2d2416; --ok: #5bc48b; --ok-bg: #16291f; --info-bg: #1e2129;
    --shadow: none;
  }
  :root:not([data-theme="light"])[data-palette="purple"] { --accent: #a796ff; --soft: #24203a; --info-bg: #24203a; }
  :root:not([data-theme="light"])[data-palette="navy"] { --accent: #8fb0ea; --soft: #1b2336; --info-bg: #1b2336; }
}
:root[data-theme="dark"] {
  --bg: #0f0f10; --card: #19191b; --ink: #f2f2f0; --muted: #9a9a9a; --line: #2a2a2d;
  --accent: #f2f2f0; --accent-ink: #111111; --soft: #232326;
  --warn: #f0b04a; --warn-bg: #2d2416; --ok: #5bc48b; --ok-bg: #16291f; --info-bg: #1e2129;
  --shadow: none;
}
:root[data-theme="dark"][data-palette="purple"] { --accent: #a796ff; --soft: #24203a; --info-bg: #24203a; }
:root[data-theme="dark"][data-palette="navy"] { --accent: #8fb0ea; --soft: #1b2336; --info-bg: #1b2336; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: Vazirmatn, Tahoma, sans-serif; font-size: 15px; line-height: 1.7; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: isolate; font-size: .92em; }

header.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; font-size: 22px; letter-spacing: .5px; display: flex; align-items: baseline; gap: 8px; }
.brand .w { direction: ltr; }
.brand small { font-weight: 500; font-size: 14px; color: var(--muted); }
header.top .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 720px; margin: 0 auto; padding: 4px 16px 110px; }
.section-title { font-weight: 700; margin: 22px 2px 10px; display: flex; align-items: center; gap: 8px; }
.section-title .count { font-weight: 500; color: var(--muted); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--soft); color: var(--ink); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; cursor: pointer; text-align: start; }
.stat .n { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: 12.5px; color: var(--muted); }
.stat.hot { background: var(--warn-bg); border-color: transparent; }
.stat.hot .n, .stat.hot .l { color: var(--warn); }

.mail { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.mail .em { width: 38px; height: 38px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; font-size: 18px; flex: none; }
.mail .t { font-weight: 600; }
.mail .s { color: var(--ink); opacity: .85; font-size: 14px; }
.mail .meta { font-size: 12.5px; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.badge { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }

.code-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 10px; background: var(--info-bg);
  font-family: ui-monospace, Menlo, monospace; font-weight: 700; font-size: 17px; letter-spacing: 1px; direction: ltr; cursor: pointer; border: 0; }

.btn { text-decoration: none; display: inline-block; border: 0; border-radius: 12px; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.line { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.sm { padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn.done { background: var(--ok-bg); color: var(--ok); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

input[type=text], input[type=password], input[type=search], input[type=number], input[type=time], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 10px 2px 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 2px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

nav.tabs { position: fixed; bottom: 0; inset-inline: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
nav.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11.5px;
  color: var(--muted); padding: 4px 8px; cursor: pointer; position: relative; min-width: 56px; }
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button.on { color: var(--ink); font-weight: 600; }
nav.tabs .nb { position: absolute; top: 0; inset-inline-end: 8px; background: var(--warn); color: #fff; font-size: 10px; border-radius: 999px; padding: 0 5px; line-height: 16px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet .grip { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 2px auto 10px; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv .k { color: var(--muted); }
.body-text { white-space: pre-wrap; font-size: 13px; line-height: 1.6; max-height: 320px; overflow: auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; direction: auto; text-align: start; unicode-bidi: plaintext; }
.action-box { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-weight: 500; }
.action-box.done { background: var(--ok-bg); color: var(--ok); }
.timeline { position: relative; padding-inline-start: 18px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl { position: relative; padding: 6px 0; cursor: pointer; }
.tl::before { content: ""; position: absolute; inset-inline-start: -16px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); }

.report { white-space: pre-wrap; font-size: 14px; line-height: 1.75; }
.report b { font-weight: 700; }
.report code { background: var(--soft); padding: 0 4px; border-radius: 4px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 14px; padding: 10px 14px; margin: 8px 0; font-size: 14px; }

.toast { position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px;
  border-radius: 12px; z-index: 40; font-size: 14px; max-width: 90vw; animation: fade .15s; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 24px; }
.login .brand { font-size: 34px; text-align: center; margin-bottom: 4px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--soft); border-radius: 999px; padding: 4px 6px 4px 12px; direction: ltr; font-family: ui-monospace, monospace; }
.tag button { border: 0; background: var(--card); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
