/* ============================================================
   Corporate Brain — Design System
   SOU Brand: Navy #0B1B3F · Magenta #E5197D
   ============================================================ */

/* ── FONTS ── */
@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;700;800;900&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

/* ── VARIABLES ── */
:root {
  --navy: #0B1B3F;
  --navy2: #16275A;
  --navy3: #0F1F4F;
  --magenta: #E5197D;
  --mgsoft: #F45CA7;
  --mglight: #FCE7F3;
  --paper: #F1F3F7;
  --white: #FFFFFF;
  --line: #D9DEE8;
  --line2: #E5E7EB;
  --muted: #5A647A;
  --muted2: #9FB0D0;
  --ink: #0B1B3F;
  --green: #10B981;
  --green-light: #D1FAE5;
  --green-dark: #065F46;
  --red: #EF4444;
  --red-light: #FEE2E2;
  --red-dark: #991B1B;
  --amber: #F59E0B;
  --amber-light: #FEF3C7;
  --amber-dark: #92400E;
  --sidebar-w: 260px;
  --header-h: 64px;
}

/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── LAYOUT: CHASSI (Sidebar + Header + Content) ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy2) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-radius: 0 16px 16px 0;
  overflow: hidden;
  position: relative;
  z-index: 20;
  box-shadow: 4px 0 24px rgba(11, 27, 63, 0.3);
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .logo-img {
  height: 28px;
  width: auto;
}

.sidebar-brand .logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--magenta);
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  padding: 16px 20px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  margin: 2px 8px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-link.active {
  background: var(--magenta);
  color: #fff;
  box-shadow: 0 4px 12px rgba(229, 25, 125, 0.3);
}

.sidebar-link .svg-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── MAIN AREA ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── HEADER ── */
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-title {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--magenta), var(--mgsoft));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  font-family: 'Archivo', sans-serif;
}

.user-avatar.admin-avatar {
  background: linear-gradient(135deg, #6C5CE7, #A29BFE);
}

.role-badge {
  background: var(--magenta);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── CONTENT ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ── CARDS ── */
.card {
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
}

/* ── STAT CARDS ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.15s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.stat-card:hover {
  border-color: var(--magenta);
  box-shadow: 0 4px 16px rgba(229, 25, 125, 0.1);
  transform: translateY(-1px);
}

.stat-card .stat-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-family: 'Archivo', sans-serif;
  font-weight: 900;
  font-size: 28px;
  color: var(--magenta);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── TABLES ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--line2);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.data-table tr:hover td {
  background: var(--paper);
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-red { background: var(--red-light); color: var(--red-dark); }
.badge-amber { background: var(--amber-light); color: var(--amber-dark); }
.badge-magenta { background: var(--mglight); color: var(--magenta); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--magenta); color: #fff; }
.btn-primary:hover { background: var(--mgsoft); }

.btn-secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--line); border-color: var(--muted2); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); }

.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 6px; }

/* ── FORMS ── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(229, 25, 125, 0.1);
}

.form-input::placeholder {
  color: var(--muted2);
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
}

/* ── FLASH MESSAGES ── */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}

.flash-error { background: var(--red-light); color: var(--red-dark); border: 1px solid rgba(239, 68, 68, 0.2); }
.flash-success { background: var(--green-light); color: var(--green-dark); border: 1px solid rgba(16, 185, 129, 0.2); }
.flash-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── PAGE HEADER ── */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.page-header p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── CODE BLOCK ── */
.code-block {
  background: var(--navy);
  color: var(--muted2);
  padding: 16px 20px;
  border-radius: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  word-break: break-all;
  margin: 12px 0;
  line-height: 1.6;
}

.code-block .hl { color: var(--magenta); font-weight: 600; }

/* ── AUTH PAGES (Login / Verify) ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy3) 40%, #1a1040 100%);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(229, 25, 125, 0.15), transparent 60%);
  border-radius: 50%;
}

.auth-page::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(58, 58, 140, 0.3), transparent 60%);
  border-radius: 50%;
}

.auth-card {
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 2;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-img {
  height: 48px;
  width: auto;
  margin-bottom: 12px;
}

.auth-logo .logo-text {
  font-family: 'Archivo', sans-serif;
  font-weight: 900;
  font-size: 32px;
  color: var(--navy);
}

.auth-logo .logo-text span {
  color: var(--magenta);
}

.auth-logo .logo-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 6px;
}

.auth-card h2 {
  font-family: 'Archivo', sans-serif;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 6px;
}

.auth-card .auth-desc {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.auth-card .auth-email {
  color: var(--muted);
  font-size: 12px;
  background: var(--paper);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.auth-card .auth-email strong {
  color: var(--ink);
  font-weight: 600;
}

.otp-input {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 28px;
  text-align: center;
  letter-spacing: 10px;
  color: var(--ink);
  transition: all 0.15s ease;
}

.otp-input:focus {
  outline: none;
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(229, 25, 125, 0.1);
}

.otp-input::placeholder {
  color: var(--line);
  letter-spacing: 4px;
}

.auth-link {
  text-align: center;
  margin-top: 16px;
}

.auth-link a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.15s;
}

.auth-link a:hover {
  color: var(--magenta);
}

.new-doc-form-hidden { display: none !important; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 16px;
  }
  .topbar {
    padding: 0 16px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    margin: 16px;
    padding: 28px 20px;
  }
}

/* ── CHARTS ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

.donut-chart { position: relative; width: 160px; height: 160px; margin: 0 auto; }
.donut-chart svg { transform: rotate(-90deg); }
.donut-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.donut-center .total { font-family: 'Archivo', sans-serif; font-weight: 900; font-size: 20px; color: var(--ink); }
.donut-center .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.donut-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; justify-content: center; }
.donut-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

.bar-compare { display: flex; align-items: flex-end; gap: 24px; height: 180px; padding: 8px 0; justify-content: center; }
.bar-group { display: flex; gap: 4px; align-items: flex-end; height: 100%; }
.bar-group-label { text-align: center; font-size: 10px; color: var(--muted); margin-top: 8px; font-weight: 600; }
.bar-planned { width: 20px; background: var(--line); border-radius: 3px 3px 0 0; }
.bar-actual { width: 20px; background: var(--magenta); border-radius: 3px 3px 0 0; }
.bar-legend-row { display: flex; gap: 16px; justify-content: center; margin-top: 8px; font-size: 11px; color: var(--muted); }
.bar-legend-row span { display: flex; align-items: center; gap: 4px; }
.bar-legend-swatch { width: 12px; height: 12px; border-radius: 2px; }

.line-svg { width: 100%; overflow: visible; }
.line-point { fill: var(--magenta); }
.line-point:hover { fill: var(--mgsoft); r: 5; }
.line-grid { stroke: var(--line); stroke-width: 0.5; stroke-dasharray: 4 4; }
