:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d7dee8;
  --accent: #0f766e;
  --accent-hover: #0d9488;
  --accent-soft: #ccfbf1;
  --danger: #b91c1c;
  --ok: #15803d;
  --sidebar-w: 264px;
  --sidebar-bg: #0b1f2a;
  --sidebar-text: #c5d4de;
  --sidebar-active: #14b8a6;
  --topbar-h: 64px;
  --tab-h: 64px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-display: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sx-icon { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; display: block; }

/* ——— Shell Synapti (desktop-first) ——— */
.sx-app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sx-sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
  background: linear-gradient(180deg, #0b1f2a 0%, #102a38 55%, #0b1f2a 100%);
  color: var(--sidebar-text);
  border-right: 1px solid #163445;
  padding: 1rem 0.75rem 1.5rem;
  z-index: 50;
}
.sx-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.55rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.75rem;
}
.sx-sidebar__mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(20, 184, 166, 0.15);
  color: var(--sidebar-active);
  display: grid; place-items: center;
}
.sx-sidebar__mark .sx-icon { width: 1.35rem; height: 1.35rem; }
.sx-sidebar__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: #fff;
  text-transform: uppercase;
}
.sx-sidebar__tag { font-size: 0.72rem; color: #7f96a6; }

.sx-nav-group { margin: 0.55rem 0 0.85rem; }
.sx-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d8494;
  padding: 0.35rem 0.65rem;
}
.sx-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 40px;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none !important;
  font-size: 0.92rem;
  font-weight: 500;
}
.sx-nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sx-nav-link.active {
  background: rgba(20, 184, 166, 0.16);
  color: #5eead4;
  font-weight: 600;
}

.sx-workspace { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.sx-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1.5rem;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.sx-menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 42px; height: 42px;
  align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
}
.sx-topbar__crumb {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.sx-topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sx-topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sx-user { font-size: 0.85rem; color: var(--muted); font-weight: 500; }

.sx-main {
  padding: 1.25rem 1.5rem 2rem;
  width: 100%;
  max-width: 1280px;
}
.sx-sidebar-backdrop { display: none; }

/* Tab bar solo mobile */
.tabbar { display: none; }

@media (max-width: 960px) {
  .sx-app { grid-template-columns: 1fr; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); }
  .sx-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sx-sidebar.is-open { transform: translateX(0); }
  .sx-menu-btn { display: inline-flex; }
  .sx-sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 40;
  }
  .sx-main { padding: 1rem; max-width: none; }
  .tabbar {
    display: grid;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255,255,255,0.97);
    border-top: 1px solid var(--border);
    grid-template-columns: repeat(5, 1fr);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    text-decoration: none;
    min-height: var(--tab-h);
  }
  .tabbar a.active { color: var(--accent); }
  .tabbar .sx-icon { width: 1.25rem; height: 1.25rem; }
}

/* ——— Components ——— */
.flash-wrap { margin: 0 0 1rem; }
.flash {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}
.flash-success { background: #dcfce7; color: var(--ok); }
.flash-error { background: #fee2e2; color: var(--danger); }
.flash-info { background: #e0f2fe; color: #075985; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.panel__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}
.panel__body { padding: 1rem; }

/* legacy card alias */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 0.85rem;
}
.card h2, .card h3 { margin: 0 0 0.65rem; font-size: 1rem; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat .n {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.stat .l { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none !important;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; }

.workspace-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
}
@media (max-width: 960px) {
  .workspace-grid { grid-template-columns: 1fr; }
}

.module-soon {
  border: 1px dashed #94a3b8;
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: left;
}
.module-soon h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.module-soon p { margin: 0 0 0.75rem; color: var(--muted); max-width: 42rem; }
.module-soon .badge { margin-bottom: 0.75rem; }

label { display: block; font-size: 0.82rem; font-weight: 600; margin: 0.65rem 0 0.25rem; color: #334155; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}
textarea { min-height: 100px; resize: vertical; }
.muted { color: var(--muted); font-size: 0.85rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}
.list li:last-child { border-bottom: none; }
.list a { color: var(--text); font-weight: 600; text-decoration: none; }
.list .meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
}
.badge-ok { background: #dcfce7; color: var(--ok); }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-wa { background: #d1fae5; color: #047857; }
.badge-soon { background: #e2e8f0; color: #475569; }

.pipeline {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 900px) {
  .pipeline { grid-template-columns: repeat(4, 1fr); }
}
.pipeline-col {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem;
  min-height: 140px;
}
.pipeline-col h3 { margin: 0 0 0.5rem; font-size: 0.85rem; }
.pipe-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at top left, rgba(20,184,166,0.18), transparent 50%),
    linear-gradient(135deg, #0b1f2a 0%, #123044 45%, #0f766e 160%);
}
.login-card {
  width: min(100%, 420px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
}
.login-card .brand-hero {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0 0 0.35rem;
  color: #0b1f2a;
  text-transform: uppercase;
}
.login-card .brand-tagline {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.toolbar input, .toolbar select { flex: 1 1 140px; }

.completed { opacity: 0.55; text-decoration: line-through; }
code { font-size: 0.85em; background: #f1f5f9; padding: 0.1rem 0.3rem; border-radius: 4px; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}
@media (min-width: 700px) {
  .quick-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none !important;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 48px;
}
.quick-link:hover { border-color: #99f6e4; background: #f0fdfa; }
.quick-link .sx-icon { color: var(--accent); }
.quick-link small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.72rem;
}
