@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Sora:wght@500;600;700;800&display=swap");

:root {
  --font-sans: "Plus Jakarta Sans", "Aptos", "Segoe UI", sans-serif;
  --font-display: "Sora", "Space Grotesk", "Aptos Display", sans-serif;

  --bg: #f5f7fa;
  --bg-soft: #edf1f5;
  --ink: #121c28;
  --ink-soft: #263648;
  --muted: #4f6174;

  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: #dbe2ea;
  --line-strong: #c9d3df;

  --brand: #2f6ea7;
  --brand-strong: #245887;
  --brand-soft: #ecf3fa;
  --brand-ink: #1f4870;

  --cash: #3b74da;
  --cash-soft: #edf3fe;
  --realized: #2f9b72;
  --realized-soft: #edf7f2;

  --danger: #c24034;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --shadow-soft: 0 12px 30px rgba(20, 33, 48, 0.08);
  --shadow-strong: 0 18px 38px rgba(16, 27, 41, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(125, 139, 156, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 139, 156, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 50% 20%, rgba(0, 0, 0, 0.6), transparent 78%);
  z-index: -1;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(110% 88% at 8% -10%, rgba(66, 125, 189, 0.1) 0%, rgba(66, 125, 189, 0) 52%),
    radial-gradient(92% 82% at 100% 0%, rgba(122, 148, 180, 0.09) 0%, rgba(122, 148, 180, 0) 56%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 52%, var(--bg-soft) 100%);
  z-index: -2;
}

.layout {
  width: min(1360px, calc(100% - 2.2rem));
  margin: 0 auto;
  padding: 2.1rem 0 3rem;
  display: grid;
  gap: 1.15rem;
}

.app-footer {
  border: 1px solid rgba(209, 220, 231, 0.95);
  border-radius: var(--radius-md);
  padding: 0.72rem 0.88rem;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.app-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.app-footer-links a {
  color: #2c5e90;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.app-footer-links a:hover {
  color: #1f4870;
  text-decoration: underline;
}

.legal-page {
  min-height: 100vh;
}

.legal-layout {
  width: min(980px, calc(100% - 2.2rem));
  margin: 0 auto;
  padding: 2.1rem 0 3rem;
  display: grid;
  gap: 1rem;
}

.legal-header,
.legal-panel,
.legal-warning {
  border: 1px solid rgba(209, 220, 231, 0.95);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.legal-header {
  padding: 1.05rem 1.15rem;
}

.legal-kicker {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4f6278;
}

.legal-header h1 {
  margin: 0.3rem 0 0.7rem;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.4vw, 1.9rem);
  color: #172636;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.legal-nav a {
  border: 1px solid #cbd8e6;
  border-radius: 999px;
  padding: 0.22rem 0.58rem;
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 100%);
  color: #2e5f91;
  font-size: 0.79rem;
  font-weight: 700;
  text-decoration: none;
}

.legal-nav a[aria-current="page"] {
  border-color: #9fb9d3;
  background: linear-gradient(180deg, #ffffff 0%, #e9f2fb 100%);
  color: #214c78;
}

.legal-nav a:hover {
  border-color: #a9bfd7;
}

.legal-warning {
  padding: 0.82rem 1.05rem;
  border-color: #d2b26f;
  background: linear-gradient(180deg, #fff7e8 0%, #f9efdd 100%);
  color: #735319;
}

.legal-warning p {
  margin: 0;
}

.legal-warning p + p {
  margin-top: 0.42rem;
}

.legal-panel {
  padding: 1.1rem 1.2rem;
}

.legal-panel h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.07rem;
  color: #1e344b;
}

.legal-panel h2 + p,
.legal-panel h2 + ul,
.legal-panel p,
.legal-panel ul {
  margin-top: 0;
}

.legal-panel p,
.legal-panel li,
.legal-panel dd {
  color: #2f455d;
  line-height: 1.55;
}

.legal-panel ul {
  padding-left: 1.2rem;
  margin-bottom: 1rem;
}

.legal-panel a {
  color: #2c5e90;
}

.legal-kv {
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: minmax(170px, 250px) minmax(0, 1fr);
  gap: 0.2rem 0.65rem;
}

.legal-kv dt {
  margin: 0;
  font-weight: 700;
  color: #40566f;
}

.legal-kv dd {
  margin: 0;
}

.header {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(206, 217, 229, 0.94);
  border-radius: var(--radius-xl);
  padding: 1.25rem clamp(1.15rem, 2.6vw, 2.1rem) 1.3rem;
  background:
    radial-gradient(circle at 0% 0%, rgba(73, 127, 190, 0.1) 0%, rgba(73, 127, 190, 0) 46%),
    radial-gradient(circle at 100% 0%, rgba(95, 129, 170, 0.11) 0%, rgba(95, 129, 170, 0) 44%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96) 0%, rgba(250, 252, 255, 0.98) 100%);
  box-shadow: var(--shadow-soft);
  isolation: isolate;
}

.header::after {
  content: "";
  position: absolute;
  inset: auto -35% -72% 45%;
  height: 220px;
  background: radial-gradient(circle, rgba(79, 122, 173, 0.11) 0%, rgba(79, 122, 173, 0) 72%);
  pointer-events: none;
  z-index: -1;
}

.header h1 {
  margin: 0 0 0.36rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.02em;
  line-height: 1.06;
  color: #172636;
}

.header p {
  margin: 0;
  max-width: 76ch;
  color: var(--muted);
  font-size: clamp(0.91rem, 1vw, 1.03rem);
  line-height: 1.45;
  padding-right: min(26rem, 48vw);
}

.header-actions {
  position: absolute;
  top: 0.85rem;
  right: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
}

.auth-user-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c8d6e4;
  border-radius: 999px;
  padding: 0.2rem 0.56rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #ffffff 0%, #f2f6fa 100%);
  color: #42576f;
}

.auth-action {
  padding: 0.2rem 0.62rem;
  border-radius: 999px;
  font-size: 0.74rem;
}

.mark-status-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c8d6e4;
  border-radius: 999px;
  padding: 0.2rem 0.56rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #ffffff 0%, #f2f6fa 100%);
  color: #42576f;
}

