/* VEILORA V2 - Design System
   Navy + Bottle Green | RTL | Futuristic, clean, simple */

:root {
  /* Core palette */
  --navy-950: #060d18;
  --navy-900: #0a1426;
  --navy-850: #0d1b32;
  --navy-800: #112340;
  --navy-700: #16304f;
  --navy-600: #1d3e63;
  --line: #1c3554;
  --line-soft: #16293f;

  --green-900: #0b2e26;
  --green-700: #0f5142;
  --green-600: #137a5c;
  --green-500: #18a06f;
  --green-400: #2fc28a;
  --green-glow: rgba(47, 194, 138, 0.35);

  --teal-400: #36d0c4;
  --blue-400: #4d8ff0;

  /* Text */
  --ink: #eaf2f8;
  --ink-soft: #b6c6d6;
  --ink-mute: #7e92a6;
  --ink-faint: #56697e;

  /* Status */
  --good: #2fc28a;
  --warn: #f0b34d;
  --danger: #f0654d;
  --critical: #ff4d6d;
  --info: #4d8ff0;

  /* Surfaces */
  --bg: radial-gradient(1200px 700px at 85% -10%, #123157 0%, transparent 55%),
        radial-gradient(900px 600px at -5% 110%, #0c3b30 0%, transparent 50%),
        linear-gradient(160deg, #07101f 0%, #0a1526 100%);
  --surface: rgba(15, 28, 49, 0.72);
  --surface-2: rgba(20, 37, 63, 0.6);
  --card: linear-gradient(165deg, rgba(22, 41, 70, 0.85), rgba(13, 24, 43, 0.9));
  --glass-border: rgba(120, 170, 220, 0.14);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow: 0 18px 50px -28px rgba(0, 0, 0, 0.85);
  --shadow-soft: 0 8px 28px -20px rgba(0, 0, 0, 0.7);

  --font: "Heebo", "Assistant", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
}

button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1c3554; border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Layout shells ===== */
.app-root { min-height: 100%; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: min(960px, 100%);
  background: var(--card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth-hero {
  padding: 46px 40px;
  background:
    radial-gradient(500px 300px at 100% 0%, rgba(47,194,138,0.18), transparent 60%),
    linear-gradient(160deg, #0c1b33, #0a2a23);
  border-inline-end: 1px solid var(--glass-border);
  display: flex; flex-direction: column; gap: 18px;
}
.auth-body { padding: 40px 36px; display: flex; flex-direction: column; gap: 16px; }

.gate-card {
  width: min(380px, 100%);
  background: var(--card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 34px;
}
.gate-card .field { margin-bottom: 16px; }

.app-grid {
  display: grid;
  grid-template-columns: 264px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas: "topbar topbar" "sidebar main";
  min-height: 100vh;
}
.topbar { grid-area: topbar; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; overflow: auto; padding: 26px 30px 60px; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 24px;
  background: linear-gradient(90deg, rgba(10,20,38,0.95), rgba(11,30,26,0.9));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: 2px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: conic-gradient(from 140deg, var(--green-400), var(--blue-400), var(--green-400));
  display: grid; place-items: center; color: #04121d; font-weight: 900;
  box-shadow: 0 0 18px var(--green-glow);
}
.brand small { color: var(--ink-mute); font-weight: 600; letter-spacing: 1px; font-size: 10px; }

.topbar-spacer { flex: 1; }

.project-switch {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 7px 12px;
  cursor: pointer; min-width: 230px;
}
.project-switch:hover { border-color: var(--green-600); }
.project-switch .ps-label { display: flex; flex-direction: column; line-height: 1.2; }
.project-switch .ps-label b { font-size: 13px; }
.project-switch .ps-label span { font-size: 11px; color: var(--ink-mute); }
.project-switch .chev { margin-inline-start: auto; color: var(--ink-mute); }

.ps-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-start: 0;
  width: 320px; background: #0e1d34; border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 8px; z-index: 60;
}
.ps-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.ps-item:hover { background: var(--surface-2); }
.ps-item.is-active { background: rgba(47,194,138,0.12); border: 1px solid rgba(47,194,138,0.3); }
.ps-item b { font-size: 13px; }
.ps-item small { color: var(--ink-mute); display: block; }

.userchip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(160deg, var(--green-500), var(--blue-400));
  display: grid; place-items: center; font-weight: 800; color: #06141f;
}
.userchip .meta b { font-size: 13px; display: block; }
.userchip .meta span { font-size: 11px; color: var(--ink-mute); }

/* ===== Sidebar ===== */
.sidebar {
  background: linear-gradient(180deg, rgba(9,18,33,0.96), rgba(8,24,20,0.9));
  border-inline-end: 1px solid var(--line);
  padding: 20px 14px; overflow: auto;
  position: sticky; top: 64px; height: calc(100vh - 64px);
}
.nav-group-label { font-size: 11px; color: var(--ink-faint); margin: 18px 10px 8px; letter-spacing: 1px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px; color: var(--ink-soft);
  cursor: pointer; font-size: 14px; font-weight: 600; position: relative;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(47,194,138,0.16), rgba(47,194,138,0.02));
  color: #fff;
}
.nav-item.is-active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 4px; background: var(--green-400); box-shadow: 0 0 12px var(--green-glow);
}
.nav-item .ic { width: 22px; text-align: center; opacity: .9; }
.nav-step-num {
  margin-inline-start: auto; font-size: 11px; color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 7px; width: 22px; height: 20px;
  display: grid; place-items: center;
}
.nav-item.is-done .nav-step-num { color: var(--green-400); border-color: var(--green-600); }

.flow-rail { margin: 4px 8px 0; }

/* ===== Typography / page header ===== */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0 0 4px; font-weight: 800; }
.page-head p { margin: 0; color: var(--ink-mute); font-size: 14px; max-width: 720px; }
.page-head .spacer { flex: 1; }

.eyebrow { font-size: 11px; letter-spacing: 2px; color: var(--green-400); font-weight: 700; text-transform: uppercase; }

h2 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 700; }

/* ===== Cards / grids ===== */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2-1 { grid-template-columns: 2fr 1fr; }

.card {
  background: var(--card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  position: relative;
}
.card.tight { padding: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }

.kpi {
  background: var(--card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset-inline-end: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, var(--green-glow), transparent 70%); opacity: .5;
}
.kpi .k-label { font-size: 12px; color: var(--ink-mute); font-weight: 600; }
.kpi .k-value { font-size: 30px; font-weight: 800; line-height: 1; }
.kpi .k-value small { font-size: 14px; color: var(--ink-mute); font-weight: 600; }
.kpi .k-trend { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.k-trend.up { color: var(--good); }
.k-trend.down { color: var(--danger); }
.k-trend.flat { color: var(--ink-mute); }

/* ===== Badges / chips ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent;
}
.badge.good { background: rgba(47,194,138,0.14); color: var(--good); border-color: rgba(47,194,138,0.3); }
.badge.warn { background: rgba(240,179,77,0.14); color: var(--warn); border-color: rgba(240,179,77,0.3); }
.badge.danger { background: rgba(240,101,77,0.14); color: var(--danger); border-color: rgba(240,101,77,0.3); }
.badge.critical { background: rgba(255,77,109,0.16); color: var(--critical); border-color: rgba(255,77,109,0.35); }
.badge.info { background: rgba(77,143,240,0.14); color: var(--info); border-color: rgba(77,143,240,0.3); }
.badge.neutral { background: var(--surface-2); color: var(--ink-soft); border-color: var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); } .dot.info { background: var(--info); }
.dot.critical { background: var(--critical); box-shadow: 0 0 8px var(--critical); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; font-size: 14px; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  cursor: pointer; transition: transform .08s, background .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { border-color: var(--green-600); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(160deg, var(--green-500), var(--green-700));
  border-color: transparent; color: #04140d;
  box-shadow: 0 10px 26px -14px var(--green-glow);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-danger { color: var(--danger); border-color: rgba(240,101,77,0.4); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.input, .select, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  background: rgba(7,15,28,0.7); border: 1px solid var(--line); color: var(--ink);
  font-size: 14px; font-family: inherit; outline: none;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(47,194,138,0.15); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: start; font-weight: 700; color: var(--ink-mute); font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px; border-bottom: 1px solid var(--line-soft); }
.table tr:hover td { background: rgba(255,255,255,0.015); }
.table tr.clickable { cursor: pointer; }
.table .muted { color: var(--ink-mute); }

/* ===== Stepper (flow) ===== */
.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.step {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
}
.step .n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--navy-700); }
.step.is-active { border-color: var(--green-500); color: #fff; background: rgba(47,194,138,0.1); }
.step.is-active .n { background: var(--green-500); color: #04140d; }
.step.is-done .n { background: var(--green-700); color: #cfeede; }

/* ===== Misc ===== */
.muted { color: var(--ink-mute); }
.soft { color: var(--ink-soft); }
.mono { font-family: var(--mono); }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; }
.right { text-align: end; }
.center { text-align: center; }
.small { font-size: 12px; }

.list-line { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.list-line:last-child { border-bottom: 0; }

.meter { height: 8px; border-radius: 6px; background: var(--navy-700); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--green-600), var(--green-400)); }
.meter.warn > span { background: linear-gradient(90deg, #a9772a, var(--warn)); }
.meter.danger > span { background: linear-gradient(90deg, #a93a2a, var(--danger)); }

.timeline { position: relative; padding-inline-start: 18px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 4px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: -18px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--green-400); box-shadow: 0 0 0 3px rgba(47,194,138,0.15); }
.tl-item small { color: var(--ink-faint); }

.empty {
  text-align: center; padding: 48px 20px; color: var(--ink-mute);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty .mark { font-size: 28px; margin-bottom: 8px; }

.alert {
  display: flex; gap: 12px; padding: 13px 15px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px;
}
.alert.warn { border-color: rgba(240,179,77,0.35); background: rgba(240,179,77,0.07); }
.alert.danger { border-color: rgba(240,101,77,0.35); background: rgba(240,101,77,0.07); }
.alert.good { border-color: rgba(47,194,138,0.35); background: rgba(47,194,138,0.07); }

/* segmented control (period selector) */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--ink-soft); padding: 7px 14px;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.segmented button.is-active { background: linear-gradient(160deg, var(--green-500), var(--green-700)); color: #04140d; }

/* charts */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: 6px; vertical-align: middle; }

/* tags grid for portfolio */
.portfolio-card { cursor: pointer; transition: transform .12s, border-color .15s; }
.portfolio-card:hover { transform: translateY(-3px); border-color: var(--green-600); }

/* toast */
.toast-root { position: fixed; inset-block-end: 24px; inset-inline-start: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: #0e2236; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; box-shadow: var(--shadow); font-size: 13.5px; min-width: 240px;
  animation: toastin .25s ease; border-inline-start: 3px solid var(--green-400);
}
.toast.danger { border-inline-start-color: var(--danger); }
.toast.warn { border-inline-start-color: var(--warn); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(4,9,18,0.7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 150; padding: 24px; }
.modal { width: min(560px, 100%); background: #0d1d34; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); max-height: 88vh; overflow: auto; }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; }
.x-close { margin-inline-start: auto; cursor: pointer; color: var(--ink-mute); font-size: 20px; background: none; border: 0; }

/* responsive */
@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-grid { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .auth-card { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .field-row { grid-template-columns: 1fr; }
}

.scrim { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fade .25s ease; }
