/* ================================================================
   MIRDALA — shared design system  (ui/app/mirdala.css, served at /ui/mirdala.css)
   Primary: Black + Red · Secondary: Navy + Gray · Accent: Gold · Engraving: light blue
   Every rebuilt page links this file first.
   ================================================================ */
@font-face {
  font-family: "MandoaGlyphs";
  src: url("/library/fonts/aurebesh.ttf") format("truetype"), url("/library/fonts/aurebesh.otf") format("opentype");
  font-display: swap;
}
:root {
  --black: #0A0A0A; --panel: #111214; --card: #151618; --card-hi: #1B1C1F;
  --line: #26282C; --line-hi: #3A3D42;
  --red: #8B0000; --red-hi: #CC0000; --red-glow: rgba(204,0,0,.28);
  --navy: #0D1B2A; --navy-hi: #16304A;
  --gray: #1E1E1E; --gray-mid: #2C2C2C; --gray-light: #4A4A4A;
  --gold: #C9A84C; --gold-hi: #E6C46A; --gold-dim: #8B7335; --gold-glow: rgba(201,168,76,.25);
  --blue: #9BE7FF; --blue-dim: #2C6F8F; --blue-glow: rgba(155,231,255,.28);
  --text: #E8E8E8; --text-2: #A9ABAF; --muted: #6E7076;
  --ok: #4EC94E; --warn: #E8A33A;
  --radius: 12px; --radius-lg: 16px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Courier New", Courier, monospace;
  --shadow: 0 10px 30px rgba(0,0,0,.55);
  --t-fast: .15s; --t: .25s;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { background: var(--black); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; text-decoration: none; }
img { display: block; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* scrolling regions */
.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--red) transparent; }
.scroll-x { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--gray-light) transparent; }
.scroll::-webkit-scrollbar { width: 10px; }
.scroll-x::-webkit-scrollbar { height: 6px; }
.scroll::-webkit-scrollbar-thumb { background: var(--red); border-radius: 10px; border: 3px solid var(--black); }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--red-hi); }
.scroll-x::-webkit-scrollbar-thumb { background: var(--gray-light); border-radius: 6px; }
.scroll::-webkit-scrollbar-track, .scroll-x::-webkit-scrollbar-track { background: transparent; }

/* type */
.m-brand { font-family: var(--mono); font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: var(--gold); }
.m-label { font-family: var(--mono); font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); }
.m-mando { font-family: var(--mono); font-size: 10px; letter-spacing: 1.4px; color: var(--gold-dim); text-transform: uppercase; }
.m-hint { font-size: 12.5px; color: var(--muted); }

/* panels & cards */
.m-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.m-panel-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.m-panel-h h2 { font-size: 14px; font-weight: 650; flex: 1; min-width: 0; }

