/* ============================================================
   Personal Dashboard — clean light minimal
   Type: Schibsted Grotesk (UI) · tabular figures for numbers
   ============================================================ */

:root {
  --bg: oklch(0.98 0.004 85);          /* warm paper white */
  --surface: #ffffff;
  --ink: oklch(0.22 0.01 85);          /* warm near-black */
  --ink-2: oklch(0.45 0.012 85);       /* secondary text */
  --ink-3: oklch(0.62 0.01 85);        /* tertiary / hints */
  --line: oklch(0.91 0.006 85);        /* hairline borders */
  --line-soft: oklch(0.945 0.005 85);
  --gain: oklch(0.55 0.12 162);
  --loss: oklch(0.55 0.14 27);
  --gain-bg: oklch(0.96 0.025 162);
  --loss-bg: oklch(0.96 0.02 27);
  --focus: oklch(0.55 0.12 162 / 0.35);
  --radius: 10px;
  --font: "Schibsted Grotesk", -apple-system, "Helvetica Neue", Helvetica, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; }

/* ---------- shared atoms ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: oklch(0.32 0.01 85); }
.btn-primary:disabled { background: var(--ink-3); cursor: default; }

.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-3); }

.btn-danger-armed { background: var(--loss); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s ease;
}
.field input:hover, .field select:hover { border-color: var(--ink-3); }
.field input:focus, .field select:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--gain); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--loss); }
.field .err { font-size: 12.5px; color: var(--loss); min-height: 0; display: none; }
.field .err.show { display: block; }

.banner-error {
  background: var(--loss-bg);
  color: var(--loss);
  border: 1px solid oklch(0.88 0.05 27);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  display: none;
}
.banner-error.show { display: block; }

.demo-pill {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  display: none;
  align-items: center;
  gap: 6px;
}
.demo-pill.show { display: inline-flex; }
.demo-pill::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gain);
}

/* ---------- login ---------- */

.login-stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--ink);
  display: grid;
  place-items: center;
  flex: none;
}
.brand-mark span {
  width: 12px; height: 12px;
  background: var(--bg);
  transform: rotate(45deg);
  border-radius: 2px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

.login-head h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.login-head p { color: var(--ink-2); font-size: 14.5px; }

.login-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 1px 2px oklch(0.22 0.01 85 / 0.04), 0 8px 24px oklch(0.22 0.01 85 / 0.04);
}

.login-foot {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}

.demo-hint {
  font-size: 13px;
  color: var(--ink-2);
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  display: none;
}
.demo-hint.show { display: block; }

/* ---------- dashboard ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}
/* left module rail — icons with labels below */
.with-rail { padding-left: 76px; }

.side-rail {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 76px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 14px 8px;
  z-index: 60;
}

.rail-brand { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.rail-brand span { width: 11px; height: 11px; }

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 2px 7px;
  border-radius: 9px;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.rail-icon { width: 22px; height: 22px; display: block; }
.rail-label { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; line-height: 1; }

a.rail-item:hover { background: var(--line-soft); color: var(--ink); }
a.rail-item:focus-visible { outline: 3px solid var(--focus); outline-offset: -1px; }
.rail-item.rail-active { color: var(--ink); background: var(--line-soft); }
.rail-item.rail-disabled { color: var(--ink-3); cursor: default; }
.rail-item.rail-disabled:hover { background: oklch(0.975 0.004 85); }

.topbar .brand-mark { width: 28px; height: 28px; border-radius: 7px; }
.topbar .brand-mark span { width: 10px; height: 10px; }
.topbar-module {
  font-size: 13.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-module strong { color: var(--ink); font-weight: 600; }
.topbar-spacer { flex: 1; }
.topbar-user { font-size: 13.5px; color: var(--ink-2); }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 32px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.page-head { display: flex; align-items: flex-end; gap: 16px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { color: var(--ink-2); font-size: 14px; padding-bottom: 2px; }

/* summary */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat .delta { font-size: 13px; font-weight: 600; }
.pos { color: var(--gain); }
.neg { color: var(--loss); }

/* toolbar */
.toolbar { display: flex; gap: 12px; align-items: center; }
.toolbar .search { position: relative; flex: 1; max-width: 280px; }
.toolbar .search input {
  font: inherit; font-size: 14px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  background: var(--surface);
  color: var(--ink);
}
.toolbar .search input:focus { outline: 3px solid var(--focus); border-color: var(--gain); }
.toolbar .search::before {
  content: "";
  position: absolute;
  left: 12px; top: 50%;
  width: 12px; height: 12px;
  margin-top: -7px;
  border: 1.7px solid var(--ink-3);
  border-radius: 50%;
}
.toolbar .search::after {
  content: "";
  position: absolute;
  left: 22px; top: 50%;
  width: 6px; height: 1.7px;
  margin-top: 4px;
  background: var(--ink-3);
  transform: rotate(45deg);
}
.toolbar select {
  font: inherit; font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
}
.toolbar .grow { flex: 1; }

/* form panel */
.form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: none;
  flex-direction: column;
  gap: 18px;
}
.form-panel.show { display: flex; }
.form-panel h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* table */
.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--line-soft);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--ink); }
thead th .arrow { display: inline-block; width: 1em; color: var(--ink-3); }
thead th.no-sort { cursor: default; }
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: oklch(0.975 0.004 85); }
td.r, th.r { text-align: right; }

.ticker { font-weight: 700; letter-spacing: 0.01em; }
.type-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--line-soft);
  border-radius: 6px;
  padding: 2px 8px;
}
.gl { font-weight: 600; }
.gl small { font-weight: 500; opacity: 0.75; margin-left: 6px; }

.notes-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}
.txn-buy { color: var(--gain); }
.txn-sell { color: var(--loss); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14.5px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.loading-row td { color: var(--ink-3); text-align: center; padding: 32px; }

@media (max-width: 760px) {
  .summary, .form-grid { grid-template-columns: 1fr; }
  .page { padding: 24px 16px 60px; }
}
