/* ============================================================
   KAMI OS — CORE / DESIGN SYSTEM
   Cyberpunk Executive Command Center
   ============================================================ */

:root {
  /* Surfaces */
  --bg-0: #04060a;
  --bg-1: #070b12;
  --bg-2: #0b1120;
  --bg-3: #0f1626;
  --grid-line: rgba(0, 229, 255, 0.04);

  /* Glass */
  --glass: rgba(13, 21, 38, 0.55);
  --glass-2: rgba(18, 28, 48, 0.7);
  --glass-border: rgba(83, 160, 255, 0.16);
  --glass-border-hot: rgba(0, 229, 255, 0.4);

  /* Accents */
  --accent: #00e5ff;
  --accent-2: #2b7fff;
  --accent-3: #7b5cff;
  --accent-glow: rgba(0, 229, 255, 0.35);

  /* Semantic */
  --good: #2ee6a6;
  --good-dim: rgba(46, 230, 166, 0.14);
  --warn: #ffb020;
  --warn-dim: rgba(255, 176, 32, 0.14);
  --bad: #ff4d6d;
  --bad-dim: rgba(255, 77, 109, 0.14);
  --locked: #6b7a92;

  /* Text */
  --text: #e8f1ff;
  --text-dim: #9bb0d0;
  --text-faint: #5e739a;

  /* Geometry */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 74px;
  --topbar-h: 62px;

  /* Type — alien command-deck system */
  --font-display: "Orbitron", "Chakra Petch", system-ui, sans-serif; /* brand, big readouts */
  --font-head: "Chakra Petch", "Orbitron", system-ui, sans-serif;    /* titles, UI, buttons */
  --font-body: "Sora", system-ui, -apple-system, sans-serif;          /* prose */
  --font-mono: "Share Tech Mono", ui-monospace, "SF Mono", monospace; /* terminal readouts */

  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.75);
  --shadow-glow: 0 0 28px -6px var(--accent-glow);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body {
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(43, 127, 255, 0.10), transparent 60%),
    radial-gradient(900px 600px at 12% 110%, rgba(123, 92, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
}

::selection { background: var(--accent-glow); color: #00131a; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(83, 160, 255, 0.18); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 229, 255, 0.35); background-clip: content-box; }

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   BOOT SCREEN
   ============================================================ */
.boot-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background: radial-gradient(800px 500px at 50% 40%, rgba(0,229,255,0.06), transparent 70%), var(--bg-0);
  transition: opacity 0.5s var(--ease);
}
.boot-screen.hide { opacity: 0; pointer-events: none; }
.boot-inner { width: min(340px, 80vw); text-align: center; }
.boot-logo {
  font-family: var(--font-display); font-weight: 700; font-size: 48px;
  letter-spacing: 8px; color: var(--text);
  text-shadow: 0 0 24px var(--accent-glow);
}
.boot-logo span { color: var(--accent); }
.boot-bar { margin: 22px 0 12px; height: 3px; background: rgba(255,255,255,0.07); border-radius: 4px; overflow: hidden; }
.boot-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); box-shadow: 0 0 12px var(--accent-glow); animation: bootfill 1.1s var(--ease) forwards; }
@keyframes bootfill { to { width: 100%; } }
.boot-status { font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; color: var(--text-faint); text-transform: uppercase; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; }
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(10,16,28,0.92), rgba(6,10,18,0.92));
  border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  z-index: 40; min-height: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 14px; border-bottom: 1px solid var(--glass-border); }
.brand { display: flex; align-items: center; gap: 11px; overflow: hidden; }
.brand-mark {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 19px; color: #00141a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 9px; box-shadow: 0 0 18px -2px var(--accent-glow);
}
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: 3px; white-space: nowrap; }
.brand-text span { color: var(--accent); }
.app.collapsed .brand-text, .app.collapsed .sidebar-foot, .app.collapsed .nav-label { display: none; }

.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.nav-group-label { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 2px; color: var(--text-faint); text-transform: uppercase; padding: 14px 10px 6px; }
.app.collapsed .nav-group-label { text-align: center; font-size: 0; padding: 10px 0 4px; }
.app.collapsed .nav-group-label::after { content: "·"; font-size: 14px; }