.mark-status-chip.is-live {
  border-color: #85b79f;
  background: linear-gradient(180deg, #eef9f3 0%, #e5f3eb 100%);
  color: #236648;
}

.mark-status-chip.is-offline {
  border-color: #c9d4e0;
  background: linear-gradient(180deg, #f6f9fc 0%, #edf2f7 100%);
  color: #4b6078;
}

.db-health-chip {
  appearance: none;
  border: 1px solid #c7d4e1;
  border-radius: 999px;
  padding: 0.2rem 0.58rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #ffffff 0%, #f2f6fa 100%);
  color: #40556d;
  box-shadow: none;
  cursor: pointer;
}

.db-health-chip:hover {
  transform: none;
  box-shadow: none;
  border-color: #aebfd1;
  background: linear-gradient(180deg, #ffffff 0%, #eef4fa 100%);
}

.db-health-chip:focus-visible {
  border-color: #6f91b6;
  box-shadow: 0 0 0 3px rgba(47, 110, 167, 0.24);
}

.db-health-chip.is-loading {
  border-color: #c6d3e2;
  background: linear-gradient(180deg, #f8fbff 0%, #edf2f7 100%);
  color: #566a81;
}

.db-health-chip.is-healthy {
  border-color: #85b79f;
  background: linear-gradient(180deg, #eef9f3 0%, #e5f3eb 100%);
  color: #236648;
}

.db-health-chip.is-warning {
  border-color: #d2b26f;
  background: linear-gradient(180deg, #fff7e8 0%, #f9efdd 100%);
  color: #735319;
}

.db-health-chip.is-error {
  border-color: #d99c95;
  background: linear-gradient(180deg, #fff2f1 0%, #f8e6e4 100%);
  color: #8e2f25;
}

.settings-trigger {
  position: static;
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #cad5e1;
  background: linear-gradient(180deg, #ffffff 0%, #f2f6fa 100%);
  color: #4e6178;
  box-shadow: 0 8px 14px rgba(31, 44, 61, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-trigger:hover {
  transform: none;
  background: linear-gradient(180deg, #ffffff 0%, #edf3f9 100%);
  border-color: #b7c6d7;
  box-shadow: 0 10px 16px rgba(31, 44, 61, 0.15);
}

.settings-trigger:focus-visible {
  border-color: #6f91b6;
  box-shadow: 0 0 0 3px rgba(47, 110, 167, 0.24);
}

.settings-trigger-icon {
  width: 1.18rem;
  height: 1.18rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-trigger-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  transition: transform 180ms ease;
}

.settings-trigger:hover .settings-trigger-icon svg {
  transform: rotate(20deg);
}

.panel {
  position: relative;
  overflow: clip;
  background: var(--panel);
  border: 1px solid rgba(209, 220, 231, 0.95);
  border-radius: var(--radius-lg);
  padding: clamp(0.9rem, 1.4vw, 1.2rem);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 38%);
}

.panel h2 {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-size: clamp(1.03rem, 1.5vw, 1.26rem);
  letter-spacing: -0.01em;
  color: #17293c;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.table-view-head {
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.table-view-tablist {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem;
  border: 1px solid #cfd9e4;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fafd 0%, #edf2f8 100%);
}

.table-view-tab {
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #4f6279;
  box-shadow: none;
  padding: 0.46rem 0.72rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

.table-view-tab:hover {
  transform: none;
  box-shadow: none;
  border-color: #b8c9da;
  background: rgba(255, 255, 255, 0.9);
}

.table-view-tab:focus-visible {
  box-shadow: 0 0 0 3px rgba(47, 110, 167, 0.2);
}

.table-view-tab.is-active {
  border-color: #9db7d2;
  background: linear-gradient(180deg, #ffffff 0%, #edf5fc 100%);
  color: #204a78;
}

.table-view-count {
  font-size: 0.77rem;
  color: #62778f;
}

.table-view-tab.is-active .table-view-count {
  color: #375d85;
}

.table-view-panel {
  display: grid;
  gap: 0.7rem;
}

.table-view-panel[hidden] {
  display: none;
}

.table-view-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.table-view-panel h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.97rem;
  letter-spacing: -0.01em;
  color: #223a52;
}

.table-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

.table-controls input[type="search"] {
  width: min(400px, 100%);
  min-width: 230px;
}

.table-controls select {
  min-width: 186px;
}

.drop-zone {
  position: relative;
  overflow: hidden;
  border: 1px dashed #b7c6d8;
  border-radius: 16px;
  padding: 1.45rem 1.05rem;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(63, 113, 166, 0.11), transparent 62%),
    linear-gradient(180deg, #ffffff 0%, #f7fafd 100%);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.drop-zone::before {
  content: "";
  position: absolute;
  inset: -120% -10%;
  background: linear-gradient(95deg, rgba(255, 255, 255, 0) 36%, rgba(255, 255, 255, 0.75) 50%, rgba(255, 255, 255, 0) 64%);
  transform: translateX(-55%);
  transition: transform 420ms ease;
  pointer-events: none;
}

.drop-zone:hover {
  transform: translateY(-1px);
  border-color: #9fb4cb;
  box-shadow: 0 12px 28px rgba(31, 52, 75, 0.1);
}

.drop-zone:hover::before {
  transform: translateX(55%);
}

.drop-zone.drag-over {
  border-color: var(--brand);
  box-shadow: 0 18px 30px rgba(33, 65, 101, 0.16);
  background:
    radial-gradient(circle at 50% 0%, rgba(47, 110, 167, 0.2), transparent 62%),
    linear-gradient(180deg, #f8fbff 0%, #edf3fa 100%);
}

.drop-zone p {
  margin: 0 0 0.75rem;
  color: var(--ink-soft);
}

button,
input[type="search"],
select,
input[type="date"] {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.56rem 0.72rem;
  background: var(--panel-strong);
  color: var(--ink);
  transition:
    border-color 130ms ease,
    box-shadow 130ms ease,
    transform 130ms ease,
    background-color 130ms ease;
}

input[type="search"],
select,
input[type="date"] {
  font-size: 0.92rem;
}

button {
  border-color: transparent;
  color: #f7fbff;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(120deg, var(--brand-strong) 0%, var(--brand) 50%, #3b82c4 100%);
  box-shadow:
    0 7px 14px rgba(36, 82, 132, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  cursor: pointer;
}

button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 11px 18px rgba(36, 82, 132, 0.27),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: linear-gradient(180deg, #ffffff 0%, #f2f5f9 100%);
  border-color: #cbd5e0;
  color: #344455;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

button.secondary:hover {
  background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
  box-shadow:
    0 7px 14px rgba(27, 41, 56, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

button.danger {
  background: linear-gradient(120deg, #d6453a 0%, var(--danger) 55%, #a92f26 100%);
  color: #fff8f7;
}

button.danger:hover {
  box-shadow:
    0 11px 18px rgba(132, 32, 23, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

input[type="search"]:focus-visible,
select:focus-visible,
input[type="date"]:focus-visible,
button:focus-visible {
  outline: 0;
  border-color: #7d97b5;
  box-shadow: 0 0 0 3px rgba(47, 110, 167, 0.2);
}

.period-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.7rem;
}

.period-controls label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4f6276;
}

.period-controls select,
.period-controls input[type="date"] {
  min-width: 185px;
}

.window-summary {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
  margin: 0 0 1rem;
}

.stat {
  position: relative;
  border: 1px solid rgba(206, 218, 230, 0.92);
  border-radius: 14px;
  padding: 0.68rem 0.72rem 0.7rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 251, 255, 0.96) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 3px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(90deg, #4f7fb2 0%, #73a8bf 100%);
}

.stat .label {
  margin: 0;
  color: #54687d;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stat .value {
  margin: 0.24rem 0 0;
  font-size: 1.18rem;
  font-weight: 800;
  color: #1b2d40;
}

.curve-shell {
  margin: 0 0 1rem;
  padding: 0.9rem;
  border-radius: 18px;
  border: 1px solid rgba(204, 216, 229, 0.95);
  background:
    radial-gradient(circle at 10% 0%, rgba(87, 131, 177, 0.11) 0%, rgba(87, 131, 177, 0) 44%),
    radial-gradient(circle at 92% 0%, rgba(108, 144, 183, 0.1) 0%, rgba(108, 144, 183, 0) 45%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 250, 254, 0.97) 100%);
}

.curve-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.9rem;
}

.curve-kicker {
  margin: 0;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4f6278;
}

.curve-head h3 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.14rem;
  letter-spacing: -0.01em;
}

.curve-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.curve-controls label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4f6278;
  font-weight: 700;
}

.curve-controls select {
  min-width: 120px;
}

.curve-legend {
  margin: 0.74rem 0 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.curve-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.24rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.curve-pill.curve-toggle {
  appearance: none;
  cursor: pointer;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    opacity 120ms ease;
}

.curve-pill.curve-toggle:hover {
  transform: translateY(-1px);
}

.curve-pill.curve-toggle:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(47, 110, 167, 0.24);
}

.curve-pill.curve-toggle.is-off {
  opacity: 0.42;
  filter: saturate(0.4);
}

.curve-pill.realized {
  background: var(--realized-soft);
  border-color: #c4dfd2;
  color: #295d49;
}

.curve-pill.cash {
  background: var(--cash-soft);
  border-color: #c7d6f2;
  color: #315690;
}

.curve-pill.stamp {
  background: #f2f4f7;
  border-color: #d9e0e8;
  color: #4e5e70;
}

.pnl-curve {
  width: 100%;
  height: 280px;
  min-height: 230px;
  position: relative;
  overflow: hidden;
  border-radius: 13px;
}

.pnl-curve svg {
  width: 100%;
  height: 100%;
  display: block;
}

.curve-empty {
  height: 100%;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed #c7d2de;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(245, 249, 253, 0.92) 100%);
}

.curve-plot-bg {
  fill: rgba(255, 255, 255, 0.86);
  stroke: rgba(124, 141, 160, 0.26);
  stroke-width: 1;
}

.curve-grid-line {
  stroke: rgba(102, 122, 145, 0.18);
  stroke-width: 1;
  stroke-dasharray: 2.5 4;
}

.curve-zero-line {
  stroke: rgba(55, 68, 84, 0.4);
  stroke-width: 1.2;
}

.curve-axis-label {
  fill: #4f6073;
  font-size: 10px;
  font-family: var(--font-sans);
  text-anchor: end;
}

.curve-axis-label.x-axis {
  text-anchor: middle;
}

.curve-area {
  stroke: none;
}

.curve-area.realized {
  fill: url(#curve-realized-fill);
}

.curve-area.cash {
  fill: url(#curve-cash-fill);
}

.curve-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.curve-line.realized {
  stroke: url(#curve-realized-stroke);
}

.curve-line.cash {
  stroke: url(#curve-cash-stroke);
}

.curve-dot {
  stroke-width: 1.2;
}

.curve-dot.realized {
  fill: var(--realized);
  stroke: #f6fffb;
}

.curve-dot.cash {
  fill: var(--cash);
  stroke: #f4f8ff;
}

.curve-hover-line {
  stroke: rgba(70, 81, 98, 0.45);
  stroke-width: 1.2;
  stroke-dasharray: 3 4;
  pointer-events: none;
}

.curve-hover-marker {
  stroke-width: 2;
  pointer-events: none;
}

.curve-hover-marker.realized {
  fill: var(--realized);
  stroke: #f5fffa;
}

.curve-hover-marker.cash {
  fill: var(--cash);
  stroke: #f3f7ff;
}

.curve-hitbox {
  fill: transparent;
  cursor: crosshair;
  pointer-events: all;
}

.curve-hover-tooltip {
  position: absolute;
  min-width: 164px;
  max-width: min(248px, calc(100% - 8px));
  padding: 0.54rem 0.62rem;
  border-radius: 11px;
  background: rgba(25, 34, 46, 0.93);
  color: #f3f7fd;
  box-shadow: 0 12px 25px rgba(18, 28, 40, 0.28);
  border: 1px solid rgba(157, 171, 194, 0.26);
  font-size: 0.78rem;
  line-height: 1.3;
  pointer-events: none;
  z-index: 2;
}

.curve-hover-date {
  margin: 0 0 0.24rem;
  color: #d8e3f1;
  font-weight: 700;
  font-size: 0.74rem;
}

.curve-hover-row {
  margin: 0.1rem 0 0;
  font-weight: 700;
}

.curve-hover-row.realized {
  color: #b8d9ca;
}

.curve-hover-row.cash {
  color: #c5d7f2;
}

.feedback {
  margin-top: 0.8rem;
  color: #4f6174;
  font-size: 0.93rem;
  white-space: pre-line;
}

.feedback.error {
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(208, 218, 229, 0.92);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 880px;
  background: transparent;
}

.strategies-table.hide-lifecycle .strategy-col-lifecycle {
  display: none;
}

th,
td {
  text-align: left;
  padding: 0.58rem 0.52rem;
  border-bottom: 1px solid rgba(214, 223, 234, 0.86);
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #f7f9fc 0%, #f1f5f9 100%);
  color: #4d5f73;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom-color: rgba(196, 207, 220, 0.96);
}

tbody tr {
  background: rgba(255, 255, 255, 0.88);
  transition: background-color 110ms ease;
}

tbody tr:nth-child(even) {
  background: rgba(251, 253, 255, 0.92);
}

tbody tr:hover {
  background: rgba(242, 247, 253, 0.96);
}

th.has-tooltip {
  cursor: help;
  text-decoration: underline dotted rgba(74, 92, 114, 0.58);
  text-underline-offset: 0.2em;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #d6dde6;
  padding: 0.22rem 0.56rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.pill.open {
  color: #2d6d52;
  background: #eef7f2;
  border-color: #c9e2d5;
}

.pill.closed {
  color: #445668;
  background: #f1f4f8;
  border-color: #d9e0e7;
}

.mark-cell {
  display: inline-flex;
  align-items: center;
}

.mark-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #ced9e4;
  padding: 0.14rem 0.48rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: #f2f6fb;
  color: #4d6074;
}

.mark-badge.ib {
  background: #eaf7f0;
  border-color: #bedfce;
  color: #1f704d;
}

.mark-badge.fallback {
  background: #f6f1e5;
  border-color: #e4d2a4;
  color: #7a5a1e;
}

.mark-badge.na {
  background: #eff3f7;
  border-color: #d5dfea;
  color: #5b6f84;
}

.pnl-pos {
  color: #2f7a59;
  font-weight: 700;
}

.pnl-neg {
  color: #af352c;
  font-weight: 700;
}

.pnl-na {
  color: #667a90;
  font-weight: 600;
}

.pnl-estimated {
  text-decoration: underline dotted currentColor;
  text-underline-offset: 2px;
}

.legs {
  display: grid;
  gap: 0.2rem;
}

.session-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.chevron {
  display: inline-grid;
  place-items: center;
  width: 0.85rem;
  color: #54677b;
}

.strategy-summary {
  cursor: pointer;
}

.strategy-summary:hover {
  background: rgba(238, 244, 251, 0.96);
}

.strategy-summary:focus-visible {
  outline: 2px solid #4f78ab;
  outline-offset: -2px;
}

.strategy-summary.expanded {
  background: rgba(232, 240, 250, 0.98);
}

.strategy-detail td {
  background: rgba(250, 252, 255, 0.94);
  padding: 0.78rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.9rem;
  margin-bottom: 0.82rem;
}

.detail-title {
  margin: 0 0 0.28rem;
  color: #4e6176;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-window {
  margin: 0;
}

.roll-section {
  margin: 0 0 0.82rem;
}

.mini-table-wrap {
  overflow: auto;
  border: 1px solid rgba(207, 217, 228, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
}

.mini-table {
  min-width: 740px;
}

.mini-table th,
.mini-table td {
  font-size: 0.83rem;
}

.muted-text {
  color: #5a6c80;
}

.roll-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.roll-count {
  font-weight: 700;
  color: #26384d;
}

.roll-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.12rem 0.44rem;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.roll-badge-trigger {
  appearance: none;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
}

.roll-badge-trigger:focus-visible {
  outline: 2px solid #4f78ab;
  outline-offset: 2px;
}

.roll-badge.high {
  color: #1e8051;
  background: #e8f6ef;
  border-color: #c2e4d2;
}

.roll-badge.medium {
  color: #8a5a16;
  background: #fcf3e4;
  border-color: #f0d6a8;
}

.roll-badge.low,
.roll-badge.none {
  color: #586a80;
  background: #edf1f5;
  border-color: #d5dee8;
}

.roll-events {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.roll-events > .muted-text {
  margin: 0;
}

.roll-event {
  border: 1px solid #d8e2ec;
  border-radius: 10px;
  padding: 0.58rem 0.62rem;
  background: #ffffff;
}

.roll-route {
  margin: 0;
  font-size: 0.82rem;
  color: #22364d;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.roll-meta {
  margin: 0.2rem 0 0;
  font-size: 0.76rem;
  color: #586b80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.44rem;
  flex-wrap: wrap;
}

.roll-popover-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
}

.roll-confidence-label {
  color: #586b80;
}

.roll-popover {
  position: absolute;
  top: calc(100% + 0.44rem);
  left: 0;
  right: auto;
  z-index: 10;
  width: min(360px, calc(100vw - 3rem));
  border: 1px solid #d8e2ec;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 28px rgba(23, 38, 56, 0.18);
  padding: 0.52rem 0.56rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

.roll-popover-shell.align-end .roll-popover {
  left: auto;
  right: 0;
}

.roll-popover-shell:focus-within .roll-popover,
.roll-popover-shell.is-open .roll-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .roll-popover-shell:hover .roll-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }
}

.roll-popover-line {
  margin: 0;
  font-size: 0.73rem;
  color: #4f6073;
}

.roll-popover-line + .roll-popover-line {
  margin-top: 0.2rem;
}

.roll-popover .roll-reasons {
  margin-top: 0.36rem;
}

.roll-popover .roll-reasons > .muted-text {
  font-size: 0.71rem;
  margin: 0;
}

.roll-reasons {
  margin-top: 0.33rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.26rem;
}

.roll-reason {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d5dfeb;
  border-radius: 999px;
  padding: 0.08rem 0.4rem;
  font-size: 0.68rem;
  color: #4f6073;
  background: #f4f7fb;
}

.roll-window-note {
  margin: 0.02rem 0 0.36rem;
  font-size: 0.73rem;
  color: #7a5b26;
}

.db-health-modal[hidden] {
  display: none;
}

.db-health-modal {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(16, 24, 34, 0.45);
  backdrop-filter: blur(3px);
}

.db-health-dialog {
  width: min(940px, 100%);
  max-height: min(700px, calc(100vh - 2rem));
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: 18px;
  border: 1px solid rgba(201, 214, 227, 0.96);
  background: #ffffff;
  box-shadow: 0 20px 44px rgba(18, 30, 44, 0.26);
  overflow: hidden;
}

.db-health-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #d8e1ea;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f6fb 100%);
}

.db-health-dialog-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #1a2c40;
}

.db-health-dialog-body {
  overflow: auto;
  padding: 0.95rem 1.05rem 1.15rem;
  display: grid;
  gap: 0.82rem;
}

.db-health-overview {
  margin: 0;
  font-size: 0.92rem;
  color: #40556c;
}

.db-health-warning-list {
  margin: 0;
  padding: 0.62rem 0.72rem 0.62rem 1.3rem;
  border-radius: 10px;
  border: 1px solid #ebc58f;
  background: #fff7e7;
  color: #6f4e17;
  display: grid;
  gap: 0.2rem;
  font-size: 0.82rem;
}

.db-health-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.52rem;
}

.db-health-stat {
  border: 1px solid #d6e0ea;
  border-radius: 11px;
  padding: 0.48rem 0.58rem;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9fc 100%);
}

.db-health-stat .label {
  margin: 0;
  color: #54687d;
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.db-health-stat .value {
  margin: 0.18rem 0 0;
  color: #213448;
  font-size: 0.98rem;
  font-weight: 750;
}

.db-health-section {
  border: 1px solid #d8e2ed;
  border-radius: 11px;
  padding: 0.62rem 0.72rem 0.72rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfe 100%);
}

.db-health-danger-zone {
  border-color: #edc6bf;
  background: linear-gradient(180deg, #fffafa 0%, #fff2f0 100%);
}

#db-health-action-feedback {
  margin-top: 0.5rem;
  min-height: 1.3rem;
}

.db-health-section h3 {
  margin: 0 0 0.44rem;
  color: #22374e;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.db-health-kv-grid {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(160px, 240px) minmax(0, 1fr);
  gap: 0.24rem 0.7rem;
}

.db-health-kv-grid dt {
  margin: 0;
  color: #516579;
  font-size: 0.79rem;
  font-weight: 700;
}

.db-health-kv-grid dd {
  margin: 0;
  color: #1f3348;
  font-size: 0.81rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.db-health-table-wrap {
  border-radius: 10px;
}

.db-health-table {
  min-width: 420px;
}

.db-health-table td:nth-child(2),
.db-health-table td:nth-child(3) {
  font-variant-numeric: tabular-nums;
}

body.settings-modal-open {
  overflow: hidden;
}

.settings-modal[hidden] {
  display: none;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(16, 24, 34, 0.45);
  backdrop-filter: blur(3px);
}

.settings-dialog {
  width: min(860px, 100%);
  max-height: min(660px, calc(100vh - 2rem));
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: 18px;
  border: 1px solid rgba(201, 214, 227, 0.96);
  background: #ffffff;
  box-shadow: 0 20px 44px rgba(18, 30, 44, 0.26);
  overflow: hidden;
}

.settings-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #d8e1ea;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f6fb 100%);
}

.settings-dialog-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #1a2c40;
}

.settings-close {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #c8d6e3;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  color: #4c6178;
  box-shadow: none;
}

.settings-close:hover {
  transform: none;
  box-shadow: none;
}

.settings-dialog-body {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 300px;
}

.settings-nav {
  background: linear-gradient(180deg, #f7fafe 0%, #f0f5fa 100%);
  border-right: 1px solid #d9e3ed;
  padding: 0.75rem 0.5rem;
  display: grid;
  align-content: start;
  gap: 0.35rem;
}

.settings-nav-item {
  justify-content: flex-start;
  text-align: left;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.56rem 0.62rem;
  font-size: 0.9rem;
  font-weight: 650;
  background: transparent;
  color: #485f77;
  box-shadow: none;
}

.settings-nav-item:hover {
  transform: none;
  box-shadow: none;
  border-color: #c7d6e5;
  background: rgba(255, 255, 255, 0.84);
}

.settings-nav-item.is-active {
  border-color: #acc3db;
  background: linear-gradient(180deg, #ffffff 0%, #eef4fb 100%);
  color: #244a76;
}

.settings-pane {
  padding: 1rem 1.15rem 1.2rem;
}

.settings-pane h3 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: 1rem;
  color: #1a2f45;
}

.theme-options {
  margin: 0;
  border: 1px solid #d5e0eb;
  border-radius: 12px;
  padding: 0.75rem;
  max-width: 350px;
  display: grid;
  gap: 0.45rem;
  background: linear-gradient(180deg, #ffffff 0%, #f5f9fd 100%);
}

.theme-options legend {
  padding: 0 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #52687f;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid #d6e1ec;
  border-radius: 10px;
  padding: 0.52rem 0.56rem;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.theme-option:hover {
  border-color: #b7c9dd;
  background: #f8fbff;
}

.theme-option input {
  accent-color: var(--brand);
}

.theme-option span {
  font-size: 0.9rem;
  color: #2e4155;
  font-weight: 600;
}

.theme-option:has(input:focus-visible) {
  box-shadow: 0 0 0 3px rgba(47, 110, 167, 0.2);
}

.theme-option:has(input:checked) {
  border-color: #9eb8d5;
  background: #eef5fc;
}

.settings-note {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  color: #556a80;
}

.market-data-options {
  max-width: 430px;
}

.settings-field {
  display: grid;
  gap: 0.28rem;
}

.settings-field span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #4b6078;
  text-transform: uppercase;
}

.settings-field input {
  width: 100%;
  border: 1px solid #cad7e4;
  border-radius: 10px;
  padding: 0.44rem 0.52rem;
  font: inherit;
  font-size: 0.9rem;
  color: #2a3f56;
  background: #ffffff;
}

.settings-field input:focus-visible {
  outline: 0;
  border-color: #7ea2ca;
  box-shadow: 0 0 0 3px rgba(47, 110, 167, 0.2);
}

.settings-button-row {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  margin-top: 0.2rem;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1620;
  --bg-soft: #0b121a;
  --ink: #ebf1f8;
  --ink-soft: #c6d2e0;
  --muted: #9aaabc;
  --panel: rgba(22, 30, 40, 0.94);
  --panel-strong: #172230;
  --line: #2d3b4d;
  --line-strong: #3c4d62;
  --brand: #6d9ed5;
  --brand-strong: #4f7fad;
  --brand-soft: #1e2c3d;
  --brand-ink: #b9d3ef;
  --cash: #75a6ff;
  --cash-soft: #1d2f4d;
  --realized: #64c496;
  --realized-soft: #1a352b;
  --danger: #ff7b74;
  --shadow-soft: 0 12px 30px rgba(3, 8, 13, 0.44);
  --shadow-strong: 0 18px 38px rgba(3, 8, 13, 0.56);
}

html[data-theme="dark"] body {
  background: #0f1620;
}

html[data-theme="dark"] body::before {
  background-image:
    linear-gradient(rgba(138, 164, 191, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138, 164, 191, 0.08) 1px, transparent 1px);
}

html[data-theme="dark"] body::after {
  background:
    radial-gradient(100% 84% at 8% -10%, rgba(105, 152, 212, 0.18) 0%, rgba(105, 152, 212, 0) 52%),
    radial-gradient(90% 72% at 100% 0%, rgba(84, 120, 166, 0.16) 0%, rgba(84, 120, 166, 0) 55%),
    linear-gradient(180deg, #0f1620 0%, #0b1118 100%);
}

html[data-theme="dark"] .header {
  border-color: #324356;
  background:
    radial-gradient(circle at 0% 0%, rgba(117, 160, 216, 0.15) 0%, rgba(117, 160, 216, 0) 46%),
    radial-gradient(circle at 100% 0%, rgba(126, 151, 184, 0.15) 0%, rgba(126, 151, 184, 0) 44%),
    linear-gradient(145deg, rgba(25, 35, 47, 0.98) 0%, rgba(21, 30, 40, 0.98) 100%);
}

html[data-theme="dark"] .header::after {
  background: radial-gradient(circle, rgba(95, 138, 196, 0.16) 0%, rgba(95, 138, 196, 0) 72%);
}

html[data-theme="dark"] .header h1 {
  color: #eef4fb;
}

html[data-theme="dark"] .mark-status-chip {
  border-color: #4a6079;
  background: linear-gradient(180deg, #253749 0%, #1f2f40 100%);
  color: #c8d7e8;
}

html[data-theme="dark"] .auth-user-chip {
  border-color: #4a6079;
  background: linear-gradient(180deg, #253749 0%, #1f2f40 100%);
  color: #c8d7e8;
}

html[data-theme="dark"] .mark-status-chip.is-live {
  border-color: #4d7c64;
  background: linear-gradient(180deg, #234235 0%, #1d352b 100%);
  color: #bde3cd;
}

html[data-theme="dark"] .mark-status-chip.is-offline {
  border-color: #4a6079;
  background: linear-gradient(180deg, #253749 0%, #1f2f40 100%);
  color: #c8d7e8;
}

html[data-theme="dark"] .db-health-chip {
  border-color: #4a6079;
  background: linear-gradient(180deg, #253749 0%, #1f2f40 100%);
  color: #c8d7e8;
}

html[data-theme="dark"] .db-health-chip.is-healthy {
  border-color: #4d7c64;
  background: linear-gradient(180deg, #234235 0%, #1d352b 100%);
  color: #bde3cd;
}

html[data-theme="dark"] .db-health-chip.is-warning {
  border-color: #7f6a3a;
  background: linear-gradient(180deg, #433620 0%, #392c17 100%);
  color: #e7d1aa;
}

html[data-theme="dark"] .db-health-chip.is-error {
  border-color: #8b554f;
  background: linear-gradient(180deg, #4b2b2a 0%, #3f2423 100%);
  color: #efc2bc;
}

html[data-theme="dark"] .settings-trigger {
  border-color: #3d5068;
  background: linear-gradient(180deg, #223142 0%, #1a2634 100%);
  color: #d7e5f4;
  box-shadow: 0 8px 14px rgba(7, 13, 20, 0.42);
}

html[data-theme="dark"] .settings-trigger:hover {
  border-color: #4c6480;
  background: linear-gradient(180deg, #27384b 0%, #1d2c3c 100%);
}

html[data-theme="dark"] .auth-action.secondary {
  border-color: #4a6079;
  background: linear-gradient(180deg, #2a3d51 0%, #223244 100%);
  color: #d9e6f4;
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .mini-table-wrap,
html[data-theme="dark"] .settings-dialog,
html[data-theme="dark"] .db-health-dialog {
  border-color: #334457;
  background: rgba(21, 31, 42, 0.95);
}

html[data-theme="dark"] .panel::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0) 38%);
}

html[data-theme="dark"] .app-footer,
html[data-theme="dark"] .legal-header,
html[data-theme="dark"] .legal-panel {
  border-color: #3a4e64;
  background: rgba(25, 35, 47, 0.95);
}

html[data-theme="dark"] .legal-warning {
  border-color: #7e6a40;
  background: #3c301d;
  color: #efd8af;
}

html[data-theme="dark"] .app-footer-links a,
html[data-theme="dark"] .legal-panel a {
  color: #8fb8e5;
}

html[data-theme="dark"] .legal-kicker,
html[data-theme="dark"] .legal-kv dt {
  color: #afc2d7;
}

html[data-theme="dark"] .legal-header h1,
html[data-theme="dark"] .legal-panel h2,
html[data-theme="dark"] .legal-panel p,
html[data-theme="dark"] .legal-panel li,
html[data-theme="dark"] .legal-panel dd {
  color: #dbe8f6;
}

html[data-theme="dark"] .legal-nav a {
  border-color: #4c6380;
  background: linear-gradient(180deg, #2a3d51 0%, #223244 100%);
  color: #d3e3f5;
}

html[data-theme="dark"] .legal-nav a[aria-current="page"] {
  border-color: #6f91b7;
  background: linear-gradient(180deg, #324862 0%, #283b53 100%);
  color: #e5effa;
}

html[data-theme="dark"] .panel h2,
html[data-theme="dark"] .settings-dialog-head h2,
html[data-theme="dark"] .settings-pane h3,
html[data-theme="dark"] .db-health-dialog-head h2 {
  color: #e4edf8;
}

html[data-theme="dark"] .db-health-dialog-head {
  border-bottom-color: #3e5168;
  background: linear-gradient(180deg, #263849 0%, #1f2e3d 100%);
}

html[data-theme="dark"] .db-health-overview {
  color: #b9c9db;
}

html[data-theme="dark"] .db-health-warning-list {
  border-color: #7e6a40;
  background: #3c301d;
  color: #efd8af;
}

html[data-theme="dark"] .db-health-stat,
html[data-theme="dark"] .db-health-section {
  border-color: #42566f;
  background: #1d2b3a;
}

html[data-theme="dark"] .db-health-stat .label,
html[data-theme="dark"] .db-health-kv-grid dt {
  color: #a9bdd2;
}

html[data-theme="dark"] .db-health-stat .value,
html[data-theme="dark"] .db-health-kv-grid dd,
html[data-theme="dark"] .db-health-section h3 {
  color: #e0ebf8;
}

html[data-theme="dark"] .table-view-tablist {
  border-color: #42566f;
  background: linear-gradient(180deg, #243446 0%, #1e2d3e 100%);
}

html[data-theme="dark"] .table-view-tab {
  color: #b9c9dc;
}

html[data-theme="dark"] .table-view-tab:hover {
  border-color: #58708d;
  background: rgba(54, 73, 96, 0.85);
}

html[data-theme="dark"] .table-view-tab.is-active {
  border-color: #6382a7;
  background: linear-gradient(180deg, #2f4560 0%, #273b53 100%);
  color: #e3eefb;
}

html[data-theme="dark"] .table-view-count {
  color: #9cb1c8;
}

html[data-theme="dark"] .table-view-tab.is-active .table-view-count {
  color: #d0dff0;
}

html[data-theme="dark"] .table-view-panel h3 {
  color: #d8e4f2;
}

html[data-theme="dark"] .stat {
  border-color: #3a4a5f;
  background: linear-gradient(180deg, rgba(28, 39, 52, 0.96) 0%, rgba(23, 33, 45, 0.98) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .stat::before {
  background: linear-gradient(90deg, #4f6786 0%, #4d617a 100%);
}

html[data-theme="dark"] .stat .label {
  color: #afbdd0;
}

html[data-theme="dark"] .stat .value {
  color: #e2ecf8;
}

html[data-theme="dark"] .drop-zone {
  border-color: #49607a;
  background:
    radial-gradient(circle at 50% 0%, rgba(122, 163, 215, 0.18), transparent 62%),
    linear-gradient(180deg, #182432 0%, #131e2a 100%);
}

html[data-theme="dark"] .drop-zone:hover {
  border-color: #5b76a0;
}

html[data-theme="dark"] button.secondary {
  background: linear-gradient(180deg, #253444 0%, #1a2735 100%);
  border-color: #3f536d;
  color: #d8e5f2;
}

html[data-theme="dark"] .curve-shell {
  border-color: #3a4e64;
  background:
    radial-gradient(circle at 10% 0%, rgba(97, 139, 192, 0.19) 0%, rgba(97, 139, 192, 0) 44%),
    radial-gradient(circle at 92% 0%, rgba(126, 156, 194, 0.17) 0%, rgba(126, 156, 194, 0) 45%),
    linear-gradient(165deg, rgba(25, 35, 47, 0.98) 0%, rgba(20, 29, 39, 0.98) 100%);
}

html[data-theme="dark"] .curve-empty {
  border-color: #465a72;
  background: linear-gradient(180deg, rgba(24, 35, 48, 0.95) 0%, rgba(21, 31, 43, 0.95) 100%);
}

html[data-theme="dark"] .curve-plot-bg {
  fill: rgba(22, 34, 47, 0.9);
  stroke: rgba(130, 153, 179, 0.28);
}

html[data-theme="dark"] .curve-grid-line {
  stroke: rgba(139, 162, 188, 0.2);
}

html[data-theme="dark"] .curve-zero-line {
  stroke: rgba(179, 197, 219, 0.44);
}

html[data-theme="dark"] .curve-axis-label {
  fill: #a7b8ca;
}

html[data-theme="dark"] .curve-pill.stamp {
  background: #273545;
  border-color: #3c5168;
  color: #d2e0ef;
}

html[data-theme="dark"] .curve-hover-tooltip {
  background: rgba(11, 17, 26, 0.94);
  border-color: rgba(134, 155, 182, 0.3);
}

html[data-theme="dark"] th {
  background: linear-gradient(180deg, #243343 0%, #1f2d3c 100%);
  color: #c5d4e6;
  border-bottom-color: rgba(80, 100, 122, 0.92);
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-bottom-color: rgba(71, 92, 114, 0.86);
}

html[data-theme="dark"] tbody tr {
  background: rgba(20, 30, 40, 0.96);
}

html[data-theme="dark"] tbody tr:nth-child(even) {
  background: rgba(24, 36, 49, 0.98);
}

html[data-theme="dark"] tbody tr:hover,
html[data-theme="dark"] .strategy-summary:hover {
  background: rgba(37, 52, 69, 0.96);
}

html[data-theme="dark"] .strategy-summary.expanded {
  background: rgba(43, 58, 75, 0.98);
}

html[data-theme="dark"] .strategy-detail td {
  background: rgba(24, 36, 49, 0.96);
}

html[data-theme="dark"] .pill.closed {
  background: #2a384a;
  border-color: #455a71;
  color: #c5d3e2;
}

html[data-theme="dark"] .pill.open {
  background: #223b32;
  border-color: #3e6256;
  color: #b8d8ca;
}

html[data-theme="dark"] .mark-badge {
  border-color: #4f6580;
  background: #27384b;
  color: #c9d9ea;
}

html[data-theme="dark"] .mark-badge.ib {
  border-color: #49715f;
  background: #254336;
  color: #bfe4ce;
}

html[data-theme="dark"] .mark-badge.fallback {
  border-color: #75603a;
  background: #3f3320;
  color: #e8d1a3;
}

html[data-theme="dark"] .mark-badge.na {
  border-color: #4f6580;
  background: #27384b;
  color: #c9d9ea;
}

html[data-theme="dark"] .pnl-na {
  color: #9eb2c8;
}

html[data-theme="dark"] .pnl-estimated {
  text-decoration-thickness: 1px;
}

html[data-theme="dark"] .roll-count {
  color: #d5e2f1;
}

html[data-theme="dark"] .roll-badge.high {
  color: #bde7d0;
  background: #27493d;
  border-color: #466f5f;
}

html[data-theme="dark"] .roll-badge.medium {
  color: #f0dcb0;
  background: #4a3b22;
  border-color: #725b2f;
}

html[data-theme="dark"] .roll-badge.low,
html[data-theme="dark"] .roll-badge.none {
  color: #c7d5e6;
  background: #2a394b;
  border-color: #4a6178;
}

html[data-theme="dark"] .roll-badge-trigger:focus-visible {
  outline-color: #88a8cd;
}

html[data-theme="dark"] .roll-section {
  border-color: #42566f;
  background: rgba(29, 43, 58, 0.62);
}

html[data-theme="dark"] .roll-event {
  border-color: #42566f;
  background: #1d2b3a;
}

html[data-theme="dark"] .roll-route {
  color: #dce8f6;
}

html[data-theme="dark"] .roll-meta {
  color: #aec2d8;
}

html[data-theme="dark"] .roll-confidence-label {
  color: #aec2d8;
}

html[data-theme="dark"] .roll-popover {
  border-color: #4a6078;
  background: #1a2735;
  box-shadow: 0 14px 28px rgba(5, 9, 14, 0.52);
}

html[data-theme="dark"] .roll-popover-line {
  color: #c6d6e7;
}

html[data-theme="dark"] .roll-reason {
  border-color: #4a6078;
  color: #c6d6e7;
  background: #27384b;
}

html[data-theme="dark"] .roll-window-note {
  color: #e0bf84;
}

html[data-theme="dark"] .settings-dialog-head {
  border-bottom-color: #3e5168;
  background: linear-gradient(180deg, #263849 0%, #1f2e3d 100%);
}

html[data-theme="dark"] .settings-close {
  border-color: #4a6079;
  background: linear-gradient(180deg, #2a3d51 0%, #223244 100%);
  color: #d9e6f4;
}

html[data-theme="dark"] .settings-nav {
  border-right-color: #3f536a;
  border-color: #3f536a;
  background: linear-gradient(180deg, #223143 0%, #1d2a3a 100%);
}

html[data-theme="dark"] .settings-nav-item {
  color: #c6d5e6;
}

html[data-theme="dark"] .settings-nav-item:hover {
  border-color: #4e6580;
  background: rgba(48, 66, 86, 0.85);
}

html[data-theme="dark"] .settings-nav-item.is-active {
  border-color: #5e7da2;
  background: linear-gradient(180deg, #324862 0%, #283b53 100%);
  color: #e5effa;
}

html[data-theme="dark"] .theme-options {
  border-color: #40556f;
  background: linear-gradient(180deg, #202f40 0%, #1a2736 100%);
}

html[data-theme="dark"] .theme-options legend {
  color: #aec2d7;
}

html[data-theme="dark"] .theme-option {
  border-color: #485f7a;
  background: #1d2b3a;
}

html[data-theme="dark"] .theme-option:hover {
  border-color: #6483a7;
  background: #223346;
}

html[data-theme="dark"] .theme-option span {
  color: #dbe8f6;
}

html[data-theme="dark"] .theme-option:has(input:checked) {
  border-color: #6f91b7;
  background: #2a3f58;
}

html[data-theme="dark"] .settings-note {
  color: #a8bdd4;
}

html[data-theme="dark"] .settings-field span {
  color: #aec2d7;
}

html[data-theme="dark"] .settings-field input {
  border-color: #4a6079;
  background: #1d2b3a;
  color: #d9e6f4;
}

html[data-theme="dark"] .settings-field input:focus-visible {
  border-color: #6b8db3;
  box-shadow: 0 0 0 3px rgba(109, 158, 213, 0.24);
}

html[data-theme="high_contrast"] {
  --bg: #ffffff;
  --bg-soft: #ffffff;
  --ink: #000000;
  --ink-soft: #000000;
  --muted: #111111;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --line: #000000;
  --line-strong: #000000;
  --brand: #005fcc;
  --brand-strong: #004599;
  --brand-soft: #ffffff;
  --brand-ink: #00366f;
  --cash: #0047aa;
  --cash-soft: #ffffff;
  --realized: #006f3f;
  --realized-soft: #ffffff;
  --danger: #9f0000;
  --shadow-soft: none;
  --shadow-strong: none;
}

html[data-theme="high_contrast"] body {
  background: #ffffff;
}

html[data-theme="high_contrast"] body::before {
  display: none;
}

html[data-theme="high_contrast"] body::after {
  display: none;
}

html[data-theme="high_contrast"] .header,
html[data-theme="high_contrast"] .panel,
html[data-theme="high_contrast"] .table-wrap,
html[data-theme="high_contrast"] .mini-table-wrap,
html[data-theme="high_contrast"] .settings-dialog,
html[data-theme="high_contrast"] .db-health-dialog,
html[data-theme="high_contrast"] .theme-options,
html[data-theme="high_contrast"] .theme-option,
html[data-theme="high_contrast"] .app-footer,
html[data-theme="high_contrast"] .legal-header,
html[data-theme="high_contrast"] .legal-panel,
html[data-theme="high_contrast"] .legal-warning {
  border-color: #000000 !important;
  background: #ffffff !important;
  box-shadow: none !important;
}

html[data-theme="high_contrast"] .header::after,
html[data-theme="high_contrast"] .panel::before,
html[data-theme="high_contrast"] .drop-zone::before {
  display: none;
}

html[data-theme="high_contrast"] .drop-zone {
  border-color: #000000;
  background: #ffffff;
}

html[data-theme="high_contrast"] .drop-zone.drag-over {
  background: #eaf2ff;
}

html[data-theme="high_contrast"] .settings-trigger,
html[data-theme="high_contrast"] .settings-close,
html[data-theme="high_contrast"] button.secondary {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
  box-shadow: none;
}

html[data-theme="high_contrast"] button {
  background: #004da8;
  color: #ffffff;
  border: 2px solid #003d84;
  box-shadow: none;
}

html[data-theme="high_contrast"] .settings-nav {
  border-right: 2px solid #000000;
  border-color: #000000;
  background: #ffffff;
}

html[data-theme="high_contrast"] .table-view-tablist {
  border: 2px solid #000000;
  background: #ffffff;
}

html[data-theme="high_contrast"] .table-view-tab {
  border: 2px solid transparent;
  background: #ffffff;
  color: #000000;
}

html[data-theme="high_contrast"] .table-view-tab:hover {
  border-color: #000000;
  background: #ffffff;
}

html[data-theme="high_contrast"] .table-view-tab.is-active {
  border-color: #000000;
  background: #eaf2ff;
  color: #000000;
}

html[data-theme="high_contrast"] .table-view-count,
html[data-theme="high_contrast"] .table-view-tab.is-active .table-view-count,
html[data-theme="high_contrast"] .table-view-panel h3 {
  color: #000000;
}

html[data-theme="high_contrast"] .settings-nav-item {
  color: #000000;
  border: 2px solid transparent;
  background: #ffffff;
}

html[data-theme="high_contrast"] .settings-nav-item.is-active {
  border-color: #000000;
  background: #eef4ff;
}

html[data-theme="high_contrast"] .settings-note {
  color: #000000;
}

html[data-theme="high_contrast"] .app-footer-links a,
html[data-theme="high_contrast"] .legal-panel a {
  color: #003d84;
}

html[data-theme="high_contrast"] .legal-nav a {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
}

html[data-theme="high_contrast"] .legal-nav a[aria-current="page"] {
  background: #eaf2ff;
}

html[data-theme="high_contrast"] .settings-field input {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
  box-shadow: none;
}

html[data-theme="high_contrast"] .settings-field input:focus-visible {
  box-shadow: none;
}

html[data-theme="high_contrast"] .settings-modal {
  background: rgba(0, 0, 0, 0.45);
}

html[data-theme="high_contrast"] .db-health-modal {
  background: rgba(0, 0, 0, 0.45);
}

html[data-theme="high_contrast"] .mark-status-chip,
html[data-theme="high_contrast"] .db-health-chip,
html[data-theme="high_contrast"] .mark-badge,
html[data-theme="high_contrast"] .auth-user-chip {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
}

html[data-theme="high_contrast"] .auth-action {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
  box-shadow: none;
}

html[data-theme="high_contrast"] .db-health-warning-list,
html[data-theme="high_contrast"] .db-health-stat,
html[data-theme="high_contrast"] .db-health-section {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
}

html[data-theme="high_contrast"] .db-health-dialog-head {
  border-bottom: 2px solid #000000;
  background: #ffffff;
}

html[data-theme="high_contrast"] .curve-shell,
html[data-theme="high_contrast"] .curve-empty,
html[data-theme="high_contrast"] .curve-plot-bg {
  background: #ffffff !important;
  border-color: #000000 !important;
}

html[data-theme="high_contrast"] .curve-grid-line {
  stroke: rgba(0, 0, 0, 0.22);
}

html[data-theme="high_contrast"] .curve-zero-line {
  stroke: rgba(0, 0, 0, 0.75);
}

html[data-theme="high_contrast"] th,
html[data-theme="high_contrast"] td {
  color: #000000;
  border-bottom-color: #000000;
}

html[data-theme="high_contrast"] th {
  background: #ffffff !important;
}

html[data-theme="high_contrast"] tbody tr,
html[data-theme="high_contrast"] tbody tr:nth-child(even),
html[data-theme="high_contrast"] tbody tr:hover,
html[data-theme="high_contrast"] .strategy-summary:hover,
html[data-theme="high_contrast"] .strategy-summary.expanded,
html[data-theme="high_contrast"] .strategy-detail td {
  background: #ffffff;
}

html[data-theme="high_contrast"] .pill,
html[data-theme="high_contrast"] .pill.open,
html[data-theme="high_contrast"] .pill.closed,
html[data-theme="high_contrast"] .curve-pill.realized,
html[data-theme="high_contrast"] .curve-pill.cash,
html[data-theme="high_contrast"] .curve-pill.stamp {
  background: #ffffff;
  border-color: #000000;
  color: #000000;
}

html[data-theme="high_contrast"] .roll-count,
html[data-theme="high_contrast"] .roll-badge,
html[data-theme="high_contrast"] .roll-route,
html[data-theme="high_contrast"] .roll-meta,
html[data-theme="high_contrast"] .roll-confidence-label,
html[data-theme="high_contrast"] .roll-popover-line,
html[data-theme="high_contrast"] .roll-reason,
html[data-theme="high_contrast"] .roll-window-note {
  color: #000000;
}

html[data-theme="high_contrast"] .roll-badge,
html[data-theme="high_contrast"] .roll-event,
html[data-theme="high_contrast"] .roll-reason {
  border-color: #000000;
  background: #ffffff;
}

html[data-theme="high_contrast"] .roll-section {
  border-color: #000000;
  background: #ffffff;
}

html[data-theme="high_contrast"] .roll-badge-trigger {
  border-width: 2px;
}

html[data-theme="high_contrast"] .roll-badge-trigger:focus-visible {
  outline-color: #000000;
}

html[data-theme="high_contrast"] .roll-popover {
  border: 2px solid #000000;
  background: #ffffff;
  box-shadow: none;
}

html[data-theme="high_contrast"] .pnl-na {
  color: #000000;
}

html[data-theme="high_contrast"] .pnl-estimated {
  text-decoration-thickness: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(238, 243, 248, 0.95);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #b4c2d2 0%, #8ea3bb 100%);
  border-radius: 999px;
  border: 2px solid rgba(238, 243, 248, 1);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #9fb2c8 0%, #778ea8 100%);
}

.header,
.panel {
  opacity: 0;
  transform: translateY(16px);
  animation: rise-in 520ms cubic-bezier(0.2, 0.82, 0.2, 1) forwards;
}

.header {
  animation-delay: 20ms;
}

main.layout > .panel:nth-of-type(1) {
  animation-delay: 70ms;
}

main.layout > .panel:nth-of-type(2) {
  animation-delay: 130ms;
}

main.layout > .panel:nth-of-type(3) {
  animation-delay: 190ms;
}

main.layout > .panel:nth-of-type(4) {
  animation-delay: 250ms;
}

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

@media (max-width: 1080px) {
  .layout {
    width: min(100%, calc(100% - 1.4rem));
    padding-top: 1.5rem;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-controls {
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .layout {
    width: min(100%, calc(100% - 1rem));
    padding: 0.95rem 0 1.7rem;
    gap: 0.85rem;
  }

  .header {
    border-radius: 16px;
    padding: 1rem 0.95rem 0.95rem;
  }

  .header p {
    padding-right: 0;
    margin-bottom: 0.72rem;
  }

  .header-actions {
    position: static;
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .auth-user-chip,
  .mark-status-chip,
  .db-health-chip {
    max-width: calc(100% - 3.1rem);
  }

  .panel {
    border-radius: 15px;
    padding: 0.82rem;
  }

  .table-view-head {
    align-items: stretch;
    gap: 0.55rem;
  }

  .table-view-tablist {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .table-view-tab {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .table-view-panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .table-view-panel h3 {
    font-size: 0.93rem;
  }

  .period-controls,
  .table-controls,
  .curve-controls {
    align-items: stretch;
  }

  .period-controls label,
  .curve-controls label {
    width: 100%;
  }

  .table-controls input[type="search"],
  .table-controls select,
  .period-controls select,
  .period-controls input[type="date"],
  .period-controls button,
  .curve-controls select {
    width: 100%;
    min-width: 0;
  }

  .curve-head {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pnl-curve {
    height: 250px;
    min-height: 210px;
  }

  .curve-pill {
    font-size: 0.74rem;
  }

  .settings-modal {
    padding: 0.55rem;
  }

  .db-health-modal {
    padding: 0.55rem;
  }

  .settings-dialog {
    max-height: calc(100vh - 1.1rem);
    border-radius: 14px;
  }

  .db-health-dialog {
    max-height: calc(100vh - 1.1rem);
    border-radius: 14px;
  }

  .settings-dialog-body {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .db-health-dialog-body {
    padding: 0.86rem;
  }

  .settings-nav {
    border-right: 0;
    border-bottom: 1px solid #d9e3ed;
    grid-auto-flow: column;
    grid-auto-columns: minmax(120px, max-content);
    overflow-x: auto;
    padding: 0.45rem;
  }

  .settings-nav-item {
    white-space: nowrap;
  }

  .settings-pane {
    padding: 0.88rem;
  }

  .theme-options {
    max-width: 100%;
  }

  .db-health-kv-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.16rem;
  }

  .legal-layout {
    width: min(100%, calc(100% - 1rem));
    padding: 0.95rem 0 1.7rem;
  }

  .legal-header,
  .legal-panel,
  .legal-warning {
    border-radius: 15px;
  }

  .legal-kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.12rem;
  }
}

@media (max-width: 520px) {
  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .curve-hover-tooltip {
    min-width: 148px;
    font-size: 0.74rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Auth + legal redesign */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.6rem 1rem;
  background: linear-gradient(180deg, #f3f4f7 0%, #eceff4 100%);
}

.auth-page::before,
.auth-page::after {
  display: none;
}

.auth-layout {
  width: min(430px, 100%);
  margin: 0;
  padding: 0;
}

.auth-card {
  border: 1px solid #d9dde6;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 18px 36px rgba(24, 33, 47, 0.1);
  padding: 1.5rem 1.35rem 1.2rem;
  display: grid;
  gap: 0.78rem;
}

.auth-header {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
}

.auth-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  text-decoration: none;
  color: inherit;
}

.auth-logo {
  width: 1.48rem;
  height: 1.48rem;
  display: block;
}

.auth-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2rem);
  color: #161e2d;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 0;
  color: #5d6878;
  font-size: 0.9rem;
  line-height: 1.45;
}

.auth-form {
  margin: 0;
  display: grid;
  gap: 0.62rem;
}

.auth-field {
  margin: 0;
  display: grid;
  gap: 0.26rem;
}

.auth-field label {
  color: #49566a;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.auth-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #d5dce6;
  border-radius: 10px;
  background: #f8f9fc;
  color: #1a2535;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.3;
  padding: 0.56rem 0.78rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.auth-input::placeholder {
  color: #9aa5b7;
}

.auth-input:focus-visible {
  border-color: #5c84d9;
  box-shadow: 0 0 0 3px rgba(74, 119, 216, 0.24);
  outline: none;
}

.auth-password-wrap {
  position: relative;
  display: block;
}

.auth-password-wrap .auth-input {
  padding-right: 4.1rem;
}

.auth-toggle {
  position: absolute;
  right: 0.34rem;
  top: 50%;
  transform: translateY(-50%);
  min-height: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #657389;
  padding: 0.24rem 0.5rem;
  font-size: 0.77rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}

.auth-toggle:hover {
  transform: translateY(-50%);
  background: #e9eef8;
  color: #33465f;
}

.auth-toggle:focus-visible {
  transform: translateY(-50%);
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 119, 216, 0.24);
}

.auth-primary,
.auth-secondary {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.auth-primary {
  border: 1px solid #406ac4;
  background: linear-gradient(180deg, #5b84dc 0%, #4e78d3 100%);
  color: #ffffff;
}

.auth-primary:hover {
  border-color: #355db6;
  background: linear-gradient(180deg, #527cd7 0%, #456cc4 100%);
  transform: none;
  box-shadow: none;
}

.auth-primary:active {
  transform: none;
}

.auth-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 119, 216, 0.25);
}

.auth-secondary {
  border: 1px solid #d4dbe5;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7fb 100%);
  color: #2f3a4c;
}

.auth-secondary:hover {
  border-color: #c2ccd9;
  background: linear-gradient(180deg, #ffffff 0%, #eff3f9 100%);
  transform: none;
  box-shadow: none;
}

.auth-secondary:active {
  transform: none;
}

.auth-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 119, 216, 0.18);
}

.auth-secondary-link {
  margin-top: 0.2rem;
}

.auth-provider-form {
  margin-bottom: 0;
}

.auth-divider {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.58rem;
  color: #7f8b9e;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e0e5ec;
}

.auth-inline-note {
  margin: 0;
  color: #47566d;
  font-size: 0.86rem;
  line-height: 1.4;
}

.auth-notice,
.auth-error {
  border-radius: 10px;
  padding: 0.62rem 0.75rem;
}

.auth-notice p,
.auth-error p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.38;
}

.auth-notice {
  border: 1px solid #c4d6f2;
  background: linear-gradient(180deg, #f3f8ff 0%, #e9f1fd 100%);
  color: #2b4f87;
}

.auth-error {
  border: 1px solid #e4c1c1;
  background: linear-gradient(180deg, #fff4f4 0%, #ffecec 100%);
  color: #8a2f2f;
}

.auth-links {
  margin: 0;
  text-align: center;
  color: #5f6a7a;
  font-size: 0.88rem;
}

.auth-links a {
  color: #365f98;
  font-weight: 600;
  text-decoration: none;
}

.auth-links a:hover {
  color: #234d84;
  text-decoration: underline;
}

.auth-links-spaced {
  margin-top: 0.34rem;
}

.auth-legal-links {
  margin-top: 0.22rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.46rem;
  color: #6d798a;
  font-size: 0.8rem;
}

.auth-legal-links a {
  color: #546882;
  text-decoration: none;
}

.auth-legal-links a:hover {
  color: #314e73;
  text-decoration: underline;
}

.legal-doc-page {
  min-height: 100vh;
}

.legal-shell {
  width: min(980px, calc(100% - 2rem));
  padding: 1.45rem 0 2.2rem;
  gap: 0.85rem;
}

.legal-hero,
.legal-content,
.legal-alert {
  border: 1px solid #d9dde6;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 30px rgba(23, 33, 47, 0.08);
}

.legal-hero {
  padding: 1.08rem 1.12rem;
}

.legal-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 999px;
  text-decoration: none;
}

.legal-logo {
  width: 1.24rem;
  height: 1.24rem;
  display: block;
}

.legal-hero .legal-kicker {
  margin-top: 0.45rem;
}

.legal-hero h1 {
  margin: 0.28rem 0 0.7rem;
  font-size: clamp(1.3rem, 2.2vw, 1.9rem);
}

.legal-nav-minimal {
  gap: 0.4rem;
}

.legal-nav-minimal a {
  border-radius: 999px;
  padding: 0.26rem 0.66rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.legal-content {
  padding: 1.08rem 1.14rem;
}

.legal-content h2 {
  margin: 1.15rem 0 0.46rem;
}

.legal-content h2:first-child {
  margin-top: 0;
}

.legal-alert {
  padding: 0.75rem 0.92rem;
}

.legal-alert p {
  margin: 0;
}

.legal-alert p + p {
  margin-top: 0.42rem;
}

html[data-theme="dark"] .auth-page {
  background: linear-gradient(180deg, #131922 0%, #0f151d 100%);
}

html[data-theme="dark"] .auth-card {
  border-color: #2e3a4b;
  background: #161f2a;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .auth-logo,
html[data-theme="dark"] .legal-logo {
  filter: brightness(2.2);
}

html[data-theme="dark"] .auth-header h1 {
  color: #f2f6fd;
}

html[data-theme="dark"] .auth-subtitle,
html[data-theme="dark"] .auth-inline-note,
html[data-theme="dark"] .auth-links,
html[data-theme="dark"] .auth-legal-links {
  color: #aab8ca;
}

html[data-theme="dark"] .auth-field label {
  color: #b7c4d5;
}

html[data-theme="dark"] .auth-input {
  border-color: #36475c;
  background: #0f1620;
  color: #eff4fb;
  box-shadow: none;
}

html[data-theme="dark"] .auth-input::placeholder {
  color: #6f8198;
}

html[data-theme="dark"] .auth-input:focus-visible {
  border-color: #7da3ee;
  box-shadow: 0 0 0 3px rgba(106, 149, 229, 0.28);
}

html[data-theme="dark"] .auth-toggle {
  color: #9aacbe;
}

html[data-theme="dark"] .auth-toggle:hover {
  background: #1d2938;
  color: #c6d2e1;
}

html[data-theme="dark"] .auth-secondary {
  border-color: #3a4a61;
  background: linear-gradient(180deg, #1b2735 0%, #172231 100%);
  color: #d8e1ed;
}

html[data-theme="dark"] .auth-secondary:hover {
  border-color: #4f6482;
  background: linear-gradient(180deg, #213043 0%, #1a2838 100%);
}

html[data-theme="dark"] .auth-primary {
  border-color: #4f7bd5;
  background: linear-gradient(180deg, #5e88de 0%, #4f77cd 100%);
}

html[data-theme="dark"] .auth-primary:hover {
  border-color: #3f67bc;
  background: linear-gradient(180deg, #547ed3 0%, #426ac0 100%);
}

html[data-theme="dark"] .auth-divider {
  color: #7d90a8;
}

html[data-theme="dark"] .auth-divider::before,
html[data-theme="dark"] .auth-divider::after {
  background: #304155;
}

html[data-theme="dark"] .auth-notice {
  border-color: #2f4f85;
  background: #16263d;
  color: #aac6f2;
}

html[data-theme="dark"] .auth-error {
  border-color: #6d3636;
  background: #321b1b;
  color: #f0c0c0;
}

html[data-theme="dark"] .auth-links a,
html[data-theme="dark"] .auth-legal-links a {
  color: #9ec1f3;
}

html[data-theme="dark"] .auth-links a:hover,
html[data-theme="dark"] .auth-legal-links a:hover {
  color: #c0d8f9;
}

html[data-theme="dark"] .legal-hero,
html[data-theme="dark"] .legal-content,
html[data-theme="dark"] .legal-alert {
  border-color: #2f3c4f;
  background: rgba(21, 30, 41, 0.94);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .legal-nav-minimal a {
  border-color: #3b4d63;
  background: linear-gradient(180deg, #1f2c3d 0%, #1a2534 100%);
  color: #a8c7f3;
}

html[data-theme="dark"] .legal-nav-minimal a[aria-current="page"] {
  border-color: #53729a;
  background: linear-gradient(180deg, #27384d 0%, #203044 100%);
  color: #d4e2f7;
}

html[data-theme="high_contrast"] .auth-page {
  background: #000000;
}

html[data-theme="high_contrast"] .auth-card {
  border: 2px solid #ffffff;
  background: #000000;
  box-shadow: none;
}

html[data-theme="high_contrast"] .auth-logo,
html[data-theme="high_contrast"] .legal-logo {
  filter: invert(1);
}

html[data-theme="high_contrast"] .auth-header h1,
html[data-theme="high_contrast"] .auth-subtitle,
html[data-theme="high_contrast"] .auth-field label,
html[data-theme="high_contrast"] .auth-inline-note,
html[data-theme="high_contrast"] .auth-links,
html[data-theme="high_contrast"] .auth-legal-links {
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-input {
  border: 2px solid #ffffff;
  background: #000000;
  color: #ffffff;
  box-shadow: none;
}

html[data-theme="high_contrast"] .auth-input::placeholder {
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-input:focus-visible,
html[data-theme="high_contrast"] .auth-toggle:focus-visible,
html[data-theme="high_contrast"] .auth-primary:focus-visible,
html[data-theme="high_contrast"] .auth-secondary:focus-visible {
  box-shadow: 0 0 0 3px #ffff00;
}

html[data-theme="high_contrast"] .auth-toggle {
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-toggle:hover {
  background: #222222;
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-primary {
  border: 2px solid #00ffff;
  background: #0034aa;
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-primary:hover {
  border-color: #00ffff;
  background: #0f44bc;
}

html[data-theme="high_contrast"] .auth-secondary {
  border: 2px solid #ffffff;
  background: #000000;
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-secondary:hover {
  border-color: #ffff00;
  background: #111111;
}

html[data-theme="high_contrast"] .auth-divider {
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-divider::before,
html[data-theme="high_contrast"] .auth-divider::after {
  background: #ffffff;
}

html[data-theme="high_contrast"] .auth-notice {
  border: 2px solid #00ffff;
  background: #001a33;
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-error {
  border: 2px solid #ff5f5f;
  background: #330000;
  color: #ffffff;
}

html[data-theme="high_contrast"] .auth-links a,
html[data-theme="high_contrast"] .auth-legal-links a {
  color: #00ffff;
}

html[data-theme="high_contrast"] .auth-links a:hover,
html[data-theme="high_contrast"] .auth-legal-links a:hover {
  color: #ffff00;
}

html[data-theme="high_contrast"] .legal-hero,
html[data-theme="high_contrast"] .legal-content,
html[data-theme="high_contrast"] .legal-alert {
  border: 2px solid #ffffff;
  background: #000000;
  box-shadow: none;
}

html[data-theme="high_contrast"] .legal-nav-minimal a {
  border: 2px solid #ffffff;
  background: #000000;
  color: #ffffff;
}

html[data-theme="high_contrast"] .legal-nav-minimal a[aria-current="page"] {
  border-color: #00ffff;
  color: #00ffff;
}

@media (max-width: 760px) {
  .auth-page {
    align-items: flex-start;
    padding: 1rem 0.68rem;
  }

  .auth-layout {
    width: 100%;
  }

  .auth-card {
    border-radius: 15px;
    padding: 1.16rem 0.95rem 0.96rem;
    gap: 0.68rem;
  }

  .legal-shell {
    width: min(100%, calc(100% - 1rem));
    padding: 0.95rem 0 1.7rem;
  }

  .legal-hero,
  .legal-content,
  .legal-alert {
    border-radius: 14px;
  }

  .legal-content {
    padding: 0.92rem 0.94rem;
  }
}
