/* ============================================
   SJG Operating System — app shell
   Same premium-disruptor DNA, dense product UI
   ============================================ */

:root {
  --bg:         #07070C;
  --bg-soft:    #0C0C16;
  --panel:      #0E0E1A;
  --sidebar:    #090910;
  --surface:    rgba(255,255,255,0.025);
  --surface-2:  rgba(255,255,255,0.05);
  --border:     rgba(255,255,255,0.08);
  --border-2:   rgba(255,255,255,0.14);
  --text:       #ECECF4;
  --muted:      #9A9AB2;
  --faint:      #62627A;
  --accent:     #4D7CFF;
  --accent-2:   #9B6CFF;
  --accent-cy:  #38E1FF;
  --green:      #4ade80;
  --amber:      #fbbf24;
  --glow:       rgba(77,124,255,0.45);
  --grad:       linear-gradient(100deg, #6E9BFF 0%, #9B6CFF 50%, #38E1FF 100%);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
  --radius: 14px;
}

* { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }
body { font-family:var(--font-body); background:var(--bg); color:var(--text); -webkit-font-smoothing:antialiased; }
button { font-family:inherit; cursor:pointer; }

.glass { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); }

/* ---------- Buttons ---------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; font-family:var(--font-display); font-weight:600; font-size:15px; padding:13px 22px; border-radius:11px; border:1px solid transparent; transition:.2s; }
.btn--primary { background:var(--grad); color:#07070C; box-shadow:0 8px 30px -8px var(--glow); }
.btn--primary:hover { transform:translateY(-2px); }
.btn--block { width:100%; }

/* ============ LOGIN ============ */
.login { position:fixed; inset:0; display:grid; place-items:center; padding:24px; }
.login__bg { position:absolute; inset:0; z-index:-1;
  background:
    radial-gradient(600px circle at 30% 20%, rgba(77,124,255,0.25), transparent 60%),
    radial-gradient(600px circle at 70% 80%, rgba(155,108,255,0.2), transparent 60%);
  background-color:var(--bg); }
