:root {
  --ink: #12161d; --ink-2: #1c222c; --line: #e3e6eb; --bg: #f3f4f7; --card: #fff;
  --text: #1a1f29; --muted: #6b7482; --accent: #f2541b; --accent-ink: #fff;
  --ok: #12805c; --ok-bg: #e2f5ec; --warn: #a15c00; --warn-bg: #fdf0d8; --bad: #b3261e; --bad-bg: #fbe6e4;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: clip; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Naskh Arabic", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 16px; margin: 0 0 12px; }
a { color: inherit; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.side { background: var(--ink); color: #c9d0db; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 2px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: #8e98a8; margin-top: 2px; }
.nav { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { text-decoration: none; padding: 9px 12px; border-radius: 8px; border-inline-start: 3px solid transparent; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.on { background: var(--ink-2); color: #fff; border-inline-start-color: var(--accent); }
.who { font-size: 13px; padding: 10px; border-top: 1px solid #2a323f; }
.who button { margin-top: 8px; width: 100%; }
.main { padding: 22px 26px 60px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar { display: none; }

/* pieces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; line-height: 1.3; }
.stat > span { color: var(--muted); font-size: 13px; }
.stat.hot { border-color: var(--accent); }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b9c0cb; }
a.btn { text-decoration: none; display: inline-block; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(.94); }
.btn.danger { color: var(--bad); }
.btn.dark { background: var(--ink-2); border-color: #333c4a; color: #dfe4ec; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: start; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafbfc; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }
.tag { display: inline-block; font-size: 12.5px; padding: 2px 9px; border-radius: 99px; background: #eceff3; color: #4a5361; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); } .tag.warn { background: var(--warn-bg); color: var(--warn); } .tag.bad { background: var(--bad-bg); color: var(--bad); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { max-width: 240px; }
input, select, textarea { width: 100%; border: 1px solid #cfd5dd; border-radius: 8px; padding: 8px 10px; background: #fff; }
label { display: block; font-size: 13px; color: #414a58; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.err { background: var(--bad-bg); color: var(--bad); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.note { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 18px; }
.kv > div > span:first-child { display: block; color: var(--muted); font-size: 12.5px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #eef0f3; }
.check input[type=checkbox] { width: 18px; height: 18px; flex: none; }
.check input[type=number] { width: 72px; margin-inline-start: auto; }
code.token { display: block; direction: ltr; text-align: left; background: #f1f3f6; padding: 10px; border-radius: 8px; word-break: break-all; font-size: 13px; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 19, 26, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: #fff; border-radius: 12px; width: min(480px, 100%); max-height: 92vh; overflow: auto; padding: 18px; }
.modal h2 { font-size: 17px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 6px; }
#toast { position: fixed; bottom: 18px; inset-inline: 0; margin: auto; width: fit-content; max-width: 90%; background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
#toast.show { opacity: 1; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login .box { background: #fff; border-radius: 14px; padding: 26px; width: min(380px, 100%); }
.login h1 { margin-bottom: 4px; } .login p { color: var(--muted); margin: 0 0 18px; }
.login .btn { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 8px 0 0; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 10; }
  .side { display: none; position: fixed; inset-block: 0; inset-inline-start: 0; width: 250px; height: auto; z-index: 15; box-shadow: 0 0 0 100vmax rgba(15, 19, 26, .5); }
  .side.open { display: flex; }
  .main { padding: 16px 14px 60px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
