/* ==========================================================================
   SmartOps SuperAPP — White-Label Client Demo Design System
   Refined Swiss-Modern Enterprise SaaS | Light & Dark Mode | Dynamic Brand
   ========================================================================== */

:root {
  --brand-primary: #1e3a8a;
  --brand-primary-hover: #172e6e;
  --brand-primary-soft: rgba(30, 58, 138, 0.09);
  --brand-primary-border: rgba(30, 58, 138, 0.24);

  --bg-page: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sidebar: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #e0f2fe;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.14);
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-surface: #111a2e;
  --bg-subtle: #17233b;
  --bg-sidebar: #070c17;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #1e2d48;
  --border-strong: #314466;
  --brand-primary-soft: rgba(56, 189, 248, 0.14);
  --brand-primary-border: rgba(56, 189, 248, 0.34);
  --success-soft: rgba(21, 128, 61, 0.22);
  --warning-soft: rgba(180, 83, 9, 0.22);
  --danger-soft: rgba(185, 28, 28, 0.24);
  --info-soft: rgba(3, 105, 161, 0.24);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.42);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary); text-decoration: none; }
[data-theme="dark"] a { color: #60a5fa; }

.hidden { display: none !important; }

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, opacity 0.16s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--bg-subtle); }

.btn-soft {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border-color: var(--brand-primary-border);
}
[data-theme="dark"] .btn-soft { color: #93c5fd; }

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-sm { padding: 0.4rem 0.72rem; font-size: 0.79rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}
.field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.input, select.input, textarea.input {
  width: 100%;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
}

/* ---------- Landing / Pitch Login Page ---------- */
.pitch-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
}
@media (max-width: 960px) {
  .pitch-shell { grid-template-columns: 1fr; }
}

.pitch-hero {
  background: var(--brand-primary);
  color: #ffffff;
  padding: 2.75rem 3.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.pitch-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.14), transparent 55%);
  pointer-events: none;
}
.pitch-hero > * { position: relative; z-index: 1; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.brand-lockup img {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: #ffffff;
  padding: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}
.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-company {
  font-size: 0.82rem;
  opacity: 0.86;
  font-weight: 500;
}

.hero-copy {
  margin: 2.6rem 0;
  max-width: 540px;
}
.hero-eyebrow {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.82;
  margin-bottom: 0.75rem;
}
.hero-copy h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, 2.8vw, 2.35rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.025em;
}
.hero-copy p {
  margin: 0 0 1.65rem;
  font-size: 0.96rem;
  opacity: 0.9;
  line-height: 1.6;
}

.feature-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
@media (max-width: 600px) {
  .feature-list { grid-template-columns: 1fr; }
  .pitch-hero { padding: 1.75rem 1.4rem; }
}
.feature-item {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}
.feature-item strong {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.feature-item span {
  font-size: 0.78rem;
  opacity: 0.86;
  display: block;
}

.hero-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.8rem;
}
.btn-hero-apk {
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
}
.btn-hero-apk:hover { background: #f1f5f9; }

.pitch-panel {
  padding: 2.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 600px) {
  .pitch-panel { padding: 1.5rem 1.2rem; }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.role-grid {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0 1.25rem;
}
.role-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease;
}
.role-btn:hover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
  transform: translateY(-1px);
}
.role-btn strong { display: block; font-size: 0.92rem; font-weight: 700; }
.role-btn small { display: block; font-size: 0.78rem; color: var(--text-muted); }
.role-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--brand-primary);
  color: #ffffff;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-surface) inset;
}

/* ---------- App Shell (Dashboard Portal) ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 1.15rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.85rem;
}
.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #ffffff;
  padding: 1px;
}
.sidebar-brand .s-app {
  font-size: 0.94rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}
.sidebar-brand .s-co {
  font-size: 0.72rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 175px;
}

.nav-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.65rem 0.65rem 0.3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  padding: 0.62rem 0.75rem;
  margin-bottom: 0.18rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #ffffff; }
.nav-item.active {
  background: var(--brand-primary);
  color: #ffffff;
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.demo-ribbon {
  background: var(--brand-primary);
  color: #ffffff;
  padding: 0.45rem 1.35rem;
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.demo-ribbon strong { font-weight: 700; }

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0;
}
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.menu-toggle {
  display: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.65rem;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1rem;
}

@media (max-width: 960px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: -270px;
    transition: left 0.22s ease;
  }
  .sidebar.open { left: 0; box-shadow: var(--shadow-lg); }
}

.content-wrap {
  padding: 1.35rem;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- KPI Grid & Charts ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 1024px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.kpi-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  height: 175px;
  padding: 0.75rem 0.25rem 0.25rem;
  border-bottom: 1px solid var(--border-color);
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 0.3rem;
}
.chart-pair {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 135px;
  width: 100%;
  justify-content: center;
}
.bar-masuk {
  width: 12px;
  border-radius: 4px 4px 0 0;
  background: var(--brand-primary);
  transition: height 0.25s ease;
}
.bar-visit {
  width: 12px;
  border-radius: 4px 4px 0 0;
  background: #0ea5e9;
  transition: height 0.25s ease;
}
.chart-lbl { font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }

/* ---------- Tables & Badges ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
table.data-table th {
  text-align: left;
  padding: 0.72rem 0.9rem;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-color);
}
table.data-table td {
  padding: 0.72rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-mono {
  font-family: var(--font-mono);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border-radius: 6px;
}
[data-theme="dark"] .badge-mono { color: #93c5fd; }

/* ---------- Sub-tabs & WI Word Editor ---------- */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.subtab-btn {
  padding: 0.52rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.subtab-btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.wi-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.55rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.wi-toolbar button {
  padding: 0.34rem 0.58rem;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
}
.wi-toolbar button:hover { background: var(--brand-primary-soft); }

.wi-editor-canvas {
  min-height: 250px;
  padding: 1.1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  outline: none;
  font-size: 0.92rem;
  line-height: 1.62;
}
.wi-doc-table, .wi-editor-canvas table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
}
.wi-doc-table th, .wi-doc-table td, .wi-editor-canvas th, .wi-editor-canvas td {
  border: 1px solid var(--border-strong);
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-size: 0.84rem;
}
.wi-doc-table th, .wi-editor-canvas th {
  background: var(--bg-subtle);
  font-weight: 700;
}

/* ---------- Modals (WI Navy Read-Only Preview & SP Letter) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-navy-head {
  background: var(--brand-primary);
  color: #ffffff;
  padding: 1.1rem 1.35rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 0.85rem 1.35rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.wi-meta-grid {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.83rem;
}
.wi-meta-grid th, .wi-meta-grid td {
  border: 1px solid var(--border-strong);
  padding: 0.5rem 0.75rem;
}
.wi-meta-grid th {
  background: var(--bg-subtle);
  font-weight: 700;
  width: 17%;
  text-align: left;
}
.wi-paper {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  line-height: 1.65;
}
.wi-paper::after { content: ""; display: table; clear: both; }

#demoMap {
  height: 410px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  z-index: 1;
}

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.05rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-width: 380px;
}

@media print {
  .sidebar, .topbar, .demo-ribbon, .modal-foot, .no-print { display: none !important; }
  .modal-backdrop { position: static; background: #fff; padding: 0; }
  .modal-box { box-shadow: none; max-height: none; }
}