.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--text-dim);
  border: 1px solid transparent; position: relative;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
  white-space: nowrap; user-select: none;
}
.nav-item:hover { background: rgba(83,160,255,0.07); color: var(--text); }
.nav-item .nav-ico { width: 20px; height: 20px; flex: none; opacity: 0.85; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(0,229,255,0.14), rgba(0,229,255,0.02));
  color: #fff; border-color: var(--glass-border-hot);
}
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); width: 3px; height: 22px; background: var(--accent); border-radius: 4px; box-shadow: 0 0 10px var(--accent); }
.nav-item.locked { opacity: 0.5; }
.nav-item.locked .nav-lock { margin-left: auto; font-size: 11px; }
.app.collapsed .nav-item { justify-content: center; padding: 11px; }
.app.collapsed .nav-lock { display: none; }
.nav-label { font-family: var(--font-head); font-size: 13px; font-weight: 500; letter-spacing: 0.6px; }

.sidebar-foot { padding: 14px 18px; border-top: 1px solid var(--glass-border); }
.sys-stat { font-family: var(--font-mono); font-size: 18px; color: var(--accent); letter-spacing: 1px; }
.sys-sub { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 2px; color: var(--text-faint); margin-top: 2px; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 16px;
  padding: 0 22px; border-bottom: 1px solid var(--glass-border);
  background: rgba(7,11,18,0.6); backdrop-filter: blur(10px); z-index: 30;
}
.topbar-title { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: 3px; color: var(--text); }
.topbar-stats { display: flex; gap: 16px; margin-left: 14px; flex: 1; overflow: hidden; min-width: 0; }
@media (max-width: 1280px) { .topbar-stats .tb-stat:nth-child(n+3) { display: none; } }
@media (max-width: 1080px) { .topbar-stats { display: none; } }
.tb-stat { display: flex; flex-direction: column; line-height: 1.1; }
.tb-stat .k { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px; color: var(--text-faint); text-transform: uppercase; }
.tb-stat .v { font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--text); }
.tb-stat .v.good { color: var(--good); } .tb-stat .v.bad { color: var(--bad); } .tb-stat .v.warn { color: var(--warn); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.view-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; scroll-behavior: smooth; }
.view { padding: 24px; max-width: 1500px; margin: 0 auto; }
.app-foot { text-align: center; padding: 18px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.5px; color: var(--text-faint); }

/* ---------- Buttons ---------- */
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; flex: none;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  color: var(--text-dim); transition: all 0.15s var(--ease);
}
.icon-btn:hover { color: var(--accent); border-color: var(--glass-border-hot); box-shadow: var(--shadow-glow); }
.ghost-btn {
  height: 36px; padding: 0 14px; background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); color: var(--text-dim); font-family: var(--font-head);
  font-size: 11.5px; letter-spacing: 2px; font-weight: 600; transition: all 0.15s var(--ease);
  display: inline-flex; align-items: center; gap: 7px; text-transform: uppercase;
}
.ghost-btn:hover { color: var(--accent); border-color: var(--glass-border-hot); box-shadow: var(--shadow-glow); }
.ghost-btn.accent { color: var(--accent); border-color: var(--glass-border-hot); background: rgba(0,229,255,0.06); }
.ghost-btn .cap-plus { font-size: 15px; line-height: 0; font-weight: 700; }
.ghost-btn kbd { font-family: var(--font-mono); font-size: 9px; padding: 2px 5px; border: 1px solid var(--glass-border); border-radius: 5px; color: var(--text-faint); letter-spacing: 0; }
.icon-btn.on { color: var(--accent); border-color: var(--glass-border-hot); box-shadow: var(--shadow-glow); }
.mobile-menu { display: none; }
@media (max-width: 880px) { .ghost-btn kbd { display: none; } #btn-brief, #btn-audit { display: none; } }

@media (max-width: 880px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform 0.25s var(--ease); }
  .sidebar.open { transform: translateX(0); box-shadow: 30px 0 60px -20px #000; }
  .mobile-menu { display: grid; }
  .sidebar-toggle { display: none; }
  .view { padding: 16px; }
  .topbar { padding: 0 14px; }
  .topbar-stats { display: none; }
}

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35; backdrop-filter: blur(2px); }
@media (min-width: 881px) { .scrim { display: none; } }

[hidden] { display: none !important; }
