/* ============================================================================
   Matrix-Free Empire OS — Sovereign command center theme
   Dark obsidian + royal gold. Smooth, tactile, fast.
   ========================================================================== */
:root {
  --gold:        #D4AF37;
  --gold-2:      #E8CB7C;
  --gold-deep:   #A8892F;
  --bg:          #0a0a0a;
  --bg-1:        #101010;
  --bg-2:        #161616;
  --bg-3:        #1c1c1c;
  --bg-4:        #242424;
  --line:        rgba(212,175,55,0.14);
  --line-soft:   rgba(255,255,255,0.06);
  --ink:         #f3f1ea;
  --muted:       #9a958a;
  --muted-2:     #6f6b62;
  --green:       #4ade80;
  --amber:       #fbbf24;
  --red:         #f87171;
  --blue:        #60a5fa;
  --sidebar-w:   258px;
  --radius:      16px;
  --shadow:      0 24px 70px rgba(0,0,0,0.55);
  --ease:        cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 600px at 82% -8%, rgba(212,175,55,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(212,175,55,0.05), transparent 55%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(212,175,55,0.3); color: #fff; }

.gold { color: var(--gold); }
.grad {
  background: linear-gradient(120deg, var(--gold) 0%, var(--gold-2) 50%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-deep); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#emp-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
  background: linear-gradient(180deg, #0d0d0d, #0a0a0a);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: transform .35s var(--ease);
}
.emp-brand { display: flex; align-items: center; gap: 11px; padding: 22px 20px 18px; }
.emp-brand .crest {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  display: grid; place-items: center; color: #1a1407; font-weight: 900;
  box-shadow: 0 6px 20px rgba(212,175,55,0.3);
}
.emp-brand b { font-size: 14.5px; letter-spacing: .2px; line-height: 1.1; }
.emp-brand span { font-size: 10.5px; color: var(--muted-2); letter-spacing: .14em; text-transform: uppercase; }
.emp-nav { padding: 6px 12px 16px; overflow-y: auto; flex: 1; }
.emp-nav .group { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted-2); padding: 14px 12px 7px; }
.emp-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--muted); font-size: 13.5px; font-weight: 500; position: relative;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.emp-link svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.emp-link:hover { background: rgba(255,255,255,0.04); color: var(--ink); transform: translateX(2px); }
.emp-link.active { background: linear-gradient(90deg, rgba(212,175,55,0.16), rgba(212,175,55,0.04)); color: var(--gold); }
.emp-link.active svg { opacity: 1; }
.emp-link.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px;
  background: linear-gradient(var(--gold), var(--gold-deep));
}
.emp-sidefoot { padding: 14px 18px; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--muted-2); }
.emp-sidefoot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
#emp-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: rgba(10,10,10,0.82); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line-soft);
}
#emp-topbar .burger { display: none; background: none; border: 0; color: var(--ink); cursor: pointer; }
.emp-ttl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.emp-ttl h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.emp-ttl p { margin: 0; font-size: 12px; color: var(--muted); }
.emp-top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.emp-pill-live {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); padding: 7px 12px; border-radius: 999px; background: var(--bg-1);
}
.emp-pill-live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }

/* ── Layout shell ────────────────────────────────────────────────────────── */
.emp-main { margin-left: var(--sidebar-w); min-height: 100vh; }
.emp-container { max-width: 1240px; margin: 0 auto; padding: 26px 26px 90px; }
#emp-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 55; backdrop-filter: blur(2px); }

/* ── Cards & panels ──────────────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  transition: border-color .25s, transform .25s var(--ease), box-shadow .25s;
}
.card.hover:hover { border-color: var(--line); transform: translateY(-3px); box-shadow: var(--shadow); }
.card-p { padding: 20px; }
.panel { background: linear-gradient(180deg, var(--bg-2), var(--bg-1)); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head .sub { font-size: 12px; color: var(--muted); }
.panel-body { padding: 18px 20px; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.section-title { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted-2); margin: 30px 0 14px; }

/* ── KPI tiles ───────────────────────────────────────────────────────────── */
.kpi { position: relative; overflow: hidden; padding: 18px 18px 16px; }
.kpi .lbl { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi .val { font-size: 27px; font-weight: 800; margin-top: 9px; letter-spacing: -.02em; }
.kpi .delta { font-size: 11.5px; margin-top: 7px; color: var(--muted); }
.kpi .ring { position: absolute; right: -28px; top: -28px; width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle, rgba(212,175,55,.16), transparent 70%); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 11px 18px; border-radius: 11px; cursor: pointer; border: 1px solid transparent;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s, opacity .2s; white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-deep)); color: #1a1407; box-shadow: 0 8px 24px rgba(212,175,55,0.25); }
.btn-gold:hover { box-shadow: 0 12px 30px rgba(212,175,55,0.4); }
.btn-ghost { background: var(--bg-3); color: var(--ink); border-color: var(--line-soft); }
.btn-ghost:hover { border-color: var(--line); background: var(--bg-4); }
.btn-outline { background: transparent; color: var(--gold); border-color: var(--line); }
.btn-outline:hover { background: rgba(212,175,55,0.08); }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 9px; }
.btn-danger { background: rgba(248,113,113,.12); color: var(--red); border-color: rgba(248,113,113,.25); }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 11px; padding: 11px 13px;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,0.14); }
.textarea { resize: vertical; min-height: 84px; }
select.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a958a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); }
.tbl tr { transition: background .15s; }
.tbl tbody tr:hover { background: rgba(255,255,255,0.025); }
.tbl tr:last-child td { border-bottom: 0; }

