/* ============================================================
   ATELIER DES MAÎTRES ÉBÉNISTES
   Live Production Tracker — Alasfour Furniture
   ============================================================
   A master cabinetmaker's workshop journal aesthetic.
   Drafting-table precision · warm Saudi craftsmanship dignity.
   ============================================================ */

/* ---------- Design tokens ---------- */

:root {
  /* PAPER PALETTE — daylight workshop */
  --paper:           #f7f2e7;
  --paper-2:         #ede5d1;   /* aged manuscript */
  --paper-edge:      #e0d4ba;
  --paper-grain:     #d8cbab;

  --ink:             #1d2933;   /* drafting ink */
  --ink-2:           #2f3d4a;
  --ink-soft:        #4a5a6a;
  --ink-mute:        #768494;

  --brass:           #b78a3d;   /* aged brass */
  --brass-bright:    #d4a93c;
  --brass-deep:      #8a6724;
  --brass-tint:      #f5e7c2;

  --sapphire:        #1f4f6e;   /* cool counterpoint */
  --sapphire-tint:   #cde0eb;

  --sage:            #41695a;   /* completed, on-schedule */
  --sage-tint:       #d4e3da;

  --olive:           #8a7a30;   /* at risk */
  --olive-tint:      #ede6c3;

  --brick:           #a13822;   /* delayed, over-budget */
  --brick-tint:      #f1d5cc;

  --aubergine:       #5a3552;   /* cancelled */
  --aubergine-tint:  #e3d2dd;

  --charcoal:        #3a3a3a;
  --scarlet:         #c93a25;   /* alarm */

  /* SHOP PALETTE — TV / night workshop */
  --shop-table:      #0a0e14;   /* deep table */
  --shop-table-2:    #131a23;
  --shop-ink:        #1d2933;   /* slightly raised slate */
  --shop-cream:      #e8dfc9;   /* lamp-lit paper */
  --shop-cream-2:    #c5b896;
  --shop-mute:       #5f6b78;
  --shop-brass:      #e7c267;   /* luminous brass */
  --shop-sage:       #6b9d87;
  --shop-brick:      #d96f57;
  --shop-sapphire:   #5d96bc;

  /* SPACING — 4px base */
  --sp-h: 4px;  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px;

  /* FONT FAMILIES */
  --f-display:  "Fraunces", "IBM Plex Serif", Georgia, serif;
  --f-sans:     "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-ar:       "IBM Plex Sans Arabic", "Cairo", "Tajawal", sans-serif;
  --f-mono:     "IBM Plex Mono", "JetBrains Mono", "SF Mono", Menlo, monospace;

  /* TYPE SCALE */
  --t-xs:   11px;
  --t-sm:   13px;
  --t-md:   15px;
  --t-lg:   18px;
  --t-xl:   22px;
  --t-2xl:  28px;
  --t-3xl:  36px;
  --t-4xl:  48px;
  --t-5xl:  64px;
  --t-6xl:  88px;

  /* RADII — sparing use; mostly square */
  --r-sm: 2px;
  --r-md: 4px;
  --r-lg: 8px;

  /* SHADOWS — paper depth, never floaty */
  --sh-sm: 0 1px 0 rgba(29,41,51,0.08), 0 0 0 1px rgba(29,41,51,0.04);
  --sh-md: 0 2px 0 rgba(29,41,51,0.06), 0 1px 12px rgba(29,41,51,0.06), 0 0 0 1px rgba(29,41,51,0.04);
  --sh-lg: 0 8px 24px rgba(29,41,51,0.12), 0 0 0 1px rgba(29,41,51,0.06);

  /* PAGE LAYOUT */
  --page-max: 1480px;
  --page-pad: 32px;
}

/* ---------- Base reset & typography ---------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  font-family: var(--f-sans);
  font-feature-settings: "ss01" on, "ss02" on, "kern" on, "liga" on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color: var(--ink);
  background: var(--paper);
}

[dir="rtl"], .ar { font-family: var(--f-ar); }

body {
  min-height: 100vh;
  /* Paper grain — extremely subtle SVG noise. */
  background:
    radial-gradient(circle at 20% 10%, rgba(183,138,61,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(31,79,110,0.03) 0%, transparent 60%),
    var(--paper);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.16 0 0 0 0 0.20 0 0 0 0.045 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.6;
  z-index: 0;
  mix-blend-mode: multiply;
}

