:root {
  --bg: #04070d;
  --app: #060b14;
  --panel: #0c141f;
  --panel-2: #101a28;
  --panel-3: #162334;
  --line: #1b2a3d;
  --line-soft: #12202f;
  --text: #eaf2f8;
  --muted: #93a4b8;
  --label: #64788f;
  --dim: #45566b;
  --red: #1fc7e2;
  --red-hi: #66e9ff;
  --red-deep: #062330;
  --red-line: #145060;
  --danger: #ff4d4d;
  --danger-soft: #ff9a9a;

  --f-display: "Bungee", "Cairo", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", "Cairo", ui-monospace, monospace;
  --f-body: "Rubik", "Cairo", system-ui, sans-serif;

  --cut: 10px;
  --app-w: 460px;
  --gutter: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--red-hi); outline-offset: 2px; }
[hidden], .hidden { display: none !important; }

.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
:lang(ar) * { letter-spacing: 0 !important; }

.mono-label {
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--label);
}
.mono { font-family: var(--f-mono); }

.cut, .frame {
  --shape: polygon(0 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);
}
.cut2 {
  --shape: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.cut, .cut2, .frame { clip-path: var(--shape); }
.frame {
  position: relative;
  isolation: isolate;
  background: var(--frame-line, var(--line-soft));
}
.frame::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  background: var(--frame-bg, var(--panel));
  clip-path: var(--shape);
}

/* ───────── app shell ───────── */
.app {
  position: relative;
  max-width: var(--app-w);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background:
    radial-gradient(120% 46% at 50% 0%, rgba(31, 199, 226, .07), transparent 62%),
    var(--app);
}
@media (min-width: 520px) {
  .app { box-shadow: 0 0 0 1px #121216, 0 0 80px rgba(0, 0, 0, .8); }
}
.view-enter { animation: enter .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

/* ───────── language ───────── */
.lang { position: relative; }
.lang-btn {
  --cut: 6px;
  --frame-bg: var(--panel-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--text);
}
.lang-btn .ic { width: 15px; height: 15px; color: var(--muted); }
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 40;
  min-width: 208px;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .6);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity .16s, transform .16s;
}
.lang.open .lang-menu { opacity: 1; transform: none; pointer-events: auto; }
.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--muted);
  text-align: start;
}
.lang-item:hover { background: var(--panel-3); color: var(--text); }
.lang-item.sel { background: var(--panel-3); color: var(--text); font-weight: 500; }
.lang-item .ic { width: 16px; height: 16px; stroke-width: 2.2; opacity: 0; color: var(--red-hi); }
.lang-item.sel .ic { opacity: 1; }

/* ───────── login ───────── */
.login {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 14px var(--gutter) calc(18px + var(--safe-b));
}
.login-top { display: flex; justify-content: flex-end; }
.login-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 40px 0;
  background: radial-gradient(closest-side, rgba(31, 199, 226, .14), transparent 72%);
}
.logo {
  display: block;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .7));
  user-select: none;
  -webkit-user-drag: none;
}
.logo-lg {
  width: min(64vw, 186px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #17334a, 0 24px 50px rgba(0, 0, 0, .75), 0 0 60px rgba(31, 199, 226, .22);
  animation: floaty 7s ease-in-out infinite;
}
@keyframes floaty { 50% { transform: translateY(-9px); } }
.tagline {
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #5d7189;
  text-align: center;
}
[dir="rtl"] .tagline { font-size: 13px; }

.login-form { display: flex; flex-direction: column; }
.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--label);
}
.sq { width: 7px; height: 7px; background: var(--red); display: inline-block; }

