/* ═══════════════════════════════════════════════════════════
   ONE Platform — Design System
   Brand: #0D2B52 (navy), #1A73A7 (blue), #4CC8D9 (teal)
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Variables ──────────────────────────────────────── */
:root {
  /* Brand */
  --brand-navy:    #0D2B52;
  --brand-blue:    #1A73A7;
  --brand-teal:    #4CC8D9;
  --brand-light:   #E8F4F8;

  /* Surfaces */
  --bg:            #F5F7FA;
  --panel:         #FFFFFF;
  --panel-hover:   #F0F4F8;
  --line:          #E2E8F0;

  /* Text */
  --text:          #1A202C;
  --text-secondary:#64748B;
  --text-muted:    #94A3B8;

  /* Semantic */
  --success:       #22C55E;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          var(--brand-teal);

  /* Radii & Shadows */
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  /* Layout */
  --topbar-h:      56px;
  --sidebar-w:     240px;

  /* Font */
  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ─── Dark Theme ─────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0F172A;
    --panel:         #1E293B;
    --panel-hover:   #334155;
    --line:          #334155;
    --text:          #F1F5F9;
    --text-secondary:#94A3B8;
    --text-muted:    #64748B;
    --shadow:        0 1px 3px rgba(0,0,0,.3);
    --shadow-md:     0 4px 6px rgba(0,0,0,.3);
    --shadow-lg:     0 10px 15px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg:            #0F172A;
  --panel:         #1E293B;
  --panel-hover:   #334155;
  --line:          #334155;
  --text:          #F1F5F9;
  --text-secondary:#94A3B8;
  --text-muted:    #64748B;
  --shadow:        0 1px 3px rgba(0,0,0,.3);
  --shadow-md:     0 4px 6px rgba(0,0,0,.3);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.4);
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}
a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
input, button, select, textarea { font: inherit; }

/* ─── App Shell ──────────────────────────────────────────── */
.app { min-height: 100dvh; }
.screen { display: none; }
.screen.active { display: flex; }

/* ─── Login ──────────────────────────────────────────────── */
.login-screen {
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-blue) 100%);
}
.login-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: min(400px, 90vw);
  text-align: center;
}
.login-logo { width: 120px; margin: 0 auto 1rem; }
.login-card h1 { font-size: 1.5rem; color: var(--brand-navy); margin-bottom: .25rem; }
.login-subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: .9rem; }
.login-form { text-align: start; }
.login-footer { margin-top: 1.5rem; font-size: .8rem; color: var(--text-muted); }

/* ─── Form ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; color: var(--text-secondary); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(26,115,167,.15);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand-blue);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-navy); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--panel-hover); }
.btn-block { width: 100%; justify-content: center; }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: .4rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--panel-hover); color: var(--text); }

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; inset-inline: 0;
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 1rem;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-start, .topbar-end { display: flex; align-items: center; gap: .75rem; }
.topbar-logo { height: 32px; width: auto; }
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--brand-navy); }
.user-name { font-size: .85rem; color: var(--text-secondary); }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  inset-inline-start: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-inline-end: 1px solid var(--line);
  padding-top: 1rem;
  overflow-y: auto;
  z-index: 90;
  transition: transform .2s;
}
.nav-list { list-style: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 500;
  border-radius: 0;
  transition: all .15s;
}
.nav-link:hover { background: var(--panel-hover); color: var(--text); text-decoration: none; }
.nav-link.active {
  color: var(--brand-blue);
  background: var(--brand-light);
  font-weight: 600;
  border-inline-start: 3px solid var(--brand-blue);
}

/* ─── Main Layout ────────────────────────────────────────── */
.main-layout {
  flex-direction: column;
  min-height: 100dvh;
}
.content {
  margin-top: var(--topbar-h);
  margin-inline-start: var(--sidebar-w);
  padding: 1.5rem;
  min-height: calc(100dvh - var(--topbar-h));
}

/* ─── Views ──────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }
.view h2 { font-size: 1.4rem; margin-bottom: 1rem; color: var(--text); }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

/* ─── Stats Grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--brand-navy); }
.stat-label { font-size: .85rem; color: var(--text-secondary); margin-top: .25rem; }

/* ─── Data Table ─────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table th {
  background: var(--bg);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  padding: .75rem 1rem;
  text-align: start;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--panel-hover); }

/* ─── Card Grid ──────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(500px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close { font-size: 1.5rem; line-height: 1; }
.modal-body { padding: 1.25rem; }

/* ─── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  inset-inline-end: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column-reverse;
  gap: .5rem;
}
.toast {
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow-md);
  font-size: .9rem;
  border-inline-start: 4px solid var(--brand-blue);
  animation: toast-in .25s ease-out;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Config List ────────────────────────────────────────── */
.config-list { display: flex; flex-direction: column; gap: .75rem; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: rgba(34,197,94,.15); color: #16a34a; }
.badge-warning { background: rgba(245,158,11,.15); color: #d97706; }
.badge-danger  { background: rgba(239,68,68,.15); color: #dc2626; }
.badge-info    { background: rgba(76,200,217,.15); color: #0e7490; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .content { margin-inline-start: 0; }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  [dir="ltr"] .sidebar.open { transform: translateX(0); }
}
