/* LaunchpadOS — Design System v2 (warm light theme) */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --brand:     #534AB7;
  --brand-d:   #3C3489;
  --brand-l:   #EEEDFE;
  --brand-m:   #AFA9EC;

  --bg:        #F7F6F2;
  --surface:   #ffffff;
  --surface2:  #F1EFE8;
  --surface3:  #ECEAE3;

  --border:    rgba(0,0,0,0.07);
  --border-m:  rgba(0,0,0,0.12);

  --text:      #1A1917;
  --text2:     #6B6963;
  --text3:     #9E9B94;

  --green:     #1D9E75;
  --gbg:       #E1F5EE;
  --amber:     #BA7517;
  --abg:       #FAEEDA;
  --red:       #C0392B;
  --rbg:       #FAECE7;
  --blue:      #185FA5;
  --bbg:       #E6F1FB;

  --radius:    10px;
  --sidebar-w: 212px;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
input, select, textarea, button { font: inherit; border: none; outline: none; }
button { cursor: pointer; background: none; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-m); border-radius: 2px; }

/* ── App shell ── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid rgba(0,0,0,0.09);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-top {
  padding: 18px 14px 14px;
  border-bottom: 0.5px solid var(--border);
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo-mark {
  width: 30px; height: 30px;
  background: var(--brand);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px; padding: 6px;
  flex-shrink: 0;
}
.logo-mark span { background: white; border-radius: 1.5px; }
.logo-mark span:nth-child(2) { opacity: .6; }
.logo-mark span:nth-child(3) { opacity: .6; }
.logo-mark span:nth-child(4) { opacity: .3; }
.logo-text { font-size: 14px; font-weight: 600; letter-spacing: -.3px; }
.logo-text em { color: var(--brand); font-style: normal; }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-group-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text3); padding: 10px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; color: var(--text2);
  transition: all .12s; margin-bottom: 1px;
  width: 100%; font-size: 13px; text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--brand-l); color: var(--brand); font-weight: 500; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .65; }
.nav-item.active svg { opacity: 1; }
.nav-item.soon { opacity: .38; cursor: default; pointer-events: none; }
.nav-badge {
  margin-left: auto; background: var(--red); color: white;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.nav-badge-a {
  margin-left: auto; background: var(--abg); color: var(--amber);
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 20px;
}

.sidebar-foot { padding: 12px 8px; border-top: 0.5px solid var(--border); }
.brand-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; background: var(--surface2);
  border-radius: 8px; cursor: pointer;
}
.brand-pill:hover { background: var(--surface3); }
.b-avatar {
  width: 28px; height: 28px; background: var(--brand);
  border-radius: 7px; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700;
  color: white; flex-shrink: 0;
}
.b-name  { font-size: 12px; font-weight: 500; }
.b-plan  { font-size: 10px; color: var(--text3); }
.live-bar {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px 0; font-size: 10px; color: var(--text3);
}
.live-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--green); animation: blink 2s infinite;
  display: inline-block;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Main content ── */
.main-content { display: flex; flex-direction: column; overflow: hidden; }

/* ── Topbar ── */
.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid rgba(0,0,0,0.09);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title  { font-size: 16px; font-weight: 600; letter-spacing: -.3px; }
.page-sub    { font-size: 12px; color: var(--text3); display: flex; align-items: center; gap: 5px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Page ── */
.page { flex: 1; overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.page-header { display: flex; align-items: center; justify-content: space-between; }
.page-title-lg { font-size: 16px; font-weight: 600; letter-spacing: -.3px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: 7px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .12s; border: none;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-d); }
.btn-ghost {
  background: transparent; color: var(--text2);
  border: 0.5px solid var(--border-m);
}
.btn-ghost:hover { background: var(--surface2); }
.btn:disabled { opacity: .45; cursor: default; }

/* ── Metrics grid ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.metric {
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.09);
  border-radius: 11px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.metric-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); margin-bottom: 8px; }
.metric-val   { font-size: 24px; font-weight: 600; letter-spacing: -.5px; line-height: 1; margin-bottom: 5px; }
.metric-delta { font-size: 11px; display: flex; align-items: center; gap: 3px; }
.dg { color: var(--green); }
.dr { color: var(--red); }
.da { color: var(--amber); }
.db { color: var(--text3); }

/* ── Panel ── */
.panel {
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.09);
  border-radius: 11px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 0.5px solid var(--border);
}
.panel-title { font-size: 13px; font-weight: 600; }
.panel-sub   { font-size: 11px; color: var(--text3); margin-top: 1px; }
.panel-body     { padding: 0 16px; }
.panel-body-pad { padding: 16px; }
.row { display: grid; gap: 12px; }

/* ── Table ── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text3); padding: 9px 12px;
  text-align: left; border-bottom: 0.5px solid var(--border);
}
.tbl td {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border);
  color: var(--text);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover td { background: var(--surface2); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.bg  { background: var(--gbg);    color: var(--green); }
.ba  { background: var(--abg);    color: var(--amber); }
.br  { background: var(--rbg);    color: var(--red);   }
.bp  { background: var(--brand-l);color: var(--brand-d); }
.bgr { background: var(--surface2); color: var(--text2); }
.bb  { background: var(--bbg);    color: var(--blue);  }

/* ── Mono ── */
.mono { font-family: 'DM Mono', monospace; font-size: 12px; }

/* ── Filter bar ── */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 0.5px solid var(--border);
  flex-wrap: wrap;
}
.filter-select {
  padding: 6px 10px; border: 0.5px solid var(--border-m);
  border-radius: 7px; font-size: 12px;
  background: var(--surface); color: var(--text);
  cursor: pointer;
}
.filter-select:focus { border-color: var(--brand); outline: none; }
.filter-label { font-size: 11px; font-weight: 500; color: var(--text3); }
.filter-input {
  padding: 6px 10px; border: 0.5px solid var(--border-m);
  border-radius: 7px; font-size: 12px;
  background: var(--surface); color: var(--text);
  flex: 1; min-width: 180px;
}
.filter-input:focus { border-color: var(--brand); outline: none; }
.filter-spacer { flex: 1; }