#root { position: relative; z-index: 1; }

a { color: var(--brass); text-decoration: none; border-bottom: 1px dotted var(--brass); }
a:hover { color: var(--brass-deep); border-bottom-style: solid; }

/* ---------- Display + numeric typography ---------- */

.display, h1.display, .h-display {
  font-family: var(--f-display);
  font-weight: 460;            /* Fraunces variable */
  font-variation-settings: "opsz" 60, "SOFT" 0, "WONK" 0;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--ink);
}

.h-eyebrow {
  font-family: var(--f-sans);
  font-weight: 600;
  font-size: var(--t-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.h-eyebrow .ar {
  letter-spacing: 0;
  font-weight: 500;
  margin-inline-start: 6px;
  opacity: 0.7;
}

.h-section {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: var(--t-2xl);
  font-variation-settings: "opsz" 60;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.num {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "zero" on, "ss01" on;
  letter-spacing: -0.01em;
}

.num-display {
  font-family: var(--f-display);
  font-weight: 380;
  font-variant-numeric: tabular-nums lining-nums;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.02em;
  line-height: 0.92;
  color: var(--ink);
}

.muted { color: var(--ink-mute); }
.soft  { color: var(--ink-soft); }
.ar-display { font-family: var(--f-ar); font-weight: 500; }

/* ---------- Decorative motifs ---------- */

/* Tick divider — a measuring rule. */
.tick-rule {
  position: relative;
  height: 12px;
  background-image:
    linear-gradient(to right,
      var(--ink) 1px, transparent 1px,
      transparent 8px,
      var(--ink-mute) 1px, transparent 1px);
  background-size: 16px 100%;
  background-position: 0 50%;
  background-repeat: repeat-x;
  background-clip: padding-box;
  opacity: 0.18;
}

.tick-rule-thick {
  height: 24px;
  background-image:
    /* tall ticks every 10 units, short ticks between */
    linear-gradient(to right,
      var(--ink) 1px, transparent 1px),
    linear-gradient(to right,
      var(--ink) 1px, transparent 1px);
  background-size: 80px 100%, 16px 50%;
  background-position: 0 0, 0 100%;
  background-repeat: repeat-x, repeat-x;
  opacity: 0.22;
}

hr.rule {
  border: 0;
  height: 1px;
  background: var(--ink);
  opacity: 0.12;
  margin: var(--sp-5) 0;
}

/* Marker corner brackets — for highlighting key blocks. */
.bracket {
  position: relative;
}
.bracket::before, .bracket::after,
.bracket > .br-tr, .bracket > .br-bl, .bracket > .br-br {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--brass);
  border-style: solid;
  border-width: 0;
  opacity: 0.9;
}
.bracket::before  { top: -2px; left: -2px; border-top-width: 2px; border-left-width: 2px; }
.bracket::after   { top: -2px; right: -2px; border-top-width: 2px; border-right-width: 2px; }
.bracket > .br-bl { bottom: -2px; left: -2px; border-bottom-width: 2px; border-left-width: 2px; }
.bracket > .br-br { bottom: -2px; right: -2px; border-bottom-width: 2px; border-right-width: 2px; }

/* Hand-drawn underline (svg-emulated via wavy decoration) */
.ud-stamp {
  background-image: linear-gradient(to right, var(--brass) 30%, transparent 30%);
  background-size: 6px 2px;
  background-position: 0 100%;
  background-repeat: repeat-x;
  padding-bottom: 4px;
}

/* Stamp seal — circular hand-stamped status badge. */
.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  font-family: var(--f-sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  position: relative;
  white-space: nowrap;
  background-image:
    radial-gradient(circle at 30% 40%, rgba(255,255,255,0.4) 0%, transparent 30%);
  transform: rotate(-1.2deg);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stamp::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px dashed currentColor;
  opacity: 0.35;
  pointer-events: none;
  border-radius: 3px;
}
.stamp.tight { padding: 3px 9px; font-size: 10px; letter-spacing: 0.1em; }

.stamp.s-ok       { color: var(--sage);     background-color: var(--sage-tint); }
.stamp.s-warn     { color: var(--olive);    background-color: var(--olive-tint); }
.stamp.s-bad      { color: var(--brick);    background-color: var(--brick-tint); }
.stamp.s-ahead    { color: var(--sapphire); background-color: var(--sapphire-tint); }
.stamp.s-neutral  { color: var(--ink-soft); background-color: var(--paper-2); }
.stamp.s-stamp    { color: var(--brass-deep); background-color: var(--brass-tint); }
.stamp.s-cancel   { color: var(--aubergine); background-color: var(--aubergine-tint); }

/* Pills — softer than stamps for less-emphasized state */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-family: var(--f-sans);
  border: 1px solid transparent;
}
.pill .ar { font-weight: 500; opacity: 0.75; margin-inline-start: 4px; }
.pill.ok       { background: var(--sage-tint);     color: var(--sage);    border-color: rgba(65,105,90,0.25); }
.pill.warn     { background: var(--olive-tint);    color: var(--olive);   border-color: rgba(138,122,48,0.25); }
.pill.bad      { background: var(--brick-tint);    color: var(--brick);   border-color: rgba(161,56,34,0.25); }
.pill.ahead    { background: var(--sapphire-tint); color: var(--sapphire); border-color: rgba(31,79,110,0.25); }
.pill.neutral  { background: var(--paper-2);       color: var(--ink-soft); border-color: rgba(29,41,51,0.12); }
.pill.info     { background: var(--sapphire-tint); color: var(--sapphire); border-color: rgba(31,79,110,0.25); }
.pill.brass    { background: var(--brass-tint);    color: var(--brass-deep); border-color: rgba(183,138,61,0.3); }
.pill.zombie   { background: var(--aubergine-tint); color: var(--aubergine); border-color: rgba(90,53,82,0.25); }
.pill.clickable { cursor: pointer; transition: filter 0.15s; }
.pill.clickable:hover { filter: brightness(0.96); }

/* ---------- Page chrome ---------- */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--paper-edge);
  padding: 0 var(--page-pad);
  height: 64px;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(247, 242, 231, 0.92);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 4px;
  background:
    linear-gradient(to right, var(--brass) 0, var(--brass) 80px, transparent 80px),
    linear-gradient(to right, var(--paper-edge) 0, var(--paper-edge) 100%);
  background-position: 0 0, 0 0;
  background-size: 100% 1px, 100% 1px;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-inline-end: var(--sp-5);
  border-inline-end: 1px solid var(--paper-edge);
  height: 64px;
}
.brand-mark {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
  border-radius: var(--r-sm);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid var(--brass);
  border-radius: 1px;
  pointer-events: none;
}
.brand-name {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: var(--t-lg);
  line-height: 1.1;
  color: var(--ink);
}
.brand-name-ar {
  font-family: var(--f-ar);
  font-size: var(--t-sm);
  color: var(--ink-mute);
  display: block;
  margin-top: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
}
.nav-item {
  position: relative;
  padding: 0 var(--sp-4);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--f-sans);
  font-weight: 500;
  font-size: var(--t-sm);
  color: var(--ink-soft);
  cursor: pointer;
  border: 0;
  background: none;
  letter-spacing: 0.02em;
  transition: color 0.12s;
}
.nav-item:hover { color: var(--ink); }
.nav-item .lbl-en { line-height: 1; }
.nav-item .lbl-ar { font-family: var(--f-ar); font-size: 10px; color: var(--ink-mute); margin-top: 2px; line-height: 1; }
.nav-item.active { color: var(--ink); }
.nav-item.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px;
  bottom: -1px;
  height: 3px;
  background: var(--brass);
}

