/* ==========================================================================
   Jawwal Planner — design tokens and base controls
   Ported unchanged from the approved prototype (Blueprint 0.2.5 §3, Hi-Fi Specs 1.4 §0).
   FOUR SEPARATE COLOUR CHANNELS + the confirmed fibre lookup. Do not mix.
   Light theme only, deliberately: the approved design system defines one enterprise
   light palette. Every colour is painted explicitly.
   Loaded by every page, including the public login screen.
   ========================================================================== */
:root{
  /* 1 — BRAND. Identity + transient interaction only. Never state, never map symbology. */
  --brand-primary:#76BC21;
  --brand-primary-strong:#4F7F16;
  --brand-primary-hover:#6AAB1E;
  --brand-primary-active:#5C9419;
  --brand-primary-soft:#F0F8E6;
  --brand-primary-border:#C3E29A;
  --brand-on-primary:#121A08;
  --brand-focus-ring:#4F7F16;

  /* 2 — NEUTRAL UI */
  --surface:#FFFFFF;
  --surface-sunken:#F3F5F0;
  --surface-raised:#FFFFFF;
  --surface-hover:#ECEFE8;
  --surface-2:#E7EBE2;          /* referenced since the first pass, never defined */
  --surface-active:#E4E8DE;
  --text-primary:#16190F;
  --text-secondary:#454B3B;
  --text-tertiary:#737A68;
  --text-inverse:#F4F6F0;
  --border-subtle:#E7EAE2;
  --border-default:#D8DDD0;
  --border-strong:#B4BCA8;

  /* 3 — WORKFLOW / REVIEW STATUS. Distinct from brand: approved is deep blue-green. */
  --status-draft:#5F6654;          --status-draft-soft:#EFF1EB;
  --status-pending:#8F5E0D;        --status-pending-soft:#FBF2E0;   --status-pending-border:#E3CB95;
  --status-approved:#1E6A4A;       --status-approved-soft:#E4F0EA;  --status-approved-border:#A8CDBB;
  --status-rejected:#A5342B;       --status-rejected-soft:#FAEBE9;  --status-rejected-border:#E0B0AA;
  --status-info:#26608F;           --status-info-soft:#E8F0F7;      --status-info-border:#A9C5DC;
  --status-conflict:#A5342B;       --status-conflict-soft:#FAEBE9;
  --status-locked:#4A5060;         --status-locked-soft:#ECEEF2;

  /* 4 — MAP / NETWORK SYMBOLOGY. No brand tokens here. */
  --map-ground:#F7F8F4;
  --map-ground-sat:#2C3327;
  --map-road:#E2E5DB;            --map-road-sat:#4A5243;
  --map-road-major:#D3D8C9;
  --map-ref-building:#DCDFD5;    --map-ref-building-stroke:#C3C8B8;
  --map-ref-building-sat:#3C4436;
  --map-locality:#B9A97F;
  --map-pole:#8A6D3B;
  --map-cable:#2A5DA8;
  --map-cable-dist:#7A3E9D;
  --map-splitter:#B5417E;
  --map-manhole:#4A5560;
  --map-building:#8C5A2B;
  --map-ghost:#98A08C;
  --map-project:#1F7A8C;
  --map-import:#C2185B;
  --map-dim:rgba(243,245,240,.62);
  --map-dim-sat:rgba(20,24,18,.55);

  /* FIBRE — the confirmed 12-colour cyclic sequence (Blueprint §3.6).
     Presentation tokens only. The ordered NAMES are the business rule. */
  --fiber-1:#1F6FD0;  /* Blue   */
  --fiber-2:#E8761E;  /* Orange */
  --fiber-3:#2F9140;  /* Green  */
  --fiber-4:#7A4A21;  /* Brown  */
  --fiber-5:#8A9196;  /* Gray   */
  --fiber-6:#FFFFFF;  /* White  — requires border */
  --fiber-7:#D22D2D;  /* Red    */
  --fiber-8:#1B1B1B;  /* Black  */
  --fiber-9:#E0BC17;  /* Yellow */
  --fiber-10:#7B3FBF; /* Violet */
  --fiber-11:#E86AA6; /* Pink   */
  --fiber-12:#1FA5BC; /* Cyan   */

  --font-ui:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --font-mono:ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,"DejaVu Sans Mono",monospace;
  --sh-1:0 1px 2px rgba(22,25,15,.06),0 0 0 1px rgba(22,25,15,.04);
  --sh-2:0 6px 20px rgba(22,25,15,.14),0 0 0 1px rgba(22,25,15,.06);
}

