/* ============================================================
   SDIP — DESIGN SYSTEM
   Palette: deep forest + growth-ring signature motif.
   Display: Fraunces · Body: Inter · Data: IBM Plex Mono
   ============================================================ */

:root {
  --teal: #3AAFA9;
  --teal-light: #5EEAD4;
  --gold: #F5B942;
  --coral: #F2665E;
  --violet: #7C83FD;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 60px -20px rgba(0,0,0,0.45);
  --ease: cubic-bezier(.16,1,.3,1);
}

[data-theme="dark"] {
  --bg: #0A1210;
  --bg-grad: radial-gradient(circle at 15% 0%, #10221E 0%, #0A1210 55%);
  --surface: rgba(255,255,255,0.045);
  --surface-solid: #101C19;
  --surface-hover: rgba(255,255,255,0.075);
  --border: rgba(255,255,255,0.09);
  --text: #EAF2EF;
  --text-muted: #8FA69F;
  --text-dim: #607169;
  --sidebar: rgba(9,17,15,0.85);
}

[data-theme="light"] {
  --bg: #F5F7F2;
  --bg-grad: radial-gradient(circle at 15% 0%, #FFFFFF 0%, #F0F3EC 55%);
  --surface: rgba(255,255,255,0.72);
  --surface-solid: #FFFFFF;
  --surface-hover: rgba(255,255,255,0.95);
  --border: rgba(20,35,31,0.09);
  --text: #12211D;
  --text-muted: #5C6E68;
  --text-dim: #8B9994;
  --sidebar: rgba(255,255,255,0.85);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg-grad), var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
  transition: background .4s var(--ease), color .4s var(--ease);
  -webkit-font-smoothing: antialiased;
}
.display { font-family: 'Fraunces', serif; }
.mono { font-family: 'IBM Plex Mono', monospace; }
:focus-visible { outline: 2px solid var(--teal-light); outline-offset: 2px; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; }

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- utility ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card { padding: 22px; transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(58,175,169,0.35); }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.grid { display: grid; gap: 18px; }
.muted { color: var(--text-muted); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
  border-radius: 100px; font-size: 12px; font-weight: 600; border: 1px solid var(--border);
}
.badge-high { background: rgba(242,102,94,0.14); color: var(--coral); }
.badge-medium { background: rgba(245,185,66,0.16); color: var(--gold); }
.badge-low { background: rgba(58,175,169,0.16); color: var(--teal-light); }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#loginScreen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column;
  padding: 40px 20px; position: relative; overflow: hidden;
}
.login-orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; z-index: 0; }
.orb1 { width: 420px; height: 420px; background: var(--teal); top: -120px; left: -100px; }
.orb2 { width: 380px; height: 380px; background: var(--violet); bottom: -140px; right: -80px; }
.login-brand { text-align: center; margin-bottom: 40px; z-index: 1; }
.login-brand .mark { font-size: 42px; }
.login-brand h1 { font-size: 34px; font-weight: 600; margin: 10px 0 6px; letter-spacing: -0.5px; }
.login-brand p { color: var(--text-muted); font-size: 15px; }
.role-grid { display: grid; grid-template-columns: repeat(4, 220px); gap: 20px; z-index: 1; }
@media (max-width: 980px) { .role-grid { grid-template-columns: repeat(2, 1fr); width: 100%; max-width: 480px; } }
.role-card {
  padding: 26px 20px; text-align: center; cursor: pointer;
  transition: all .35s var(--ease);
}
.role-card:hover { transform: translateY(-6px) scale(1.02); border-color: var(--teal); box-shadow: 0 25px 50px -20px rgba(58,175,169,.35); }
.role-card .icon { font-size: 30px; margin-bottom: 12px; display: block; }
.role-card h3 { font-size: 16px; margin-bottom: 4px; }
.role-card p { font-size: 12.5px; color: var(--text-muted); }
.login-account-picker { z-index: 1; margin-top: 26px; width: 100%; max-width: 440px; display: none; }
.login-account-picker.active { display: block; animation: fadeUp .4s var(--ease); }
.account-list { max-height: 300px; overflow-y: auto; margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.account-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer; transition: all .25s;
}
.account-item:hover { background: var(--surface-hover); border-color: var(--teal); }
.back-link { display: inline-block; margin-top: 14px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.back-link:hover { color: var(--teal-light); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   APP SHELL
   ============================================================ */
#app { display: none; min-height: 100vh; }
#app.active { display: flex; }

.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar); backdrop-filter: blur(20px);
  border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 50; transition: transform .3s var(--ease);
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand-row .mark { font-size: 22px; }
.brand-row .name { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.brand-row .sub { font-size: 10.5px; color: var(--text-muted); }
.nav-group { margin-bottom: 18px; }
.nav-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); padding: 0 10px; margin-bottom: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
  color: var(--text-muted); cursor: pointer; transition: all .2s; margin-bottom: 2px;
}
.nav-item .ic { width: 18px; text-align: center; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(58,175,169,.18), rgba(124,131,253,.1)); color: var(--teal-light); font-weight: 600; }
.sidebar-footer { margin-top: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.user-chip .info { flex: 1; overflow: hidden; }
.user-chip .info .n { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .info .r { font-size: 10.5px; color: var(--text-muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #08120F; flex-shrink: 0; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 40;
}
.search-box { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 13px; }
.search-box input { background: transparent; border: none; outline: none; color: var(--text); flex: 1; font-size: 13px; }
.kbd { font-size: 10px; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border); color: var(--text-dim); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--text-muted); position: relative; transition: all .2s; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.dot-alert { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); }

.page { padding: 26px; flex: 1; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 25px; font-weight: 600; letter-spacing: -.3px; }
.page-header p { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }

/* KPI grid */
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 22px; }
.kpi-card { display: flex; flex-direction: column; gap: 6px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-icon { font-size: 18px; }
.kpi-value { font-size: 28px; font-weight: 700; font-family: 'Fraunces', serif; }
.kpi-label { font-size: 12.5px; color: var(--text-muted); }
.kpi-delta { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.kpi-delta.up { color: var(--teal-light); background: rgba(58,175,169,.14); }
.kpi-delta.down { color: var(--coral); background: rgba(242,102,94,.14); }

.chart-card h3 { font-size: 14.5px; font-weight: 600; margin-bottom: 2px; }
.chart-card .cap { font-size: 11.5px; color: var(--text-muted); margin-bottom: 14px; }
.chart-holder { position: relative; width: 100%; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr.rowhover:hover td { background: var(--surface-hover); cursor: pointer; }
.progress-bar-track { width: 100%; height: 6px; border-radius: 6px; background: var(--border); overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 6px; transition: width .8s var(--ease); }

/* heatmap */
.heatmap { display: grid; gap: 4px; font-size: 10.5px; align-items: center; }
.heatmap-col-label { text-align: center; color: var(--text-dim); font-size: 10px; }
.heatmap-row-label { font-size: 11.5px; color: var(--text-muted); padding-right: 8px; white-space: nowrap; }
.heatmap-cell { aspect-ratio: 1.4; border-radius: 5px; display: flex; align-items: center; justify-content: center; color: #08120F; font-weight: 700; font-size: 9.5px; }

/* forms */
.form-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.field input[type=range] { width: 100%; accent-color: var(--teal); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13.5px; font-family: inherit; outline: none; transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); }
.field textarea { resize: vertical; min-height: 70px; }
.field .range-val { font-size: 12px; color: var(--teal-light); font-weight: 600; float: right; }
.field .mood-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mood-opt { padding: 7px 12px; border-radius: 20px; border: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.mood-opt.selected { background: rgba(58,175,169,.18); border-color: var(--teal); }
.chip-toggle { display: inline-flex; gap: 6px; align-items: center; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; }
.chip-toggle.on { background: rgba(58,175,169,.14); border-color: var(--teal); }

/* buttons */
.btn { padding: 10px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600; border: none; transition: all .25s var(--ease); }
.btn-primary { background: linear-gradient(135deg, var(--teal), var(--teal-light)); color: #04120F; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -8px rgba(58,175,169,.5); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* growth ring */
.growth-ring circle { }
.ring-legend { display: flex; flex-direction: column; gap: 6px; }
.ring-legend .li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.ring-legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* insight & recommendation cards */
.insight-item { display: flex; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 8px; font-size: 13px; line-height: 1.5; }
.insight-item.positive { border-left: 3px solid var(--teal); }
.insight-item.watch { border-left: 3px solid var(--gold); }
.rec-col h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-bottom: 10px; }
.rec-col li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }

/* profile header */
.profile-header { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.profile-header .meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.profile-header .meta span { font-size: 12.5px; color: var(--text-muted); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin: 20px 0; flex-wrap: wrap; }
.tab-btn { padding: 9px 16px; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--teal-light); border-color: var(--teal); font-weight: 600; }

/* status/support */
.status-open { color: var(--coral); } .status-progress { color: var(--gold); } .status-resolved { color: var(--teal-light); }

/* command palette / modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); z-index: 200; display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.modal-backdrop.active { display: flex; animation: fadeUp .25s var(--ease); }
.cmd-palette { width: 560px; max-width: 92vw; }
.cmd-input { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.cmd-input input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 15px; }
.cmd-results { max-height: 340px; overflow-y: auto; padding: 8px; }
.cmd-result { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; display: flex; justify-content: space-between; cursor: pointer; }
.cmd-result:hover, .cmd-result.sel { background: var(--surface-hover); }

.side-modal { position: fixed; top: 0; right: 0; height: 100vh; width: 380px; max-width: 92vw; z-index: 210; transform: translateX(100%); transition: transform .35s var(--ease); border-left: 1px solid var(--border); }
.side-modal.active { transform: translateX(0); }
.side-modal-head { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.side-modal-body { padding: 18px 20px; overflow-y: auto; height: calc(100vh - 66px); }
.notif-item { padding: 12px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 8px; font-size: 12.5px; }
.notif-item .t { font-weight: 600; margin-bottom: 3px; }

/* toast */
#toastHost { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: fadeUp .3s var(--ease); }

/* FAB */
.fab { position: fixed; bottom: 26px; right: 26px; width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--violet)); display: flex; align-items: center; justify-content: center; font-size: 22px; color: #06120F; box-shadow: 0 14px 30px -10px rgba(58,175,169,.5); z-index: 60; transition: transform .3s var(--ease); }
.fab:hover { transform: scale(1.08) rotate(90deg); }

/* skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* mobile sidebar */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: flex; }
  .page { padding: 18px; }
}

/* report / print */
.report-page { width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: #14231F; padding: 16mm; }
@media print {
  body * { visibility: hidden; }
  #reportArea, #reportArea * { visibility: visible; }
  #reportArea { position: absolute; top: 0; left: 0; width: 100%; }
  .no-print { display: none !important; }
}

/* fade page transitions */
.page-enter { animation: fadeUp .4s var(--ease); }