.login__bg::after { content:''; position:absolute; inset:0;
  background-image:linear-gradient(rgba(255,255,255,.03) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.03) 1px,transparent 1px);
  background-size:56px 56px; mask-image:radial-gradient(ellipse 70% 70% at 50% 50%,#000,transparent 75%); }
.login__card { width:100%; max-width:420px; padding:44px 40px; text-align:center; backdrop-filter:blur(16px); }
.login__logo { height:38px; margin:0 auto 26px; }
.login__title { font-family:var(--font-display); font-size:25px; font-weight:700; }
.login__sub { color:var(--muted); margin:8px 0 30px; font-size:15px; }
.login__form { display:flex; flex-direction:column; gap:16px; text-align:left; }
.login__form label { display:flex; flex-direction:column; gap:7px; font-size:13px; color:var(--muted); }
.login__form input { background:var(--bg-soft); border:1px solid var(--border-2); border-radius:10px; padding:13px 14px; color:var(--text); font-size:15px; font-family:inherit; }
.login__form input:focus { outline:none; border-color:var(--accent); }
.login__form .btn { margin-top:8px; }
.login__error { color:#ff6b6b; font-size:13px; margin:-4px 0 -2px; }
.login__demo { color:var(--faint); font-size:13px; margin-top:18px; }

/* ============ APP SHELL ============ */
[hidden] { display:none !important; }
.app { display:grid; grid-template-columns:248px 1fr; min-height:100vh; }

/* ---------- Sidebar ---------- */
.sidebar { background:var(--sidebar); border-right:1px solid var(--border); display:flex; flex-direction:column; padding:22px 16px; position:sticky; top:0; height:100vh; }
.sidebar__brand img { height:30px; margin:6px 8px 26px; }
.sidebar__nav { display:flex; flex-direction:column; gap:4px; flex:1; }
.navitem { display:flex; align-items:center; gap:12px; width:100%; text-align:left; background:none; border:none; color:var(--muted); font-size:14.5px; padding:11px 13px; border-radius:10px; transition:.18s; }
.navitem:hover { background:var(--surface-2); color:var(--text); }
.navitem.active { background:linear-gradient(100deg, rgba(77,124,255,.16), rgba(155,108,255,.1)); color:var(--text); border:1px solid rgba(77,124,255,.28); }
.navitem__ico { font-size:15px; width:18px; text-align:center; color:var(--accent-cy); }
.badge { margin-left:auto; background:var(--grad); color:#07070C; font-size:11px; font-weight:700; padding:2px 8px; border-radius:100px; }
.sidebar__foot { border-top:1px solid var(--border); padding-top:16px; margin-top:8px; }
.userchip { display:flex; align-items:center; gap:11px; padding:6px 8px; }
.userchip__avatar { width:38px; height:38px; border-radius:10px; background:var(--grad); color:#07070C; font-family:var(--font-display); font-weight:700; display:grid; place-items:center; font-size:14px; }
.userchip__meta { display:flex; flex-direction:column; line-height:1.3; }
.userchip__meta strong { font-size:14px; }
.userchip__meta small { font-size:12px; color:var(--faint); }

/* ---------- Main / Topbar ---------- */
.main { display:flex; flex-direction:column; min-width:0; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:20px 32px; border-bottom:1px solid var(--border); position:sticky; top:0; background:rgba(7,7,12,.8); backdrop-filter:blur(14px); z-index:20; }
.topbar__title h1 { font-family:var(--font-display); font-size:22px; font-weight:600; }
.topbar__title p { color:var(--faint); font-size:13px; margin-top:3px; }
.topbar__actions { display:flex; align-items:center; gap:14px; }
.search { display:flex; align-items:center; gap:9px; background:var(--bg-soft); border:1px solid var(--border); border-radius:10px; padding:9px 14px; color:var(--muted); }
.search input { background:none; border:none; outline:none; color:var(--text); font-size:14px; font-family:inherit; width:200px; }
.autonomous { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--accent-cy); border:1px solid rgba(56,225,255,.25); background:rgba(56,225,255,.06); padding:8px 13px; border-radius:100px; }
.autonomous i { width:8px; height:8px; border-radius:50%; background:var(--accent-cy); box-shadow:0 0 8px var(--accent-cy); animation:pulse 1.8s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.iconbtn { position:relative; background:var(--bg-soft); border:1px solid var(--border); width:40px; height:40px; border-radius:10px; color:var(--muted); font-size:16px; }
.iconbtn .dot { position:absolute; top:9px; right:10px; width:7px; height:7px; border-radius:50%; background:var(--accent); }

/* ---------- Viewport / views ---------- */
.viewport { padding:28px 32px 48px; }
.view { display:none; animation:fade .4s ease; }
.view.active { display:block; }
@keyframes fade { from{opacity:0; transform:translateY(10px)} to{opacity:1; transform:translateY(0)} }
.view__lead { color:var(--muted); font-size:15px; margin-bottom:22px; max-width:680px; }

/* ---------- KPIs ---------- */
.kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:18px; margin-bottom:22px; }
.kpi { padding:22px; display:flex; flex-direction:column; gap:7px; }
.kpi__label { font-size:12px; color:var(--faint); text-transform:uppercase; letter-spacing:.04em; }
.kpi__val { font-family:var(--font-display); font-size:30px; font-weight:600; }
.kpi__delta { font-size:12.5px; color:var(--muted); }
.kpi__delta.up { color:var(--green); }

/* ---------- Panels / grids ---------- */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:18px; margin-bottom:22px; }
.panel { padding:22px; }
.panel__head { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.panel__head h3 { font-family:var(--font-display); font-size:16px; font-weight:600; }
.panel__tag { font-size:12px; color:var(--faint); border:1px solid var(--border); padding:3px 10px; border-radius:100px; }
.panel__tag.pulse { display:inline-flex; align-items:center; gap:6px; color:var(--accent-cy); }
.panel__tag.pulse i { width:6px; height:6px; border-radius:50%; background:var(--accent-cy); animation:pulse 1.6s infinite; }

/* ---------- Chart ---------- */
.chart { display:flex; align-items:flex-end; gap:14px; height:180px; padding-top:10px; }
.bar { flex:1; height:var(--h); background:linear-gradient(180deg, rgba(77,124,255,.5), rgba(77,124,255,.08)); border:1px solid rgba(77,124,255,.3); border-radius:8px 8px 0 0; position:relative; display:flex; align-items:flex-end; justify-content:center; transition:height .8s cubic-bezier(.2,.8,.2,1); }
.bar span { position:absolute; bottom:-24px; font-size:12px; color:var(--faint); }
.bar--active { background:var(--grad); border:none; box-shadow:0 0 24px -4px var(--glow); }

/* ---------- Activity ---------- */
.activity { display:flex; flex-direction:column; gap:15px; }
.act { display:flex; gap:13px; align-items:flex-start; }
.act div { display:flex; flex-direction:column; font-size:14px; }
.act small { color:var(--faint); font-size:12px; margin-top:2px; }
.act__tag { font-size:10px; font-weight:700; padding:4px 8px; border-radius:6px; letter-spacing:.04em; flex-shrink:0; }
.act__tag.green { background:rgba(74,222,128,.15); color:var(--green); }
.act__tag.blue { background:rgba(77,124,255,.18); color:#7fa0ff; }
.act__tag.violet { background:rgba(155,108,255,.18); color:#c0a3ff; }
.act__tag.amber { background:rgba(251,191,36,.16); color:var(--amber); }

/* ---------- Tasks ---------- */
.tasklist { display:flex; flex-direction:column; gap:2px; }
.task { display:flex; align-items:center; gap:13px; padding:13px 6px; border-bottom:1px solid var(--border); font-size:14px; }
.task:last-child { border-bottom:none; }
.task input { width:17px; height:17px; accent-color:var(--accent); }
.task span { flex:1; color:var(--text); }
.task input:checked + span { color:var(--faint); text-decoration:line-through; }
.due { font-size:12px; color:var(--amber); }
.due.done { color:var(--green); }

/* ---------- Pipeline (Applications) ---------- */
.apps__bar { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.apps__source { font-size:12.5px; color:var(--amber); }
.apps__source.live { color:var(--accent-cy); }
.apps__refresh { background:var(--bg-soft); border:1px solid var(--border); color:var(--muted); font-size:13px; padding:8px 14px; border-radius:9px; transition:.18s; }
.apps__refresh:hover { color:var(--text); border-color:var(--accent); }
.pipeline__empty { text-align:center; color:var(--faint); font-size:14px; padding:40px 0; }
.pcol__cards { display:flex; flex-direction:column; gap:12px; }
.pipeline { display:grid; grid-template-columns:repeat(5,1fr); gap:14px; align-items:start; }
.pcol { display:flex; flex-direction:column; gap:12px; }
.pcol__head { font-size:13px; color:var(--muted); padding:6px 4px; display:flex; }
.pcol__head b { margin-left:6px; color:var(--faint); }
.lead { padding:15px; }
.lead__top { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:8px; }
.lead__top strong { font-size:14px; }
.src { font-size:10px; color:var(--faint); border:1px solid var(--border); padding:2px 7px; border-radius:100px; flex-shrink:0; }
.lead p { font-size:12.5px; color:var(--muted); margin-bottom:12px; line-height:1.5; }
.lead__meta { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12px; color:var(--faint); }
.chip { font-size:11px; font-weight:600; padding:3px 9px; border-radius:100px; }
.chip.hot { background:rgba(74,222,128,.14); color:var(--green); }
.chip.warm { background:rgba(251,191,36,.14); color:var(--amber); }
.chip.win { background:var(--grad); color:#07070C; }
.lead.won { border-color:rgba(74,222,128,.3); }

/* ---------- Clients table ---------- */
.tablewrap { overflow-x:auto; }
.dtable { width:100%; border-collapse:collapse; font-size:14px; min-width:760px; }
.dtable th { text-align:left; font-size:12px; text-transform:uppercase; letter-spacing:.04em; color:var(--faint); font-weight:500; padding:16px 18px; border-bottom:1px solid var(--border); }
.dtable td { padding:16px 18px; border-bottom:1px solid var(--border); vertical-align:middle; }
.dtable tr:last-child td { border-bottom:none; }
.dtable tbody tr:hover { background:var(--surface); }
.dtable td small { display:block; color:var(--faint); font-size:12px; margin-top:3px; }
.tier-pill { font-size:11.5px; font-weight:600; padding:4px 10px; border-radius:100px; white-space:nowrap; }
.tier-pill.mgmt { background:rgba(155,108,255,.16); color:#c0a3ff; }
.tier-pill.full { background:rgba(77,124,255,.16); color:#7fa0ff; }
.tier-pill.os   { background:rgba(56,225,255,.12); color:var(--accent-cy); }
.tier-pill.web  { background:var(--surface-2); color:var(--muted); }
.prog { width:90px; height:6px; background:var(--surface-2); border-radius:100px; margin-bottom:5px; overflow:hidden; }
.prog i { display:block; height:100%; background:var(--grad); border-radius:100px; }
.health { font-size:10px; }
.health.good { color:var(--green); }
.health.warn { color:var(--amber); }
.st { font-size:11.5px; font-weight:600; padding:4px 11px; border-radius:100px; white-space:nowrap; }
.st.auto { background:rgba(56,225,255,.12); color:var(--accent-cy); }
.st.build { background:rgba(251,191,36,.14); color:var(--amber); }
.st.done { background:var(--surface-2); color:var(--muted); }
.st.warn { background:rgba(251,191,36,.16); color:var(--amber); }

/* ---------- Delivery board ---------- */
.board { display:grid; grid-template-columns:repeat(5,1fr); gap:14px; align-items:start; }
.bcol { display:flex; flex-direction:column; gap:12px; }
.bcol__head { font-size:13px; color:var(--muted); padding:6px 4px; }
.bcol__head b { color:var(--faint); margin-left:5px; }
.bcard { padding:15px; }
.bcard strong { font-size:14px; }
.bcard p { font-size:12.5px; color:var(--muted); margin:7px 0 13px; }
.bcard__foot { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:11.5px; }
.ag { color:var(--accent-cy); }
.ag.human { color:var(--amber); }
.ag.auto { color:var(--green); }
.pct { color:var(--faint); font-weight:600; }
.bcard.hl { border-color:rgba(251,191,36,.35); background:rgba(251,191,36,.05); }
.bcard.done { opacity:.7; }

/* ---------- Revenue breakdown ---------- */
.breakdown { display:flex; flex-direction:column; gap:18px; padding-top:4px; }
.brk { display:grid; grid-template-columns:130px 1fr 70px; align-items:center; gap:14px; font-size:13.5px; }
.brk span { color:var(--muted); }
.brk b { text-align:right; font-family:var(--font-display); }
.brk__bar { height:9px; background:var(--surface-2); border-radius:100px; overflow:hidden; }
.brk__bar i { display:block; height:100%; background:var(--grad); border-radius:100px; }

/* ---------- Agents ---------- */
.agents { display:grid; grid-template-columns:repeat(3,1fr); gap:18px; }
.agent { padding:22px; }
.agent__head { display:flex; align-items:center; gap:13px; margin-bottom:18px; }
.agent__head > div { flex:1; display:flex; flex-direction:column; }
.agent__head strong { font-size:15px; }
.agent__head small { font-size:12.5px; color:var(--faint); margin-top:2px; }
.agent__ico { width:42px; height:42px; border-radius:11px; background:var(--surface-2); border:1px solid var(--border); display:grid; place-items:center; color:var(--accent-cy); font-size:18px; flex-shrink:0; }
.agent__stats { display:flex; justify-content:space-between; gap:8px; border-top:1px solid var(--border); padding-top:15px; font-size:12px; color:var(--faint); text-align:center; }
.agent__stats span { display:flex; flex-direction:column-reverse; gap:3px; flex:1; }
.agent__stats b { font-family:var(--font-display); font-size:17px; color:var(--text); }

/* ---------- Responsive ---------- */
@media (max-width:1080px){ .kpis{grid-template-columns:repeat(2,1fr)} .grid-2{grid-template-columns:1fr} .agents{grid-template-columns:1fr 1fr} .pipeline,.board{grid-template-columns:repeat(3,1fr)} }
@media (max-width:760px){
  .app{grid-template-columns:1fr}
  .sidebar{position:fixed; bottom:0; top:auto; height:auto; width:100%; flex-direction:row; padding:8px; border-right:none; border-top:1px solid var(--border); z-index:50; }
  .sidebar__brand,.sidebar__foot{display:none}
  .sidebar__nav{flex-direction:row; gap:2px; overflow-x:auto}
  .navitem{flex-direction:column; gap:4px; font-size:10px; padding:8px 6px; white-space:nowrap}
  .navitem .badge{display:none}
  .viewport{padding:20px 16px 90px}
  .topbar{padding:16px}
  .search,.autonomous{display:none}
  .kpis{grid-template-columns:1fr 1fr; gap:12px}
  .agents{grid-template-columns:1fr}
  .pipeline,.board{grid-template-columns:1fr; }
}