.key-field {
  --cut: 12px;
  --frame-line: #2c2c33;
  --frame-bg: #0e0e11;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 60px;
  padding: 0 8px 0 18px;
  transition: background .2s;
}
[dir="rtl"] .key-field { padding: 0 18px 0 8px; }
.key-field:focus-within { --frame-line: #4a4a54; }
.key-field.invalid { --frame-line: var(--danger); }
.key-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: 0;
  outline: none;
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .1em;
  color: var(--text);
}
.key-field input::placeholder { color: #3d3f48; }
.shake { animation: shake .38s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.form-error { min-height: 22px; padding-top: 6px; font-size: 13px; color: #ff6b6f; }
.form-error:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-end: 8px;
  vertical-align: 1px;
  background: currentColor;
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  background: var(--panel-3);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  transition: background .15s;
  flex: none;
}
.btn-chip:hover { background: #26262c; }

.btn-primary {
  --cut: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 60px;
  background: var(--red);
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #04141c;
  transition: filter .15s, transform .1s;
}
:lang(ar) .btn-primary { font-weight: 900; font-size: 20px; font-family: var(--f-body); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.99); }
.btn-primary.idle, .btn-primary:disabled:not(.loading) { background: var(--panel-3); color: #545761; filter: none; transform: none; }
.btn-primary.loading { cursor: progress; }
.btn-primary.loading:active { transform: none; }
.btn-primary .spin { display: none; }
.btn-primary.loading .spin { display: block; }
.btn-primary .btn-label { display: inline-block; }

.spin { width: 20px; height: 20px; flex: none; overflow: visible; animation: spin 2.2s linear infinite; }
.spin circle { fill: none; stroke-width: 2.6; }
.spin-track { stroke: rgba(4, 20, 28, .22); }
.spin-arc {
  stroke: #04141c;
  stroke-linecap: round;
  stroke-dasharray: 1 60;
  animation: spin-dash 1.6s cubic-bezier(.45, 0, .55, 1) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-dash {
  0% { stroke-dasharray: 1 60; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 34 60; stroke-dashoffset: -12; }
  100% { stroke-dasharray: 34 60; stroke-dashoffset: -59; }
}

.login-note { margin-top: 14px; text-align: center; font-size: 14px; color: #d3d4d8; }
.login-note.dim { margin-top: 6px; font-size: 13px; color: #5d7189; }

/* ───────── dashboard shell ───────── */
.dash {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--gutter) 12px;
  background: linear-gradient(var(--app) 75%, transparent);
}
.topbar-end { display: flex; align-items: center; gap: 8px; flex: none; }
.title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(18px, 5.4vw, 23px);
  letter-spacing: .01em;
  text-transform: uppercase;
  line-height: 1;
}
.title b { color: var(--red-hi); font-weight: 400; }
:lang(ar) .title { font-weight: 900; font-size: 22px; }

.page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 var(--gutter) calc(var(--nav-h) + var(--safe-b) + 20px);
}
#tab-home { padding-bottom: 96px; }

/* ───────── status ───────── */
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  background: var(--panel-2);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.pill i { width: 7px; height: 7px; background: #5b5d66; }
.pill.on { color: #e6fbe9; }
.pill.on i { background: #22d36b; box-shadow: 0 0 8px #22d36b; }
.pill.expired { color: #ffb3b5; }
.pill.expired i { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.refreshed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--label);
}

/* ───────── gauge ───────── */
.gauge {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / .93;
  margin: 6px 0 4px;
}
.corner { position: absolute; width: 18px; height: 18px; border: 0 solid #3a3b44; }
.corner.tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.corner.tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }
.gauge-glow {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(31, 199, 226, .22), rgba(31, 199, 226, .06) 60%, transparent);
  animation: glow 4.5s ease-in-out infinite;
}
@keyframes glow { 50% { opacity: .6; } }
.gauge-svg { position: absolute; width: 92%; height: 100%; overflow: visible; }
.tick { stroke: #2a3d52; stroke-width: 2.4; stroke-linecap: butt; }
.tick.major { stroke: #3a5270; stroke-width: 2.8; }
.tick.lit {
  stroke: var(--red);
  filter: drop-shadow(0 0 3px rgba(31, 199, 226, .7));
  animation: tick-in .5s both;
  animation-delay: calc(var(--i) * 14ms + 120ms);
}
@keyframes tick-in { from { stroke: #2a3d52; filter: none; } }
.gauge-mark { fill: var(--red-hi); filter: drop-shadow(0 0 5px var(--red)); }
.gauge.is-expired .tick { stroke: #22303f; }
.gauge.is-expired .time-left { color: var(--danger-soft); }
.gauge-center { position: relative; text-align: center; padding-top: 6px; }
.time-left {
  font-family: var(--f-display);
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: .01em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .7);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
:lang(ar) .time-left { font-family: var(--f-body); font-weight: 900; font-size: 40px; }
.time-label {
  margin-top: 8px;
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #5d7189;
}
:lang(ar) .time-label { font-size: 13px; }
.gauge-timer {
  margin-top: 7px;
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .16em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ───────── key + stats ───────── */
.key-row {
  --frame-bg: var(--panel);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 0 8px 0 16px;
}
[dir="rtl"] .key-row { padding: 0 16px 0 8px; }
.key-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
  text-align: start;
}
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 78px;
  padding: 12px 12px 14px;
}
.stat .mono-label { font-size: 9.5px; }
.stat b { font-size: 13.5px; font-weight: 600; line-height: 1.25; word-break: break-word; overflow-wrap: anywhere; }
.stat b.mono { font-size: 11px; letter-spacing: .02em; }

/* ───────── CTA ───────── */
.cta-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  z-index: 35;
  width: min(100% - 2 * var(--gutter), var(--app-w) - 2 * var(--gutter));
  transform: translateX(-50%);
  filter: drop-shadow(0 10px 26px rgba(31, 199, 226, .32));
}
.cta {
  --cut: 14px;
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 74px;
  background: linear-gradient(100deg, #24cde8, #1189b4);
  color: #04141c;
  text-align: start;
  transition: filter .15s, transform .1s;
}
.cta:hover { filter: brightness(1.07); }
.cta:active { transform: scale(.99); }
.cta:disabled { filter: grayscale(1) brightness(.5); }
.cta-text { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 12px 18px; }
.cta-text b { font-family: var(--f-display); font-weight: 400; font-size: 18px; text-transform: uppercase; line-height: 1.1; }
:lang(ar) .cta-text b { font-family: var(--f-body); font-weight: 900; font-size: 19px; }
.cta-text small { font-size: 12.5px; opacity: .88; line-height: 1.3; }
.cta-plus {
  --cut: 10px;
  display: grid;
  place-items: center;
  width: 60px;
  margin: 7px;
  background: rgba(0, 0, 0, .12);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.cta-plus .ic { width: 26px; height: 26px; stroke-width: 2; }

/* ───────── tabbar ───────── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  width: min(100%, var(--app-w));
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  transform: translateX(-50%);
  background: #0a0a0c;
  border-top: 1px solid var(--line-soft);
}
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--dim);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  transition: color .2s;
}
.tab .ic { width: 21px; height: 21px; }
.tab.active { color: var(--text); }
.tab.active .ic { color: var(--red-hi); }
.tab::before {
  content: "";
  position: absolute;
  top: -1px;
  width: 34px;
  height: 2px;
  background: var(--red);
  box-shadow: 0 0 12px var(--red), 0 0 2px var(--red);
  transform: scaleX(0);
  transition: transform .25s;
}
.tab.active::before { transform: scaleX(1); }

/* ───────── sub / settings pages ───────── */
.page-title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: .01em;
  margin-top: 4px;
}
:lang(ar) .page-title { font-family: var(--f-body); font-weight: 900; font-size: 21px; }
.page-sub { margin-top: 2px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
#tab-sub .btn-primary { margin-top: 8px; }
.actions { display: grid; gap: 8px; margin-top: 8px; }
.btn-dark {
  --cut: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  width: 100%;
  background: var(--panel-3);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text);
  transition: background .15s;
}
.btn-dark:hover { background: #26262c; }
.note { margin-top: 4px; font-size: 12.5px; line-height: 1.55; color: #5d7189; }
.settings { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.settings .key-row { min-height: 52px; }
.row-lbl {
  flex: 1;
  min-width: 0;
  text-align: start;
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.row-val {
  flex: none;
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--text);
}
.key-row.danger .row-lbl, .key-row.danger .row-val { color: #ff6b6b; }

/* ───────── toast ───────── */
.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 150;
  max-width: min(90vw, 400px);
  padding: 11px 16px;
  background: var(--panel-3);
  border: 1px solid #2e2e35;
  border-inline-start: 3px solid var(--red);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .6);
  font-size: 13.5px;
  transform: translate(-50%, -20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  :root { --gutter: 12px; }
  .time-left { font-size: 34px; }
  .stat { padding: 10px; }
  .stat b { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
  .view-enter, .shake, .tick.lit, .logo-lg, .gauge-glow { animation: none !important; }
}

/* ───────── admin page compatibility ───────── */
main { max-width: 780px; margin: 0 auto; padding: 0 16px 30px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #26cfe9, #0f8fb8);
  color: #04141c;
  font-family: var(--f-display);
  font-size: 17px;
  filter: none;
  clip-path: polygon(0 0, 100% 0, 100% 68%, 68% 100%, 0 100%);
}
.brand-text {
  font-family: var(--f-display);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .02em;
  white-space: nowrap;
}
.brand-text b { color: var(--red-hi); font-weight: 400; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 12px;
}
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text);
}
.ghost:hover { background: #26262c; }
.ghost.small { height: 32px; padding: 0 10px; font-size: 10.5px; }
.hint { color: var(--muted); font-size: 13px; }
