:root {
  --bg: #08131c;
  --bg-2: #0b1924;
  --panel: #0e202d;
  --panel-2: #102634;
  --line: rgba(124, 188, 224, 0.18);
  --text: #f6f9fc;
  --muted: #a9bbca;
  --blue: #168cff;
  --blue-2: #03a9ff;
  --green: #08c987;
  --green-deep: #006c4f;
  --danger: #ff6b6b;
  --warn: #ffbd44;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 248px;
  --max: 1300px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 11%, rgba(22, 140, 255, 0.14), transparent 25%),
    radial-gradient(circle at 76% 19%, rgba(8, 201, 135, 0.1), transparent 28%),
    linear-gradient(180deg, #07121a 0%, #08151f 56%, #07131c 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.container { width: min(var(--max), calc(100% - 40px)); margin: 0 auto; }
.eyebrow {
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #3ab2ff;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue), #0e7fe9);
  box-shadow: 0 12px 30px rgba(22, 140, 255, 0.22);
  color: white;
}
.btn-outline {
  background: rgba(5, 15, 23, 0.42);
  border-color: rgba(22, 140, 255, 0.72);
  color: #fff;
}
.btn-green {
  background: linear-gradient(135deg, var(--green), #06a86f);
  color: #04170f;
  box-shadow: 0 10px 24px rgba(8, 201, 135, 0.2);
}
.btn-danger { background: rgba(255, 107, 107, 0.15); border-color: rgba(255, 107, 107, 0.5); color: #ffc9c9; }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; }

/* Public marketing page uses foundation.css */

/* Portal shell */
.portal-body { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(8, 24, 36, 0.98), rgba(5, 17, 25, 0.98));
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand img { width: 168px; display: block; margin-bottom: 28px; filter: drop-shadow(0 7px 18px rgba(0,0,0,.32)); }
.nav-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7a93a5;
  margin: 18px 10px 8px;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #d4e0e9;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.88;
  margin-bottom: 2px;
}
.side-link:hover, .side-link.active {
  opacity: 1;
  background: rgba(22, 140, 255, 0.12);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(22, 140, 255, 0.2);
}
.side-link .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(8, 201, 135, 0.5);
}
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.topbar h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  letter-spacing: -0.03em;
}
.topbar p { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; }
.user-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(14, 32, 45, 0.7);
  font-size: 0.85rem;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card, .panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 39, 53, 0.84), rgba(11, 29, 41, 0.84));
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.stat-card { padding: 18px; }
.stat-card .label { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.stat-card .value { font-size: 1.85rem; font-weight: 900; letter-spacing: -0.04em; margin-top: 8px; }
.stat-card .hint { color: #8fa6b6; font-size: 0.78rem; margin-top: 6px; }

.panel { padding: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
table.data th {
  text-align: left;
  color: #8fa6b6;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 10px 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
table.data td {
  padding: 12px 10px 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
table.data tr:hover td { background: rgba(22, 140, 255, 0.04); }
table.data a { color: #7ec8ff; font-weight: 700; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-green { background: rgba(8,201,135,.12); color: #5dffc0; border-color: rgba(8,201,135,.28); }
.badge-blue { background: rgba(22,140,255,.12); color: #7ec8ff; border-color: rgba(22,140,255,.28); }
.badge-warn { background: rgba(255,189,68,.12); color: #ffd27a; border-color: rgba(255,189,68,.28); }
.badge-muted { background: rgba(255,255,255,.06); color: #b7c6d2; }
.badge-danger { background: rgba(255,107,107,.12); color: #ffb0b0; border-color: rgba(255,107,107,.3); }

.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  background: rgba(14, 32, 45, 0.9);
  font-size: 0.9rem;
}
.messages .success { border-color: rgba(8,201,135,.35); }
.messages .error { border-color: rgba(255,107,107,.4); }
.messages .info { border-color: rgba(22,140,255,.35); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.search, .form-control, select.form-control, textarea.form-control {
  background: rgba(5, 15, 23, 0.55);
  border: 1px solid rgba(124, 188, 224, 0.22);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  outline: none;
  width: 100%;
}
.search { max-width: 280px; }
.form-control:focus { border-color: rgba(22,140,255,.7); box-shadow: 0 0 0 3px rgba(22,140,255,.15); }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #9bb0bf;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field { margin-bottom: 4px; }
.helptext, .errorlist { color: #8fa6b6; font-size: 0.78rem; margin: 4px 0 0; padding: 0; list-style: none; }
.errorlist { color: #ff9b9b; }

.quote-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 39, 53, 0.84), rgba(11, 29, 41, 0.84));
  border-radius: var(--radius-sm);
  padding: 16px;
}
.quote-card .quote { font-size: 0.88rem; line-height: 1.5; color: #eef5f9; margin: 0 0 10px; }
.quote-card .who { font-size: 0.8rem; font-weight: 800; }
.quote-card .role { display: block; font-size: 0.72rem; color: #a4b5c2; font-weight: 500; margin-top: 2px; }
.stars { color: var(--green); letter-spacing: 0.12em; }

.thread { display: grid; gap: 12px; }
.reply {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 22, 32, 0.7);
}
.reply.internal { border-color: rgba(255,189,68,.3); background: rgba(40, 30, 10, 0.35); }
.reply .meta { font-size: 0.75rem; color: #8fa6b6; margin-bottom: 8px; }
.reply .body { white-space: pre-wrap; line-height: 1.5; font-size: 0.9rem; }

.invoice-sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  background: linear-gradient(180deg, rgba(17, 39, 53, 0.9), rgba(11, 29, 41, 0.9));
}
.invoice-sheet h2 { margin: 0 0 4px; }
.muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; font-weight: 800; }

.chart-wrap {
  height: 220px;
  position: relative;
  margin-top: 8px;
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 39, 53, 0.95), rgba(11, 29, 41, 0.95));
  box-shadow: var(--shadow);
}
.login-card img { width: 200px; display: block; margin: 0 auto 20px; }
.stack-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.meta-list { display: grid; gap: 8px; font-size: 0.88rem; }
.meta-list dt { color: #8fa6b6; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.meta-list dd { margin: 2px 0 10px; }

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(124,188,224,.25);
  border-radius: var(--radius-sm);
}

@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .portal-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
  }
  .sidebar .brand { width: 100%; }
  .nav-label { display: none; }
  .side-link { padding: 8px 10px; font-size: 0.8rem; }
}