.topbar-right {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.dept-toggle {
  display: flex;
  border: 1px solid var(--paper-edge);
  background: var(--paper);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.dept-toggle button {
  background: none; border: 0;
  padding: 6px 12px;
  font-family: var(--f-sans);
  font-size: var(--t-xs);
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-inline-end: 1px solid var(--paper-edge);
}
.dept-toggle button:last-child { border-inline-end: 0; }
.dept-toggle button.active {
  background: var(--ink);
  color: var(--paper);
}

.icon-btn {
  width: 36px; height: 36px;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
  transition: color 0.12s, border-color 0.12s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-mute); }

/* Footer */
.footer-rule {
  margin-top: auto;
  padding: var(--sp-5) var(--page-pad);
  border-top: 1px solid var(--paper-edge);
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--t-xs);
  color: var(--ink-mute);
}

/* ---------- Page container ---------- */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--page-pad) var(--sp-7);
  position: relative;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sp-5);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--paper-edge);
  position: relative;
}
.page-header::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  width: 120px; height: 2px;
  background: var(--brass);
}

.page-title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 40px;
  font-variation-settings: "opsz" 120;
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.page-title .ar {
  display: block;
  font-family: var(--f-ar);
  font-weight: 500;
  font-size: var(--t-md);
  color: var(--ink-mute);
  margin-top: 4px;
  letter-spacing: 0;
}

