/* لوحة وقفة: same tokens as the app and the public site. Dark is the reference; light follows the system. */

@font-face { font-family: "Readex Pro"; src: url("fonts/readex-pro.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("fonts/plex-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("fonts/plex-arabic-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("fonts/plex-arabic-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark light;
  --bg: #0E1714;
  --surface: #16231F;
  --raised: #1D2C27;
  --line: #2A3B36;
  --text: #EEEBE3;
  --muted: #9FAEA8;
  --amber: #E9B44C;
  --accent: #E9B44C;
  --on-amber: #0E1714;
  --teal: #6CC3AE;
  --danger: #E5736A;
  --danger-soft: rgba(229, 115, 106, 0.12);
  --track: #1F2D28;
  --heading: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --radius: 18px;
  --gutter: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F7F4EC;
    --surface: #FFFFFF;
    --raised: #FBF3DF;
    --line: #E3DECF;
    --text: #14201C;
    --muted: #55655F;
    --accent: #8A5F0C;
    --teal: #2E8C77;
    --danger: #B93A30;
    --danger-soft: rgba(185, 58, 48, 0.08);
    --track: #E3DECF;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: 4px; }
h1, h2 { font-family: var(--heading); margin: 0; line-height: 1.35; font-weight: 700; text-wrap: balance; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
p { margin: 0; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; word-break: break-all; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
#content:focus { outline: none; }

.muted { color: var(--muted); }
.noscript { padding: 40px var(--gutter); text-align: center; }

/* ------------------------------------------------------------------ buttons, chips, inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: 500 15px/1 var(--body); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn.off { opacity: 0.4; cursor: default; pointer-events: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.danger-btn { border-color: var(--danger); color: var(--danger); background: transparent; }
.danger-btn:hover:not([disabled]) { background: var(--danger); color: #fff; border-color: var(--danger); }

.chip { display: inline-flex; align-items: center; padding: 1px 11px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--raised); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.teal { color: var(--teal); background: color-mix(in srgb, var(--teal) 14%, transparent); border-color: color-mix(in srgb, var(--teal) 35%, transparent); }
.chip.amber { color: var(--accent); background: color-mix(in srgb, var(--amber) 14%, transparent); border-color: color-mix(in srgb, var(--amber) 38%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.search {
  width: 100%; max-width: 360px; min-height: 44px; padding: 0 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--text); font: 400 16px var(--body);
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: none; border-color: var(--teal); }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 32px var(--gutter); }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 40px 30px 34px; text-align: center; display: grid; justify-items: center; gap: 14px; }
.login-logo { border-radius: 18px; }
.login-card h1 { font-size: 30px; color: var(--accent); }
.google-slot { min-height: 44px; margin-top: 14px; display: grid; place-items: center; }
.notice { width: 100%; background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); color: var(--text); padding: 12px 16px; border-radius: 14px; font-size: 15px; }

/* ------------------------------------------------------------------ shell */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(1180px, 100% - 2 * var(--gutter)); margin-inline: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; min-height: 64px; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { border-radius: 9px; }
.brand span { font: 700 22px/1 var(--heading); color: var(--accent); }
.brand small { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 6px; margin-inline-end: auto; }
.tab { padding: 7px 16px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--surface); color: var(--text); border: 1px solid var(--line); padding: 6px 15px; }
.who { display: flex; align-items: center; gap: 12px; }
.who-email { color: var(--muted); font-size: 14px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { width: min(1180px, 100% - 2 * var(--gutter)); margin-inline: auto; padding: 28px 0 80px; }
.page { display: grid; gap: 18px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 4px; }
.back { font-size: 15px; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--text); }

.state { display: grid; justify-items: center; gap: 14px; padding: 70px 20px; color: var(--muted); text-align: center; }
.state.error { color: var(--text); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--amber); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ cards, KPIs, charts */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-width: 0; }
.card > h2 { margin-bottom: 16px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 820px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpis.small { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 2px; align-content: start; }
.kpi-label { color: var(--muted); font-size: 14px; }
.kpi-value { font: 700 30px/1.3 var(--heading); }
.kpi-hint { color: var(--muted); font-size: 13.5px; }

.chart-wrap { display: grid; gap: 6px; }
.chart { width: 100%; height: 170px; border-bottom: 1px solid var(--line); }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.bar.teal { fill: var(--teal); }
.bar.amber { fill: var(--amber); }
.bar { fill: var(--muted); opacity: 0.95; }
.bar:hover { opacity: 0.75; }
.legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-top: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.teal { background: var(--teal); }
.dot.amber { background: var(--amber); margin-inline-start: 12px; }

.app-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.app-bars-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.app-name { font-weight: 500; }
.meter { height: 8px; border-radius: 99px; background: var(--track); margin: 6px 0 2px; overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--w, 0); background: var(--teal); border-radius: 99px; margin-inline-start: 0; }
.sub-line { display: block; color: var(--muted); font-size: 13.5px; }
.pkg { display: block; color: var(--muted); font-size: 12.5px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ------------------------------------------------------------------ tables and lists */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card .table-wrap { border: 0; border-radius: 0; background: transparent; margin: 0 -8px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 13px 16px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; font-size: 13.5px; background: color-mix(in srgb, var(--raised) 60%, transparent); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--raised) 55%, transparent); }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .time, .pkg-cell { font-size: 14px; }
.user-link { display: grid; text-decoration: none; color: var(--text); }
.user-link strong { font-weight: 500; }
.user-link:hover strong { color: var(--accent); }
.sub { color: var(--muted); font-size: 13.5px; text-align: end; }
html[dir="rtl"] .sub { text-align: right; }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.pager-buttons { display: flex; align-items: center; gap: 14px; }

.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.plain li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.plain li > div { min-width: 0; display: grid; }

.facts { display: grid; gap: 4px; margin: 0; }
.fact { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: 0; }
.fact dt { color: var(--muted); font-size: 14.5px; flex: none; }
.fact dd { margin: 0; font-weight: 500; text-align: end; min-width: 0; }

/* ------------------------------------------------------------------ danger zone and dialog */
.card.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.card.danger > h2 { color: var(--danger); margin-bottom: 8px; }
.card.danger .btn { margin-top: 16px; }

.dialog { width: min(460px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); padding: 26px; font-family: var(--body); }
.dialog::backdrop { background: rgba(4, 8, 7, 0.7); backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 12px; }
.dialog h2 { color: var(--danger); }
.target { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-weight: 500; text-align: start; overflow-wrap: anywhere; }
.field { display: grid; gap: 8px; font-size: 14.5px; color: var(--muted); }
.field .search { max-width: none; }
.dialog-error { color: var(--danger); min-height: 1.4em; font-size: 14.5px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 4px; }

.toast { position: fixed; inset-inline: 0; bottom: 24px; margin-inline: auto; width: fit-content; max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 999px; font-weight: 500; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 20; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .who-email { display: none; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .topbar-inner { gap: 8px 16px; }
  .brand small { display: none; }
  .who { margin-inline-start: auto; }
  .card { padding: 18px; }
  .kpi-value { font-size: 22px; }
  .kpi { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .toast { transition: none; }
}
