/* Outlook B.M.S. Lander — design system
   Self-contained, no external framework. Light + dark aware. */

:root {
  --brand-50:  #eefbf3;
  --brand-100: #d3f3e0;
  --brand-300: #7fd8ab;
  --brand-500: #1f9d5e;
  --brand-600: #17824c;
  --brand-700: #12673c;
  --brand-900: #0b3f26;

  --accent-500: #d97a2c; /* subsidy / warning accent — earthy orange */
  --accent-600: #b8631e;

  --ink-900: #14201c;
  --ink-700: #3a4a44;
  --ink-500: #667169;
  --ink-300: #a7b3ac;

  --surface-0: #ffffff;
  --surface-1: #f6f8f7;
  --surface-2: #eef2f0;
  --border: #e1e7e4;

  --danger-500: #d9432c;
  --danger-100: #fbe4df;
  --info-500: #2c7fd9;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 28, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 32, 28, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 32, 28, 0.12);

  --sidebar-w: 250px;
  --topbar-h: 64px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink-900: #eef2f0;
    --ink-700: #cdd8d3;
    --ink-500: #92a19a;
    --ink-300: #4b5952;

    --surface-0: #16211d;
    --surface-1: #0f1815;
    --surface-2: #1d2b25;
    --border: #26362f;

    --brand-50: #10261a;
    --brand-100: #143620;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--surface-1);
  color: var(--ink-900);
  font-size: 14.5px;
  line-height: 1.5;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-900), #0a2e1c 70%);
  color: #eafbf1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1.2rem;
  font-weight: 800;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--brand-500);
  display: grid; place-items: center;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-brand small { display: block; font-weight: 500; opacity: .65; font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }

.sidebar-nav { padding: .8rem .6rem; overflow-y: auto; flex: 1; }
.sidebar-section { margin: 1rem .6rem .35rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; opacity: .5; font-weight: 700; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  color: #d9f2e3;
  font-weight: 500;
  font-size: .92rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar-nav a.active { background: var(--brand-600); color: #fff; }
.sidebar-nav .icon { width: 18px; text-align: center; opacity: .85; }

.sidebar-footer { padding: .9rem 1.1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; opacity: .75; }

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

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; }
.topbar-user { display: flex; align-items: center; gap: .8rem; font-size: .88rem; color: var(--ink-500); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}

.content { padding: 1.6rem; flex: 1; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap;
}
.page-header p.subtitle { color: var(--ink-500); margin: .2rem 0 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
}
.card + .card { margin-top: 1rem; }
.card-title { font-weight: 700; margin-bottom: .9rem; display: flex; align-items: center; justify-content: space-between; }

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

/* ---------- KPI tiles ---------- */
.kpi {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--brand-500);
}
.kpi.accent::before { background: var(--accent-500); }
.kpi.info::before { background: var(--info-500); }
.kpi.neutral::before { background: var(--ink-300); }
.kpi-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); font-weight: 700; margin-bottom: .45rem; }
.kpi-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.kpi-sub { font-size: .8rem; color: var(--ink-500); margin-top: .3rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-0);
  color: var(--ink-900);
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  transition: filter .12s ease, transform .05s ease;
}
.btn:hover { filter: brightness(0.97); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-danger { background: var(--danger-500); border-color: var(--danger-500); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; color: var(--ink-700); }
.field { margin-bottom: 1rem; }
.field-hint { font-size: .78rem; color: var(--ink-500); margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=file],
select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-0);
  color: var(--ink-900);
  font-size: .92rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .89rem; background: var(--surface-0); }
th, td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { background: var(--surface-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); font-weight: 700; }
tbody tr:hover { background: var(--surface-1); }
tbody tr:last-child td { border-bottom: none; }
td.wrap, th.wrap { white-space: normal; }
.table-empty { padding: 2rem; text-align: center; color: var(--ink-500); }

/* Matrix / pivot table */
.matrix-table th, .matrix-table td { text-align: center; }
.matrix-table td.stage-name, .matrix-table th.stage-name { text-align: left; font-weight: 600; }
.matrix-table tfoot td { font-weight: 800; background: var(--surface-2); }
.matrix-table .metric-stremmata { color: var(--ink-500); font-size: .8rem; }
.matrix-table .metric-count { font-weight: 700; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink-700);
}
.badge-brand { background: var(--brand-100); color: var(--brand-700); }
.badge-accent { background: #fbe9d6; color: var(--accent-600); }
.badge-danger { background: var(--danger-100); color: var(--danger-500); }
.badge-info { background: #dbeafd; color: var(--info-500); }

/* ---------- Alerts / flashes ---------- */
.flash { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; font-weight: 600; }
.flash-success { background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-300); }
.flash-error { background: var(--danger-100); color: var(--danger-500); border: 1px solid #f2b6a8; }

/* ---------- Config rows (editable settings "tables") ---------- */
.config-table { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.config-head, .config-row {
  display: grid; align-items: center; gap: .6rem;
  padding: .55rem .85rem;
  border-bottom: 1px solid var(--border);
}
.config-row { background: var(--surface-0); }
.config-row:last-child, .config-table .config-head:last-child { border-bottom: none; }
.config-head { background: var(--surface-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); font-weight: 700; }
.config-row form { display: contents; }
.config-row input[type=text], .config-row input[type=number] { padding: .4rem .55rem; font-size: .85rem; }
.config-row-actions { display: flex; gap: .4rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tabs a { padding: .6rem .9rem; font-weight: 600; color: var(--ink-500); font-size: .88rem; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand-600); border-color: var(--brand-600); }

/* ---------- Funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: .5rem; }
.funnel-row { display: grid; grid-template-columns: 170px 1fr 90px; align-items: center; gap: .8rem; }
.funnel-bar-track { background: var(--surface-2); border-radius: 999px; height: 22px; overflow: hidden; }
.funnel-bar-fill { background: linear-gradient(90deg, var(--brand-500), var(--brand-600)); height: 100%; border-radius: 999px; display: flex; align-items: center; color: #fff; font-size: .72rem; font-weight: 700; padding-left: .5rem; min-width: 2.2em; }
.funnel-label { font-size: .85rem; font-weight: 600; }
.funnel-value { text-align: right; font-weight: 700; font-size: .85rem; }

/* ---------- Login ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top, var(--brand-50), var(--surface-1) 60%); padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-card .logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-500); color: #fff; display: grid; place-items: center; font-weight: 800; margin-bottom: 1rem; }

/* ---------- Misc ---------- */
.text-muted { color: var(--ink-500); }
.text-danger { color: var(--danger-500); }
.text-brand { color: var(--brand-600); }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.inline { display: flex; align-items: center; gap: .5rem; }
.space-between { display: flex; align-items: center; justify-content: space-between; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.divider { height: 1px; background: var(--border); margin: 1.1rem 0; border: none; }

.error-page { min-height: 100vh; display: grid; place-items: center; background: var(--surface-1); }
.error-box { text-align: center; }
.error-box h1 { font-size: 4rem; color: var(--brand-600); }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -100%; z-index: 30; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .content { padding: 1rem; }
}