.page-meta {
  text-align: end;
  font-size: var(--t-xs);
  color: var(--ink-mute);
  font-family: var(--f-mono);
}

/* ---------- Cards & blocks ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  padding: var(--sp-5);
  position: relative;
}

.card-flat {
  background: var(--paper);
  border: 0;
  border-top: 1px solid var(--paper-edge);
  border-bottom: 1px solid var(--paper-edge);
}

.card-elev {
  background: #fcf8ed;
  border: 1px solid var(--paper-edge);
  box-shadow: var(--sh-sm);
}

.card-inset {
  background: var(--paper-2);
  border: 1px solid var(--paper-edge);
}

.card-dark {
  background: var(--ink);
  color: var(--paper);
  border: 0;
}

.card .tag {
  position: absolute;
  top: -1px; left: var(--sp-4);
  background: var(--ink);
  color: var(--paper);
  padding: 4px 10px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Metric block — the editorial "by the numbers" card */
.metric {
  position: relative;
  padding: var(--sp-5);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
}
.metric .metric-label {
  font-family: var(--f-sans);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: flex; align-items: baseline; gap: 6px;
}
.metric .metric-label .ar {
  font-family: var(--f-ar); font-weight: 500;
  text-transform: none; letter-spacing: 0;
  font-size: var(--t-xs); color: var(--ink-mute);
}
.metric .metric-value {
  font-family: var(--f-display);
  font-weight: 380;
  font-variation-settings: "opsz" 144;
  font-size: var(--t-5xl);
  line-height: 0.95;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-top: var(--sp-3);
  font-variant-numeric: tabular-nums lining-nums;
}
.metric .metric-unit {
  font-family: var(--f-sans);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink-mute);
  margin-inline-start: 6px;
  letter-spacing: 0.02em;
}
.metric .metric-foot {
  margin-top: var(--sp-3);
  font-size: var(--t-xs);
  color: var(--ink-soft);
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--f-mono);
}
.metric .delta-up   { color: var(--sage); }
.metric .delta-down { color: var(--brick); }
.metric .delta-flat { color: var(--ink-mute); }

.metric.bordered-left { border-left: 3px solid var(--brass); }
.metric.bordered-left.s-ok    { border-left-color: var(--sage); }
.metric.bordered-left.s-warn  { border-left-color: var(--olive); }
.metric.bordered-left.s-bad   { border-left-color: var(--brick); }
.metric.bordered-left.s-info  { border-left-color: var(--sapphire); }

/* ---------- Tables ---------- */

.table-frame {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  overflow: hidden;
}

table.ledger {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--f-sans);
  font-size: var(--t-sm);
}
table.ledger thead th {
  font-family: var(--f-sans);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  text-align: start;
  padding: 14px 14px 10px;
  background: var(--paper-2);
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
table.ledger tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--paper-edge);
  vertical-align: middle;
}
table.ledger tbody tr {
  transition: background 0.12s;
}
table.ledger tbody tr:hover { background: rgba(183,138,61,0.06); }
table.ledger tbody tr.row-over-budget { background: rgba(161,56,34,0.05); }
table.ledger tbody tr.row-delayed     { background: rgba(161,56,34,0.08); }
table.ledger tbody tr.row-zombie      { background: rgba(90,53,82,0.06); }
table.ledger tbody tr.row-completed   { opacity: 0.6; }

.jo-code {
  font-family: var(--f-mono);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.jo-code-large {
  font-family: var(--f-mono);
  font-size: var(--t-lg);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.row-priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: var(--t-sm);
  border-radius: 2px;
  letter-spacing: 0;
}
.row-priority.top {
  background: var(--brass);
  color: var(--ink);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink-mute);
  border-radius: var(--r-sm);
  font-family: var(--f-sans);
  font-weight: 500;
  font-size: var(--t-sm);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn:hover { background: var(--paper-2); }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); }