/* buttons */
.btn { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-hi); background: var(--gray); color: var(--text); font-weight: 550; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast); }
.btn:hover:not(:disabled) { background: var(--gray-mid); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--red-hi); border-color: var(--red-hi); }
.btn.gold { background: transparent; border-color: var(--gold-dim); color: var(--gold); }
.btn.gold:hover:not(:disabled) { background: #17140B; }
.btn.danger { background: transparent; border-color: #6B1B1B; color: #FF8A8A; }
.btn.danger:hover:not(:disabled) { background: #1C0707; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.grow { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; border: 1.5px solid var(--line-hi); background: var(--card); color: var(--text-2); transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast); flex-shrink: 0; }
.icon-btn:hover:not(:disabled) { border-color: var(--gold-dim); color: var(--text); }
.icon-btn.on { border-color: var(--gold); color: var(--gold); background: #1B170C; }
.icon-btn.rec { border-color: var(--red-hi); color: #FF9C9C; background: #230909; animation: m-pulse 1.4s infinite; }
@keyframes m-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(204,0,0,.45); } 50% { box-shadow: 0 0 0 7px rgba(204,0,0,0); } }

/* inputs */
.inp, select.inp, textarea.inp { height: 42px; width: 100%; padding: 0 12px; border-radius: 10px; background: var(--black); border: 1px solid var(--line); outline: none; font-size: 15px; }
textarea.inp { height: auto; min-height: 42px; padding: 10px 12px; resize: none; line-height: 1.45; }
.inp:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 3px var(--gold-glow); }
select.inp { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type="date"].inp { color-scheme: dark; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

/* overlays */
.m-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(2px); z-index: 900; opacity: 0; pointer-events: none; transition: opacity var(--t); }
.m-scrim.show { opacity: 1; pointer-events: auto; }
.m-modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -48%) scale(.98); width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); z-index: 910; display: flex; flex-direction: column; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity var(--t), transform var(--t); }
.m-modal.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.m-modal.wide { width: min(720px, calc(100vw - 24px)); }
.m-modal .m-body { padding: 16px 18px; flex: 1; min-height: 0; }
.m-modal .m-foot { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.m-x { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.m-x:hover { background: var(--gray); color: var(--text); }
@media (max-width: 720px) {
  .m-modal { left: 0; right: 0; top: auto; bottom: 0; width: 100vw; transform: translateY(12px); border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .m-modal.show { transform: none; }
  .m-modal.wide { width: 100vw; }
}

/* toasts */
.m-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100vw - 32px); }
.m-toast { pointer-events: auto; max-width: 460px; padding: 11px 16px; border-radius: 11px; background: #1B1C1F; border: 1px solid var(--line-hi); box-shadow: var(--shadow); font-size: 13.5px; animation: m-tin .2s ease; }
.m-toast.ok { border-color: #2D5A27; } .m-toast.err { border-color: var(--red-hi); background: #1C0707; } .m-toast.gold { border-color: var(--gold-dim); }
@keyframes m-tin { from { opacity: 0; transform: translateY(8px); } }

/* PIN keypad (digits + Mando'a) */
.m-pin-disp { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.m-pin-dots { flex: 1; height: 52px; border-radius: 12px; background: var(--black); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 12px; overflow: hidden; font-size: 22px; letter-spacing: 4px; }
.m-pin-dots.err { border-color: var(--red-hi); animation: m-shake .35s; }
.m-pin-dots .dot { width: 12px; height: 12px; border-radius: 6px; background: var(--gold); flex-shrink: 0; }
.m-pin-dots .ph { color: var(--muted); font-size: 13px; letter-spacing: 1px; }
.m-pin-dots .g { font-family: "MandoaGlyphs", var(--mono); color: var(--gold); }
@keyframes m-shake { 0%,100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.m-pin-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.m-pin-tabs button { height: 34px; border-radius: 9px; border: 1px solid var(--line); color: var(--text-2); font-size: 13px; }
.m-pin-tabs button.on { border-color: var(--gold); color: var(--gold); background: #17140B; }
.m-keys { display: grid; gap: 8px; }
.m-keys.num { grid-template-columns: repeat(3, 1fr); }
.m-keys.glyph { grid-template-columns: repeat(6, 1fr); max-height: 260px; overflow-y: auto; }
.m-key { height: 54px; border-radius: 12px; background: var(--card-hi); border: 1px solid var(--line); font-size: 22px; font-weight: 500; display: grid; place-items: center; user-select: none; transition: background .1s, transform .05s; }
.m-keys.glyph .m-key { height: 46px; font-size: 20px; }
.m-key:hover { background: var(--gray-mid); }
.m-key:active { transform: scale(.96); background: var(--navy-hi); }
.m-key.g { font-family: "MandoaGlyphs", var(--mono); color: var(--gold); }
.m-key.g small { display: none; font-family: var(--mono); font-size: 9px; color: var(--muted); line-height: 1; }
.glyphs-on .m-key.g small { display: block; }
.m-key.fn { font-size: 13px; color: var(--text-2); }
.m-key.ok { background: var(--red); border-color: var(--red); color: #fff; font-size: 14px; font-weight: 600; }
.m-key.ok:hover { background: var(--red-hi); }
.m-pin-msg { min-height: 20px; font-size: 13px; color: #FF9C9C; text-align: center; margin-top: 10px; }
.m-pin-step { font-size: 13px; color: var(--text-2); margin-bottom: 4px; text-align: center; }
@media (max-width: 720px) { .m-key { height: 48px; } .m-keys.glyph .m-key { height: 42px; } }

/* account rows */
.m-user { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.m-user .av { width: 38px; height: 38px; border-radius: 19px; display: grid; place-items: center; background: var(--navy); border: 1px solid var(--navy-hi); color: #B9CDE3; font-weight: 700; flex-shrink: 0; }
.m-user.alor .av { background: #1C0707; border-color: var(--red); color: var(--gold); }
.m-user.council .av { border-color: var(--gold-dim); color: var(--gold); }
.m-user .mi { flex: 1; min-width: 0; }
.m-user .mi b { display: block; font-weight: 600; }
.m-user .mi small { color: var(--muted); font-size: 12px; }
.m-user.off { opacity: .45; }
.m-tier { font-family: var(--mono); font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line-hi); color: var(--text-2); margin-left: 6px; }
.m-user.alor .m-tier { border-color: var(--gold-dim); color: var(--gold); }
.m-chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--navy); border: 1px solid var(--navy-hi); color: #B9CDE3; font-size: 11.5px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; } }
