:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-subtle: #F2F0EC;
  --text: #1C1C1E;
  --muted: #76767B;
  --accent: #2F5D50;
  --accent-soft: rgba(47, 93, 80, 0.11);
  --accent-text: #FFFFFF;
  --profit: #1F9D55;
  --profit-soft: rgba(31, 157, 85, 0.12);
  --loss: #D64545;
  --loss-soft: rgba(214, 69, 69, 0.12);
  --border: #E8E6E0;
  --shadow: 0 2px 8px rgba(18, 18, 20, 0.04);
  --radius-card: 14px;
  --radius-input: 10px;
  --radius-pill: 999px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #151517;
  --surface: #202024;
  --surface-subtle: #2A2A2F;
  --text: #EEECE7;
  --muted: #9898A0;
  --accent: #6FAF9A;
  --accent-soft: rgba(111, 175, 154, 0.16);
  --accent-text: #111F1B;
  --profit: #34C778;
  --profit-soft: rgba(52, 199, 120, 0.15);
  --loss: #F06262;
  --loss-soft: rgba(240, 98, 98, 0.15);
  --border: #323238;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Shell: Mobile bottom nav vs Desktop left sidebar */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-nav {
  display: none;
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.brand-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav .nav-item {
  flex-direction: column;
  gap: 3px;
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 8px;
}

.bottom-nav .nav-item.active {
  background: transparent;
  color: var(--accent);
}

@media (min-width: 768px) {
  .main-content {
    max-width: 860px;
    padding: 28px 28px 100px;
  }
  .grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }
}

@media (min-width: 1024px) {
  .sidebar-nav {
    display: flex;
  }
  .bottom-nav {
    display: none;
  }
  .main-content {
    max-width: 960px;
    padding: 36px 40px 64px;
  }
}

/* Screen Header */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.screen-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.screen-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 0;
  margin-bottom: 8px;
}

/* Cards & Stack */
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-clickable {
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  text-decoration: none;
  color: inherit;
}

.card-clickable:hover {
  border-color: var(--accent);
}

.label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Amounts & Numbers */
.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.num-xl {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.num-lg {
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 700;
}

.text-profit {
  color: var(--profit);
}

.text-loss {
  color: var(--loss);
}

.text-muted {
  color: var(--muted);
}

.text-accent {
  color: var(--accent);
}

/* Rows & Flex utilities */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Progress Bar */
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

/* Chips / Filters */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}

.chip:hover {
  border-color: var(--accent);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Inputs & Forms */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.input.mono {
  font-family: var(--font-num);
}

.input:focus {
  border-color: var(--accent);
}

.input-suffix-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

/* Checkbox Row */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  padding: 12px 18px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--accent);
}

.btn-danger {
  background: var(--loss-soft);
  color: var(--loss);
  border-color: transparent;
}

.btn-pill {
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 13px;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.text-action {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  padding: 2px 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-profit {
  background: var(--profit-soft);
  color: var(--profit);
}

.badge-loss {
  background: var(--loss-soft);
  color: var(--loss);
}

.badge-neutral {
  background: var(--surface-subtle);
  color: var(--muted);
}

/* Login Container */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

/* Alert / Banner */
.notice {
  padding: 11px 14px;
  border-radius: var(--radius-input);
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-subtle);
  color: var(--text);
}

.notice-error {
  background: var(--loss-soft);
  color: var(--loss);
}

.notice-success {
  background: var(--profit-soft);
  color: var(--profit);
}


/* Home: Needs attention rows */
.attn-list {
  display: flex;
  flex-direction: column;
  margin: -4px 0;
}

.attn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.attn-list > .attn-row:first-child {
  border-top: 0;
}

.attn-main {
  flex: 1;
  min-width: 0;
}

.attn-title {
  font-weight: 600;
}

.attn-status {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.attn-chevron {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.15s;
}

.attn-chevron.open {
  transform: rotate(90deg);
}

.attn-sub {
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  margin-bottom: 8px;
}

.attn-row-sub {
  padding: 8px 0;
  border-top: 0;
}

@media (hover: hover) {
  .attn-row:hover .attn-title {
    color: var(--accent);
  }
}