.btn-brass {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass-deep);
  font-weight: 600;
}
.btn-brass:hover { background: var(--brass-deep); color: var(--paper); }

.btn-ghost { border-color: var(--paper-edge); color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-mute); }

.btn-danger { color: var(--brick); border-color: var(--brick); }
.btn-danger:hover { background: var(--brick-tint); }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-xs { padding: 2px 7px; font-size: 10px; gap: 3px; }

/* ---------- Forms ---------- */

input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], input[type="search"],
textarea, select {
  font-family: inherit;
  font-size: var(--t-sm);
  padding: 9px 11px;
  background: var(--paper);
  border: 1px solid var(--ink-mute);
  border-radius: var(--r-sm);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus {
  outline: 0;
  border-color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--brass);
}
textarea { min-height: 72px; resize: vertical; }

select { appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) 14px, calc(100% - 11px) 14px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 30px;
}
[dir="rtl"] select { background-position: 16px 14px, 21px 14px; padding-inline-end: 11px; padding-inline-start: 30px; }

.field {
  display: block;
  margin-bottom: var(--sp-4);
}
.field .lbl {
  display: block;
  font-family: var(--f-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.field .lbl .ar {
  font-family: var(--f-ar);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin-inline-start: 6px;
  opacity: 0.75;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  z-index: 1000;
  animation: backdrop-in 0.18s ease;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  animation: modal-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 24px 60px rgba(10,14,20,0.4), 0 0 0 1px rgba(29,41,51,0.1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.modal-head {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--paper-edge);
  position: relative;
}
.modal-head h3 {
  font-family: var(--f-display);
  font-weight: 460;
  font-variation-settings: "opsz" 80;
  font-size: var(--t-xl);
  margin: 0;
  letter-spacing: -0.015em;
}
.modal-head .modal-sub {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  color: var(--ink-mute);
  margin-top: 4px;
}
.modal-body { padding: var(--sp-5); }
.modal-foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--paper-edge);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--paper-2);
}

.modal-close {
  position: absolute;
  top: 14px; inset-inline-end: 14px;
  width: 28px; height: 28px;
  background: none;
  border: 0;
  font-size: 20px;
  cursor: pointer;
  color: var(--ink-mute);
  line-height: 1;
}
.modal-close:hover { color: var(--ink); }

/* ---------- Login gate (atelier vestibule) ---------- */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background:
    radial-gradient(ellipse at top, rgba(183,138,61,0.08) 0%, transparent 60%),
    var(--paper);
}
.gate-card {
  width: 100%;
  max-width: 420px;
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  box-shadow: 0 20px 60px rgba(29,41,51,0.08);
  position: relative;
}
.gate-card::before, .gate-card::after {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  border: 2px solid var(--brass);
}
.gate-card::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.gate-card::after  { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

.gate-mark {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.gate-mark .seal {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 24px;
}
.gate-title {
  font-family: var(--f-display);
  font-weight: 460;
  font-size: var(--t-2xl);
  font-variation-settings: "opsz" 100;
  line-height: 1;
  letter-spacing: -0.02em;
}
.gate-title-ar {
  font-family: var(--f-ar);
  font-weight: 500;
  font-size: var(--t-sm);
  color: var(--ink-mute);
  margin-top: 4px;
}

/* ---------- TV mode (night workshop) ---------- */

body.theme-shop {
  background: var(--shop-table);
  color: var(--shop-cream);
}
body.theme-shop::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.96 0 0 0 0 0.92 0 0 0 0 0.82 0 0 0 0.03 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: screen;
}

.tv {
  min-height: 100vh;
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  background:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(231,194,103,0.10), transparent),
    radial-gradient(ellipse 60% 30% at 50% 110%, rgba(31,79,110,0.18), transparent),
    var(--shop-table);
  color: var(--shop-cream);
  position: relative;
  overflow-x: hidden;
}

/* Subtle blueprint grid on TV */
.tv::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(229,219,201,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(229,219,201,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.tv-banner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: var(--sp-6);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid rgba(229,219,201,0.18);
  margin-bottom: var(--sp-5);
  position: relative;
  z-index: 2;
}
.tv-banner::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  width: 220px; height: 3px;
  background: var(--shop-brass);
}