/* ── Status pills ────────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 5px 10px; border-radius: 999px; letter-spacing: .02em; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.pending    { color: var(--amber);  background: rgba(251,191,36,.12); }
.pill.accepted   { color: var(--blue);   background: rgba(96,165,250,.12); }
.pill.arrived    { color: var(--blue);   background: rgba(96,165,250,.12); }
.pill.delivering { color: var(--gold-2); background: rgba(212,175,55,.14); }
.pill.delivered  { color: var(--green);  background: rgba(74,222,128,.12); }
.pill.cancelled  { color: var(--red);    background: rgba(248,113,113,.12); }
.pill.paid       { color: var(--green);  background: rgba(74,222,128,.12); }
.pill.unpaid     { color: var(--muted);  background: rgba(255,255,255,.05); }

.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line-soft); padding: 3px 9px; border-radius: 7px; }

/* ── Freedom Ratio gauge ─────────────────────────────────────────────────── */
.gauge { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--gold) calc(var(--val,0) * 1%), var(--bg-4) 0); transition: background .8s var(--ease); }
.gauge::before { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: var(--bg-1); }
.gauge .inner { position: relative; text-align: center; }
.gauge .inner b { font-size: 30px; font-weight: 800; }
.gauge .inner span { font-size: 10.5px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }

/* ── Alerts feed ─────────────────────────────────────────────────────────── */
.alert-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .ic { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; font-size: 14px; }
.alert-row.info .ic { background: rgba(96,165,250,.12); color: var(--blue); }
.alert-row.success .ic { background: rgba(74,222,128,.12); color: var(--green); }
.alert-row.warning .ic { background: rgba(251,191,36,.12); color: var(--amber); }
.alert-row.critical .ic { background: rgba(248,113,113,.12); color: var(--red); }
.alert-row .msg { font-size: 13px; }
.alert-row .t { font-size: 11px; color: var(--muted-2); margin-top: 3px; }

/* ── Department grid (hub) ───────────────────────────────────────────────── */
.dept-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; cursor: pointer; }
.dept-card .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: rgba(212,175,55,.1); color: var(--gold); transition: transform .25s var(--ease); }
.dept-card:hover .ic { transform: scale(1.08) rotate(-3deg); }
.dept-card h3 { margin: 0; font-size: 15px; font-weight: 700; }
.dept-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.dept-card .go { font-size: 12px; color: var(--gold); display: flex; align-items: center; gap: 6px; margin-top: auto; opacity: .7; transition: gap .2s, opacity .2s; }
.dept-card:hover .go { gap: 10px; opacity: 1; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
#emp-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast { display: flex; gap: 11px; align-items: flex-start; padding: 13px 15px; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--line); box-shadow: var(--shadow); animation: toastIn .35s var(--ease); font-size: 13px; }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
.toast .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--gold); }
.toast.success .bar { background: var(--green); }
.toast.error .bar { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.emp-modal { position: fixed; inset: 0; z-index: 150; display: none; place-items: center; padding: 20px; background: rgba(0,0,0,.62); backdrop-filter: blur(4px); }
.emp-modal.open { display: grid; animation: fade .25s ease; }
.emp-modal .box { width: 100%; max-width: 480px; background: linear-gradient(180deg, var(--bg-2), var(--bg-1)); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); animation: pop .3s var(--ease); }
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Skeleton & entrance ─────────────────────────────────────────────────── */
.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 37%, var(--bg-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.rise { opacity: 0; transform: translateY(14px); animation: rise .6s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 40px 20px; color: var(--muted-2); font-size: 13px; }
.flex { display: flex; } .between { justify-content: space-between; } .items-center { align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .wrap { flex-wrap: wrap; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.right { text-align: right; } .center { text-align: center; }
.hide { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 980px) { .g-4 { grid-template-columns: repeat(2,1fr); } .g-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  #emp-sidebar { transform: translateX(-100%); }
  body.nav-open #emp-sidebar { transform: none; }
  body.nav-open #emp-scrim { display: block; }
  .emp-main { margin-left: 0; }
  #emp-topbar .burger { display: inline-flex; }
  .emp-container { padding: 18px 16px 80px; }
}
@media (max-width: 640px) { .g-2, .g-3, .g-4 { grid-template-columns: 1fr; } .emp-top-actions .hide-sm { display: none; } }