/* ── Form ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 11px; font-weight: 500; color: var(--text2); }
.form-input {
  padding: 8px 11px; border: 0.5px solid var(--border-m);
  border-radius: 7px; font-size: 13px;
  background: var(--surface); color: var(--text);
  transition: border-color .12s; width: 100%;
}
.form-input:focus { border-color: var(--brand); outline: none; }
.form-select {
  padding: 8px 11px; border: 0.5px solid var(--border-m);
  border-radius: 7px; font-size: 13px;
  background: var(--surface); color: var(--text);
  cursor: pointer; width: 100%;
}
.form-footer {
  padding: 12px 16px; border-top: 0.5px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.25);
  z-index: 1000; display: flex; align-items: center;
  justify-content: center; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: 14px;
  width: 480px; max-height: 80vh; overflow-y: auto;
  border: 0.5px solid var(--border-m);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 0.5px solid var(--border);
}
.modal-title  { font-size: 14px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: 0.5px solid var(--border-m); background: transparent;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: var(--text2);
}
.modal-close:hover { background: var(--surface2); }
.modal-body { padding: 20px; }
.modal-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 0.5px solid var(--border); font-size: 13px;
}
.modal-row:last-child { border-bottom: none; }
.modal-key { color: var(--text3); font-size: 12px; }
.modal-val { font-weight: 500; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: white;
  padding: 10px 18px; border-radius: 9px;
  font-size: 13px; font-weight: 500; z-index: 2000;
  transform: translateY(80px); opacity: 0;
  transition: all .25s; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Pagination ── */
.pagination {
  display: flex; gap: 8px; align-items: center;
  justify-content: flex-end; padding: 12px 16px;
  border-top: 0.5px solid var(--border);
}
.pagination button {
  padding: 5px 12px; border: 0.5px solid var(--border-m);
  border-radius: 6px; font-size: 12px; color: var(--text2);
  background: var(--surface); cursor: pointer;
}
.pagination button:hover { background: var(--surface2); }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination .page-info { font-size: 11px; color: var(--text3); }

/* ── Utilities ── */
.text-muted { color: var(--text3); }
.text-right { text-align: right; }
.empty { text-align: center; padding: 40px; color: var(--text3); font-size: 13px; }

/* ════════════════════════════════════════════════════════════
   MOBILE / APP-LIKE RESPONSIVE LAYER
   ════════════════════════════════════════════════════════════ */
.lp-hamburger { display:none; }
.lp-bottom-nav { display:none; }
.sb-backdrop { display:none; }

@media (max-width: 860px) {
  /* Single column shell */
  .app-shell { grid-template-columns: 1fr !important; }

  /* Sidebar becomes off-canvas drawer */
  #sidebar {
    position: fixed !important; left: 0; top: 0; bottom: 0;
    width: 264px !important; z-index: 300;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 4px 0 28px rgba(0,0,0,.18);
  }
  body.sb-open #sidebar { transform: translateX(0); }
  .sb-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 299; }
  body.sb-open .sb-backdrop { display: block; }

  /* Floating hamburger */
  .lp-hamburger {
    display: flex; position: fixed; top: 9px; left: 12px; z-index: 120;
    width: 36px; height: 36px; border-radius: 9px; border: 1px solid rgba(0,0,0,.1);
    background: var(--surface); align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.08);
  }
  .lp-hamburger svg { width: 18px; height: 18px; }

  /* Make room for hamburger in page topbars */
  .topbar { padding-left: 56px !important; }

  /* Content breathing room for bottom nav */
  .main-content { padding-bottom: 64px; }

  /* Responsive grids — collapse multi-column layouts */
  .metrics, .kpi-grid, .quad-grid, .score-grid, .num-grid,
  .features-grid, .feat-grid, .channels-grid, .cat-grid,
  .scenarios, .quad-grid, .recon-summary { grid-template-columns: 1fr 1fr !important; }
  .sim-grid, .builder, .comm-layout, .overview-grid { grid-template-columns: 1fr !important; }
  .row, .quad-grid[style], [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns:repeat(4"], [style*="grid-template-columns:repeat(5"] { grid-template-columns: 1fr 1fr !important; }

  /* Wide tables scroll horizontally */
  .panel, .table-wrap { overflow-x: auto; }
  table { min-width: 560px; }

  /* Slide-in panels go full width */
  .detail-panel, .drawer { width: 100% !important; }

  /* Modals fit screen */
  .modal { width: 94vw !important; max-width: 94vw !important; }

  /* Segment / page tabs scroll */
  .seg-tabs, .page-tabs, .fin-tabs, .status-tabs, .journey-bar, .source-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Hide desktop sidebar footer chevron noise */
  .topbar-right { gap: 6px; flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .metrics, .kpi-grid, .quad-grid, .score-grid, .num-grid,
  .features-grid, .feat-grid, .channels-grid, .scenarios { grid-template-columns: 1fr !important; }
  .page-title { font-size: 15px; }
  .topbar-right .btn { font-size: 11px; padding: 6px 10px; }

  /* App-like bottom tab bar */
  .lp-bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 130;
    background: var(--surface); border-top: 1px solid rgba(0,0,0,.1);
    height: 58px; box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }
  .lp-bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--text3); text-decoration: none; font-size: 9px; font-weight: 600;
  }
  .lp-bn-item.active { color: var(--brand); }
  .lp-bn-item svg { width: 19px; height: 19px; }
}