.tv-dept {
  display: flex; flex-direction: column;
}
.tv-dept-en {
  font-family: var(--f-display);
  font-weight: 320;
  font-size: 56px;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.025em;
  color: var(--shop-cream);
  line-height: 1;
}
.tv-dept-ar {
  font-family: var(--f-ar);
  font-weight: 500;
  font-size: 28px;
  color: var(--shop-cream-2);
  margin-top: 6px;
  line-height: 1;
}

.tv-crest {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
}
.tv-crest-mark {
  font-family: var(--f-display);
  font-weight: 460;
  font-size: 38px;
  letter-spacing: -0.02em;
  color: var(--shop-brass);
  line-height: 1;
}
.tv-crest-label {
  font-family: var(--f-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--shop-mute);
}

.tv-clock {
  text-align: end;
}
.tv-clock-time {
  font-family: var(--f-mono);
  font-size: 56px;
  font-weight: 300;
  line-height: 1;
  color: var(--shop-cream);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.tv-clock-date {
  font-family: var(--f-sans);
  font-size: 14px;
  color: var(--shop-mute);
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.tv-clock-date-ar {
  font-family: var(--f-ar);
  font-size: 14px;
  color: var(--shop-cream-2);
  margin-top: 2px;
}

.tv-rule {
  height: 18px;
  position: relative;
  margin: 0 0 var(--sp-5);
}
.tv-rule::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(229,219,201,0.5) 1px, transparent 1px),
    linear-gradient(to right, rgba(229,219,201,0.25) 1px, transparent 1px);
  background-size: 96px 100%, 24px 50%;
  background-position: 0 0, 0 100%;
  background-repeat: repeat-x;
}

.tv-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.tv-stat {
  border-left: 2px solid var(--shop-brass);
  padding: 6px var(--sp-3);
}
.tv-stat-value {
  font-family: var(--f-display);
  font-weight: 320;
  font-size: 40px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--shop-cream);
}
.tv-stat-label {
  font-family: var(--f-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--shop-mute);
  margin-top: 4px;
}
.tv-stat-label .ar {
  font-family: var(--f-ar);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin-inline-start: 6px;
  opacity: 0.85;
}

.tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: var(--sp-4);
}

.tv-card {
  background: rgba(229,219,201,0.04);
  border: 1px solid rgba(229,219,201,0.16);
  padding: var(--sp-4);
  position: relative;
  transition: transform 0.2s, border-color 0.2s;
}
.tv-card::before, .tv-card::after,
.tv-card .corner-bl, .tv-card .corner-br {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border: 1px solid rgba(229,219,201,0.35);
  border-style: solid;
}
.tv-card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.tv-card::after  { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.tv-card .corner-bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.tv-card .corner-br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.tv-card.top {
  background: rgba(231,194,103,0.08);
  border: 1px solid rgba(231,194,103,0.4);
  grid-column: span 2;
  padding: var(--sp-5);
}
.tv-card.top::before, .tv-card.top::after,
.tv-card.top .corner-bl, .tv-card.top .corner-br {
  border-color: var(--shop-brass);
  border-width: 2px;
  width: 16px; height: 16px;
}

.tv-card .pri {
  position: absolute;
  top: var(--sp-3);
  inset-inline-end: var(--sp-3);
  background: var(--shop-brass);
  color: var(--shop-ink);
  font-family: var(--f-display);
  font-weight: 520;
  font-size: 22px;
  padding: 4px 12px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.tv-card.top .pri {
  font-size: 38px;
  padding: 8px 18px;
}

.tv-card .jo {
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--shop-cream-2);
  text-transform: uppercase;
}
.tv-card.top .jo { font-size: 16px; }

.tv-card .req {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--shop-mute);
  margin-inline-start: 8px;
}

.tv-card .item {
  font-family: var(--f-ar);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--shop-cream);
  margin-top: 10px;
  direction: rtl;
  text-align: start;
}
.tv-card.top .item { font-size: 30px; }
.tv-card .item-en {
  font-family: var(--f-sans);
  font-size: 13px;
  color: var(--shop-mute);
  letter-spacing: 0.02em;
  margin-top: 2px;
  direction: ltr;
  text-align: start;
}
.tv-card.top .item-en { font-size: 16px; }