*{box-sizing:border-box}
input[type=checkbox],input[type=radio]{accent-color:var(--brand-primary)}
html,body{height:100%}
body{margin:0;background:var(--surface-sunken);color:var(--text-primary);
  font:400 14px/1.5 var(--font-ui);-webkit-font-smoothing:antialiased;overflow:hidden;
  display:flex;flex-direction:column}
button{font:inherit;color:inherit}
[hidden]{display:none !important}
:focus-visible{outline:2px solid var(--brand-focus-ring);outline-offset:2px;border-radius:3px}
.tnum{font-variant-numeric:tabular-nums}
.mono{font-family:var(--font-mono);font-variant-numeric:tabular-nums}
.muted{color:var(--text-tertiary)}
.vh{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---------- generic controls ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:32px;padding:0 12px;
  border:1px solid var(--border-default);border-radius:4px;background:var(--surface);
  font-size:13px;font-weight:500;cursor:pointer;white-space:nowrap}
.btn:hover{background:var(--surface-hover)}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn-primary{background:var(--brand-primary);border-color:var(--brand-primary);color:var(--brand-on-primary)}
.btn-primary:hover{background:var(--brand-primary-hover);border-color:var(--brand-primary-hover)}
.btn-primary:active{background:var(--brand-primary-active)}
.btn-danger{border-color:var(--status-rejected-border);color:var(--status-rejected)}
.btn-danger:hover{background:var(--status-rejected-soft)}
.btn-sm{height:28px;padding:0 10px;font-size:12px}
.btn-ghost{border-color:transparent;background:transparent}
.btn-ghost:hover{background:var(--surface-hover)}
.icon{width:20px;height:20px;flex:none;stroke:currentColor;fill:none;stroke-width:1.6;
  stroke-linecap:round;stroke-linejoin:round}
.icon-sm{width:16px;height:16px}

/* ---------- status chip ---------- */
.chip{display:inline-flex;align-items:center;gap:6px;height:20px;padding:0 7px;border-radius:2px;
  font-size:11px;font-weight:500;line-height:1;white-space:nowrap;border:1px solid transparent}
.chip .dot{font-size:10px;line-height:1}
.chip-draft{background:var(--status-draft-soft);color:var(--status-draft);border-color:var(--border-default)}
.chip-pending{background:var(--status-pending-soft);color:var(--status-pending);border-color:var(--status-pending-border)}
.chip-approved{background:var(--status-approved-soft);color:var(--status-approved);border-color:var(--status-approved-border)}
.chip-rejected{background:var(--status-rejected-soft);color:var(--status-rejected);border-color:var(--status-rejected-border)}
.chip-info{background:var(--status-info-soft);color:var(--status-info);border-color:var(--status-info-border)}
.chip-conflict{background:var(--status-conflict-soft);color:var(--status-conflict);border-color:var(--status-rejected-border)}
.chip-locked{background:var(--status-locked-soft);color:var(--status-locked);border-color:#C6CCD6}

/* ---------- alerts, spinner ---------- */
.alert{display:flex;gap:10px;align-items:flex-start;padding:10px 12px;border-radius:4px;
  font-size:13px;margin-bottom:16px;border:1px solid}
.alert-error{background:var(--status-rejected-soft);border-color:var(--status-rejected-border);color:var(--status-rejected)}
.alert-info{background:var(--status-info-soft);border-color:var(--status-info-border);color:var(--status-info)}
.spinner{width:16px;height:16px;border:2px solid currentColor;border-right-color:transparent;
  border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spinner{animation-duration:2s}}

/* ---------- tooltip, toast ---------- */
.tip{position:fixed;z-index:90;background:var(--text-primary);color:var(--text-inverse);
  font-size:12px;padding:5px 8px;border-radius:4px;pointer-events:none;white-space:nowrap;box-shadow:var(--sh-2)}
/* toast */
.toasts{position:fixed;bottom:16px;left:50%;transform:translateX(-50%);z-index:200;
  display:flex;flex-direction:column;gap:8px;align-items:center}
.toast{background:var(--text-primary);color:var(--text-inverse);font-size:13px;padding:9px 14px;
  border-radius:4px;box-shadow:var(--sh-2);max-width:520px}
.toast.warn{background:var(--status-pending);color:#fff}
