/* بدّالة — telephone exchange cabinet. Tokens from DESIGN.md. */
:root {
  --enamel: #DCE2D8; --panel: #EEF1EA; --plate: #C9D2C5; --ink: #1F2A24; --ink-soft: #55635B;
  --brass: #9A7430; --lamp-amber: #E89A12; --lamp-green: #2F8A55; --lamp-red: #C23B2F; --lamp-off: #A9B3A6;
  --edge: #A3AE9F; --hi: #FFFFFFB0;
  --chart-ok: #2F7A4C; --chart-lost: #E8836F;
  --f-ar: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif;
  --f-kufi: 'Reem Kufi', 'IBM Plex Sans Arabic', sans-serif;
  color-scheme: light;
}
.night {
  --enamel: #1C2420; --panel: #26302B; --plate: #34403A; --ink: #E6EBE3; --ink-soft: #A3B0A8;
  --brass: #C9A15A; --lamp-amber: #F2AE2E; --lamp-green: #4DB37A; --lamp-red: #E25B4E; --lamp-off: #4A5650;
  --edge: #3E4A44; --hi: #FFFFFF14;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--enamel); color: var(--ink); font: 400 16px/1.7 var(--f-ar);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }
.soft { color: var(--ink-soft); }
.kufi { font-family: var(--f-kufi); line-height: 1.3; font-weight: 600; }
/* Engraved brass label. Reem Kufi blurs below ~20px, so small labels use Plex; Kufi is for big headings (.kufi). */
.engraved { font-family: var(--f-ar); color: var(--brass); font-weight: 600; letter-spacing: 0; line-height: 1.5;
  text-shadow: 0 1px 0 var(--hi); }
[hidden] { display: none !important; }

/* Pressed-steel panel */
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; box-shadow: inset 0 1px 0 var(--hi); }
.plate { background: var(--plate); border-radius: 6px; box-shadow: inset 0 1px 2px #0000001f; }

/* Lamps */
.lamp { --c: var(--lamp-off); width: 40px; height: 40px; flex: none; border-radius: 999px; position: relative;
  background: radial-gradient(circle at 36% 30%, #ffffffa0 0 10%, transparent 24%), var(--c);
  box-shadow: inset 0 -4px 8px #00000038, 0 0 0 3px var(--plate), 0 0 0 4px var(--edge); }
.lamp.off { --c: var(--lamp-off); opacity: .55; }
.lamp.free { --c: color-mix(in oklab, var(--lamp-green) 30%, var(--lamp-off)); }
.lamp.green { --c: var(--lamp-green); box-shadow: inset 0 -4px 8px #00000030, 0 0 0 3px var(--plate), 0 0 0 4px var(--edge), 0 0 18px color-mix(in oklab, var(--lamp-green) 60%, transparent); }
.lamp.red { --c: var(--lamp-red); box-shadow: inset 0 -4px 8px #00000030, 0 0 0 3px var(--plate), 0 0 0 4px var(--edge), 0 0 16px color-mix(in oklab, var(--lamp-red) 50%, transparent); }
.lamp.amber { --c: var(--lamp-amber); animation: blink 1s steps(2, jump-none) infinite;
  box-shadow: inset 0 -4px 8px #00000030, 0 0 0 3px var(--plate), 0 0 0 4px var(--edge), 0 0 22px color-mix(in oklab, var(--lamp-amber) 70%, transparent); }
@keyframes blink { 50% { --c: color-mix(in oklab, var(--lamp-amber) 45%, var(--lamp-off)); filter: brightness(.8); box-shadow: inset 0 -4px 8px #00000030, 0 0 0 3px var(--plate), 0 0 0 4px var(--edge); } }
@media (prefers-reduced-motion: reduce) { .lamp.amber { animation: none; } }

/* Buttons: switch keys */
.key { appearance: none; border: 1px solid var(--edge); background: var(--panel); border-radius: 6px; padding: 10px 16px;
  min-height: 44px; cursor: pointer; font-weight: 600; box-shadow: inset 0 1px 0 var(--hi), 0 2px 0 var(--edge);
  transition: transform .08s ease, box-shadow .08s ease; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.key:active { transform: translateY(2px); box-shadow: inset 0 1px 0 var(--hi), 0 0 0 var(--edge); }
.key:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.key.go { background: var(--lamp-green); border-color: color-mix(in oklab, var(--lamp-green) 70%, #000); color: #fff; box-shadow: inset 0 1px 0 #ffffff40, 0 2px 0 color-mix(in oklab, var(--lamp-green) 60%, #000); }
.key.stop { background: var(--lamp-red); border-color: color-mix(in oklab, var(--lamp-red) 70%, #000); color: #fff; box-shadow: inset 0 1px 0 #ffffff40, 0 2px 0 color-mix(in oklab, var(--lamp-red) 60%, #000); }
.key.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.key[disabled] { opacity: .5; cursor: default; }

.field { display: grid; gap: 4px; min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; }
.field input, .field select { border: 1px solid var(--edge); border-radius: 6px; background: var(--enamel); padding: 10px 12px;
  min-height: 46px; font-size: 16px; box-shadow: inset 0 1px 2px #0000001a; }

.toast { position: fixed; inset-inline: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 420px;
  background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 6px; z-index: 50; text-align: center;
  box-shadow: 0 6px 20px #0000003a; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(380px, 100%); padding: 24px; display: grid; gap: 16px; }
.login .mark { display: flex; align-items: center; gap: 12px; }
.login .mark .lamp { width: 28px; height: 28px; }
.wordmark { font-family: var(--f-kufi); font-weight: 700; font-size: 30px; line-height: 1.2; }
.err { color: var(--lamp-red); font-size: 14px; min-height: 1.4em; }