.tv-card .meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: var(--sp-3);
  font-family: var(--f-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.tv-card.top .meta-row { font-size: 17px; }
.tv-card .meta-label {
  font-family: var(--f-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--shop-mute);
}
.tv-card .meta-value { color: var(--shop-cream); font-weight: 500; }

.tv-bar {
  margin-top: 8px;
  height: 6px;
  background: rgba(229,219,201,0.08);
  position: relative;
}
.tv-bar .fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  background: var(--shop-brass);
  transition: width 0.4s ease;
}
.tv-bar .tick {
  position: absolute;
  inset-block: -3px;
  width: 1px;
  background: rgba(229,219,201,0.18);
}

.tv-workers {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: var(--sp-3);
}
.tv-worker {
  background: rgba(231,194,103,0.12);
  color: var(--shop-brass);
  font-family: var(--f-ar);
  font-size: 14px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 2px;
  letter-spacing: 0;
}

.tv-footer {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid rgba(229,219,201,0.14);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--shop-mute);
  letter-spacing: 0.04em;
  position: relative;
  z-index: 2;
}
.tv-pulse {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--shop-sage);
  border-radius: 50%;
  margin-inline-end: 8px;
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(107,157,135,0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(107,157,135,0); }
}

.tv-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--shop-mute);
}
.tv-empty-ar { font-family: var(--f-ar); font-size: 32px; color: var(--shop-cream-2); }
.tv-empty-en { font-family: var(--f-sans); font-size: 18px; margin-top: 12px; letter-spacing: 0.04em; }

/* ---------- Loading / empty states ---------- */

.skeleton {
  background: linear-gradient(90deg, var(--paper-2) 0%, var(--paper-edge) 50%, var(--paper-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.loading-compass {
  width: 36px; height: 36px;
  margin: 0 auto;
  position: relative;
}
.loading-compass::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--paper-edge);
  border-top-color: var(--brass);
  border-radius: 50%;
  animation: compass 0.9s linear infinite;
}
@keyframes compass { to { transform: rotate(360deg); } }

.empty {
  padding: 60px var(--sp-5);
  text-align: center;
  color: var(--ink-mute);
}
.empty-mark {
  width: 48px; height: 48px; margin: 0 auto var(--sp-3);
  border: 1px dashed var(--ink-mute);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display);
  font-size: 24px;
  color: var(--ink-mute);
}

/* ---------- Toast ---------- */

.toasts {
  position: fixed;
  top: 80px;
  inset-inline-end: var(--sp-5);
  z-index: 2000;
  display: flex; flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: 360px;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--t-sm);
  border-left: 3px solid var(--brass);
  min-width: 240px;
  box-shadow: 0 8px 24px rgba(10,14,20,0.3);
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}
.toast.s-ok   { border-left-color: var(--sage); }
.toast.s-bad  { border-left-color: var(--brick); }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ---------- Utility ---------- */

.row { display: flex; gap: var(--sp-3); align-items: center; }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.grow { flex: 1; }
.spacer { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.stack-2 > * + * { margin-top: var(--sp-2); }
.stack-3 > * + * { margin-top: var(--sp-3); }
.stack-4 > * + * { margin-top: var(--sp-4); }
.stack-5 > * + * { margin-top: var(--sp-5); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

[data-tip] { position: relative; cursor: help; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
  border-radius: 2px;
  pointer-events: none;
  z-index: 100;
  font-family: var(--f-sans);
  letter-spacing: 0;
  text-transform: none;
}

/* Bilingual inline pair */
.bi { display: inline-flex; align-items: baseline; gap: 6px; }
.bi .en { font-family: var(--f-sans); }
.bi .ar { font-family: var(--f-ar); font-size: 0.9em; color: var(--ink-mute); }
.bi.stacked { flex-direction: column; gap: 0; align-items: flex-start; }
.bi.stacked .ar { margin-top: 1px; font-size: 0.78em; }

/* Print */
@media print {
  body { background: white; }
  body::before { display: none; }
  .topbar, .nav, .footer-rule, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #999; }
}

/* RTL adjustments */
[dir="rtl"] .page-header::after { right: 0; left: auto; }
[dir="rtl"] .topbar::after { background-position: 100% 0; }

/* Focus outlines */
:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
