:root {
  --bg: #f5f3eb;
  --ink: #1f2328;
  --card: #fffcf2;
  --line: #d5c8a7;
  --accent: #0f766e;
  --accent-2: #c2410c;
  --muted: #5f6368;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, #fef3c7 0%, transparent 45%),
    radial-gradient(circle at 90% 20%, #bfdbfe 0%, transparent 40%),
    var(--bg);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 2px solid var(--line);
  background: linear-gradient(90deg, #fff7d6, #fff);
}

h1, h2 {
  margin: 0 0 0.5rem;
}

h3 {
  margin: 0.8rem 0 0.4rem;
}

.progress-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #0f766e;
  background: #e8f7f5;
  border: 1px solid #9dd8d2;
  vertical-align: middle;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

/* ── Compact dashboard header ─────────────────────────────────────────── */

.hero-dashboard {
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  padding: 0.9rem 1.5rem;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-title h1 {
  margin: 0 0 0.15rem;
  font-size: 1.25rem;
}

.hero-title p {
  font-size: 0.8rem;
}

.header-status {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  min-height: 1.5rem;
}

.hstat-chips,
.hstat-cds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.hstat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: #fffef8;
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.hstat-chip b {
  font-weight: 800;
}

.hstat-chip-ok {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.hstat-chip-warn {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.hstat-chip-bad {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.cooldown-chip.cd-chip-ready {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.cooldown-chip.cd-chip-soon {
  background: #ffedd5;
  border-color: #fdba74;
  color: #9a3412;
}

.hstat-bars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.mini-bar {
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
}

.mini-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.mini-bar-fulltag {
  display: none;
  font-size: 0.66rem;
  font-weight: 800;
  color: #15803d;
  background: #dcfce7;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

.mini-bar.is-full .mini-bar-fulltag {
  display: inline-block;
}

.mini-bar-track {
  margin: 0.3rem 0;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #efe6d2;
}

.mini-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.mini-bar.is-full .mini-bar-fill {
  background: linear-gradient(90deg, #15803d, #22c55e);
}

.mini-bar.is-soon .mini-bar-fill {
  background: linear-gradient(90deg, #c2410c, #f97316);
}

.mini-bar-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.mini-bar-foot .eta-pill {
  font-size: 0.72rem;
  padding: 0.12rem 0.4rem;
}

@media (max-width: 640px) {
  .hstat-bars {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


.tab-nav {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem 1rem 0;
  flex-wrap: wrap;
}

.tab-link {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffef8;
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.tab-link.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tab-hidden {
  display: none !important;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.control-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  background: #fff;
}

button {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--accent);
  color: white;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.button-link:hover {
  filter: brightness(1.05);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  gap: 1rem;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
}

.full {
  grid-column: 1 / -1;
}

.hint {
  color: var(--muted);
  margin-top: 0;
}

.diag {
  color: var(--muted);
  font-size: 0.85rem;
}

#profileContent {
  display: grid;
  gap: 0.8rem;
}

.snapshot-head p {
  margin: 0.1rem 0;
}

.money-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.4rem 0.8rem;
  padding: 0.6rem;
  background: #fffef8;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.money-grid p {
  margin: 0;
}

.money-grid.compact {
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.money-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
}

.money-pill {
  font-weight: 700;
}

.bars-wrap {
  display: grid;
  gap: 0.6rem;
}

.cooldown-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.cooldown-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: #fffef8;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.85rem;
}

.cooldown-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.cooldown-icon svg {
  width: 13px;
  height: 13px;
  display: block;
}

.cooldown-drug {
  background: #0f766e;
}

.cooldown-booster {
  background: #2563eb;
}

.cooldown-medical {
  background: #c2410c;
}

.cooldown-travel {
  background: #7c3aed;
}

.missions-box {
  margin: 0.4rem 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid #fed7aa;
  background: #fffbeb;
  border-radius: 8px;
  overflow-x: auto;
}
.missions-box .logs-table th,
.missions-box .logs-table td {
  border-bottom-color: #fde68a;
}

.bar-row {
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
}

.bar-row-emphasis {
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.bar-note {
  margin-top: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.8rem;
}

.status-banner {
  margin: 0.5rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 1.05rem;
  border: 1px solid var(--line);
  background: #fffbeb;
  border-color: #fcd34d;
}
.status-banner strong { font-size: 1.1rem; }
.status-hospital {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}
.status-travel {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.status-jail {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}
.status-fallen {
  background: #fef2f2;
  border-color: #f87171;
  color: #991b1b;
}

.bar-head,
.bar-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.bar-track {
  margin: 0.35rem 0;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #efe6d2;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.eta-pill {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.eta-ready {
  background: #dcfce7;
  color: #166534;
}

.eta-soon {
  background: #ffedd5;
  color: #9a3412;
}

.eta-later,
.eta-unknown {
  background: #e5e7eb;
  color: #374151;
}

ul {
  margin: 0;
  padding-left: 1.2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge.low {
  background: #d1fae5;
  color: #065f46;
}

.badge.medium {
  background: #ffedd5;
  color: #9a3412;
}

.trading-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
}

#tradingPollMeta {
  margin-top: -0.25rem;
  margin-bottom: 0.75rem;
}

#tradingTableWrap {
  overflow-x: auto;
}

#tradingTableWrap table td,
#tradingTableWrap table th {
  white-space: nowrap;
}

#tradingLogsListWrap {
  overflow-x: auto;
}

.effect-section {
  margin-bottom: 1rem;
}
.effect-section h4 {
  margin: 0.2rem 0 0.5rem;
}
.effect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem;
}
.effect-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}
.effect-card .effect-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}
.effect-card .inv-cat-items th,
.effect-card .inv-cat-items td {
  padding: 0.2rem 0.35rem;
  font-size: 0.75rem;
}
.tag-booster {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}
.tag-drug {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

#logsListWrap {
  overflow-x: auto;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.logs-table th,
.logs-table td {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.logs-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.log-cat-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
  white-space: nowrap;
}
.log-details pre {
  max-width: 420px;
}

#tradingDiagnosticsWrap {
  overflow-x: auto;
}

.trading-profit-positive {
  color: #166534;
  font-weight: 700;
}

.trading-profit-negative {
  color: #991b1b;
  font-weight: 700;
}

.trading-profit-flat {
  color: var(--muted);
}

.trading-sellmore {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fdba74;
  white-space: nowrap;
}

.price-menu {
  position: absolute;
  right: 1.2rem;
  top: 5rem;
  min-width: 270px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  z-index: 50;
}
.price-menu[hidden] { display: none; }
.price-menu h4 { margin: 0 0 0.4rem; }
.price-menu .pm-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.15rem 0; border-bottom: 1px dashed var(--line); }
.price-menu .pm-row:last-of-type { border-bottom: 0; }
.price-menu .pm-suggest { font-weight: 800; color: var(--accent); }
.price-menu .pm-hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.35rem; }

.targets-controls select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  background: #fff;
}

.badge.estimate-high {
  background: #dcfce7;
  color: #166534;
}

.badge.estimate-medium {
  background: #fef9c3;
  color: #854d0e;
}

.badge.estimate-low {
  background: #ffedd5;
  color: #9a3412;
}

.badge.estimate-very_low {
  background: #fee2e2;
  color: #991b1b;
}

.gym-advice {
  border: 1px solid var(--line);
  background: #fffef8;
  border-radius: 10px;
  padding: 0.7rem;
}

.gym-advice h3 {
  margin-top: 0;
}

.gym-advice p {
  margin: 0.3rem 0;
}

.gym-advice ul {
  margin-top: 0.4rem;
}

.gym-advice.boost_happy_first {
  border-color: #c2410c;
  box-shadow: 0 0 0 2px rgba(194, 65, 12, 0.12);
}

.gym-advice.small_boost_optional {
  border-color: #0f766e;
}

.gym-advice.train_now {
  border-color: #166534;
}

.gym-advice.wait_energy {
  border-color: #6b7280;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.4rem 0.8rem;
  background: #fffef8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
}

.history-grid p {
  margin: 0;
}

.history-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.history-chart-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffef8;
  padding: 0.7rem;
}

.chart-box-history {
  height: 250px;
}

.chart-box-history-donut {
  height: 220px;
  max-width: 380px;
  margin: 0 auto;
}

#runtimeCard details {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  background: #fffef9;
}

/* ── Collapsible cards ── */
.card-collapse-btn {
  margin-left: 0.6rem;
  background: transparent;
  border: 0;
  padding: 0 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.15s ease, color 0.15s ease;
}
.card-collapse-btn:hover { color: var(--accent); }
.card.collapsed .card-collapse-btn,
.budget-card.collapsed .card-collapse-btn,
.history-chart-card.collapsed .card-collapse-btn { transform: rotate(-90deg); }
.card.collapsed > :not(.card-collapse-head),
.budget-card.collapsed > :not(.card-collapse-head),
.history-chart-card.collapsed > :not(.card-collapse-head) { display: none !important; }

#runtimeCard summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}

#runtimeCard #runtimeContent {
  margin-top: 0.6rem;
}

.resources-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.7rem;
}

.resource-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: #fffef8;
}

.resource-item h3 {
  margin-top: 0;
}

.resource-item p {
  margin: 0.35rem 0;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.stats-table th,
.stats-table td {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

.skill-bar {
  display: inline-block;
  width: 120px;
  height: 8px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.skill-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 0.8rem;
}

#workspaceStateCard {
  max-width: 1400px;
  width: 100%;
}

.checklist {
  list-style: none;
  padding-left: 0;
  display: grid;
  gap: 0.35rem;
}

.checklist-large {
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  background: #fffef8;
  border: 1px solid rgba(148, 163, 184, 0.25);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.checklist li:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: #ffffff;
}

.checklist input[type="checkbox"] {
  margin-top: 0.15rem;
}

.checklist label.done {
  text-decoration: line-through;
  color: var(--muted);
}

.editable-item-label {
  cursor: text;
  border-radius: 4px;
}

.editable-item-label:hover {
  background: rgba(15, 118, 110, 0.08);
}

.editable-item-label.no-edit {
  cursor: default;
}

.editable-item-label.no-edit:hover {
  background: transparent;
}

.inline-item-editor {
  width: min(860px, 98%);
  min-height: 38px;
  resize: vertical;
  line-height: 1.35;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font: inherit;
  color: var(--ink);
  background: #ffffff;
}

.inline-item-editor:focus,
.checklist-add-input:focus,
#workspaceImportText:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.checklist-add-row {
  border: 1px dashed var(--line) !important;
  background: rgba(255, 255, 255, 0.78) !important;
}

.checklist-add-ghost {
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-top: 0.2rem;
  background: transparent;
  opacity: 0.6;
  flex: 0 0 auto;
}

.checklist-add-input {
  width: min(860px, 98%);
  min-height: 38px;
  resize: vertical;
  line-height: 1.35;
  border: 1px solid rgba(148, 163, 184, 0.55);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font: inherit;
  color: var(--ink);
  background: #ffffff;
}

.checklist-add-input::placeholder {
  color: var(--muted);
}

.checklist .completion-date {
  margin-left: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.checklist .drag-handle {
  cursor: grab;
  color: var(--muted);
  padding: 0 0.25rem;
  user-select: none;
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1.2;
  opacity: 0.55;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.checklist .drag-handle:hover {
  color: var(--accent);
  opacity: 1;
}

.checklist li.drag-source {
  opacity: 0.35;
  background: #f8fafc;
  border-style: dashed;
}

.checklist li.drag-over {
  border-color: var(--accent) !important;
  background: rgba(15, 118, 110, 0.08) !important;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.22);
}

.checklist .checklist-delete-btn {
  background: transparent;
  border: 0;
  color: #b91c1c;
  cursor: pointer;
  padding: 0 0.3rem;
  font-size: 0.95rem;
  line-height: 1.1;
  flex: 0 0 auto;
  border-radius: 6px;
  opacity: 0.65;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.checklist .checklist-delete-btn:hover {
  opacity: 1;
  background: rgba(185, 28, 28, 0.12);
  color: #7f1d1d;
}

.checklist .checklist-delete-btn:active {
  background: rgba(185, 28, 28, 0.2);
}

.milestone-category-section {
  border-left: 3px solid var(--accent);
  padding-left: 0.7rem;
  margin-bottom: 0.85rem;
  border-radius: 0 6px 6px 0;
}

.milestone-category-section.is-drag-target {
  border-left-color: var(--accent-2);
  background: rgba(194, 65, 12, 0.04);
  box-shadow: 0 0 0 2px rgba(194, 65, 12, 0.18);
}

.milestone-category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.milestone-category-title {
  margin: 0;
  font-size: 1rem;
  cursor: text;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  color: var(--ink);
  font-weight: 700;
}

.milestone-category-title:hover {
  background: rgba(15, 118, 110, 0.08);
}

.milestone-category-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.milestone-category-delete-btn {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #b91c1c;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  font-size: 0.85rem;
  border-radius: 6px;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.milestone-category-delete-btn:hover {
  opacity: 1;
  background: rgba(185, 28, 28, 0.12);
}

.milestone-category-add-row {
  display: flex;
  justify-content: center;
  margin-top: 0.4rem;
}

.add-category-btn {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  cursor: pointer;
  padding: 0.35rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 999px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.add-category-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(15, 118, 110, 0.06);
}

.workspace-inline-actions {
  margin-bottom: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.milestone-completed-list {
  list-style: none;
  padding-left: 0;
  display: grid;
  gap: 0.3rem;
}

.milestone-completed-list li {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  background: #fffbef;
}

.milestone-completed-list .hint {
  margin: 0;
}

/* ---- Generic category sections (Milestones, To-dos, Daily Routine) ---- */
.category-section {
  border-left: 3px solid var(--accent);
  padding-left: 0.7rem;
  margin-bottom: 0.85rem;
  border-radius: 0 6px 6px 0;
}

.category-section.is-drag-target {
  border-left-color: var(--accent-2);
  background: rgba(194, 65, 12, 0.04);
  box-shadow: 0 0 0 2px rgba(194, 65, 12, 0.18);
}

.category-section-daily {
  border-left-color: var(--accent-2);
}

.category-header {
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
}

.category-header:hover {
  background: rgba(15, 118, 110, 0.05);
}

.category-chevron {
  display: inline-block;
  width: 1rem;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
  transition: transform 0.15s ease;
}

.category-section.is-collapsed .category-chevron {
  transform: rotate(-90deg);
}

.category-section.is-collapsed .category-body {
  display: none;
}

.category-topics-hint {
  margin-left: 0.5rem;
  font-style: italic;
  font-weight: 500;
  opacity: 0.75;
}

.category-text-item {
  font-style: italic;
}

.category-completed {
  margin-top: 0.55rem;
  padding-top: 0.3rem;
  border-top: 1px dashed var(--line);
}

.category-completed-heading {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.3rem;
  cursor: pointer;
}
.category-completed-heading::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 0.15s ease;
}
.category-completed.is-collapsed .category-completed-heading::before {
  transform: rotate(90deg);
}
.category-completed.is-collapsed .category-completed-list {
  display: none;
}

.category-completed-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-completed-item[draggable="true"] {
  cursor: grab;
}

.category-completed-item strong {
  min-width: 0;
}

.category-completed-list li.is-hidden {
  display: none;
}

.category-completed-list.show-all li.is-hidden {
  display: block;
}

.category-completed-show-all {
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 999px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.4rem;
  padding: 0.25rem 0.7rem;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.category-completed-show-all:hover {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.06);
}

.collapse-all-btn {
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.6rem;
  padding: 0.15rem 0.6rem;
  vertical-align: middle;
  transition: border-color 0.15s ease, color 0.15s ease;
}

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

.uncomplete-milestone-btn,
.uncomplete-tool-btn {
  font-size: 0.82rem;
  padding: 0.2rem 0.55rem;
}

#toolChangeNotes {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: #fffef8;
  font-family: inherit;
  color: var(--ink);
}

#workspaceImportText {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: #fffef8;
  font-family: inherit;
  color: var(--ink);
  margin-bottom: 0.55rem;
}

#workspaceImportText {
  min-height: 210px;
}

.workspace-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin-top: 0.6rem;
}

.workspace-actions-sticky {
  position: sticky;
  top: 0.55rem;
  z-index: 5;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 252, 242, 0.95);
  backdrop-filter: blur(2px);
}

.workspace-save-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
}

#workspaceStateStatus[data-tone="neutral"] {
  color: var(--muted);
}

#workspaceStateStatus[data-tone="pending"] {
  color: #9a3412;
  border-color: rgba(217, 119, 6, 0.45);
  background: #fff7ed;
}

#workspaceStateStatus[data-tone="saving"] {
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.35);
  background: #eff6ff;
}

#workspaceStateStatus[data-tone="saved"] {
  color: #166534;
  border-color: rgba(22, 163, 74, 0.35);
  background: #f0fdf4;
}

#workspaceStateStatus[data-tone="error"] {
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.35);
  background: #fef2f2;
}

.workspace-undo-toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%) translateY(16px);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.workspace-undo-toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.workspace-undo-text {
  font-size: 0.92rem;
}

.workspace-undo-btn {
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  padding: 0.22rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.workspace-undo-btn:hover {
  background: #e2e8f0;
}

.stats-page {
  min-height: 100vh;
  overflow-x: hidden;
}

.stats-grid {
  align-items: start;
}

.chart-box {
  position: relative;
  width: 100%;
  height: 320px;
}

.chart-box-wide {
  height: 340px;
}

.chart-box-donut {
  height: 260px;
  max-width: 460px;
  margin: 0 auto;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.raw-box {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffef8;
  padding: 0.75rem;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 800px) {
  .chart-box,
  .chart-box-wide {
    height: 260px;
  }

  .chart-box-donut {
    height: 220px;
  }
}

footer {
  padding: 0.9rem 1rem 1.2rem;
  color: var(--muted);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .control-item {
    font-size: 0.85rem;
  }

  .tab-nav {
    gap: 0.35rem;
    padding: 0.6rem 0.75rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-link {
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
    white-space: nowrap;
  }

  .trading-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .history-chart-grid {
    grid-template-columns: 1fr;
  }

  /* ── Mobil: Budget/Summary stapeln, Tabellen horizontal scrollen ── */
  .budget-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "liquid"
      "calc"
      "trading"
      "stock"
      "jumps"
      "housing";
  }
  .budget-calc-cols { grid-template-columns: 1fr; }
  .history-grid { grid-template-columns: 1fr; }
  .money-grid { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .budget-card, .inv-cat, .trading-cat-list, .logs-list-wrap { overflow-x: auto; }
  .inv-cat-items, .budget-table, .stocks-table, .logs-table { min-width: 520px; }
  .hero-top { align-items: stretch; }
  .header-status { gap: 0.35rem; }
}

@keyframes loading-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.loading-pulse {
  animation: loading-pulse 1.5s ease-in-out infinite;
}

.stocks-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.stocks-table th, .stocks-table td { padding: 0.4rem 0.6rem; text-align: right; border-bottom: 1px solid #ddd; }
.stocks-table th { background: #f5f5f5; font-weight: 600; text-align: right; }
.stocks-table th:first-child, .stocks-table td:first-child { text-align: left; }
.stocks-table tfoot td { border-top: 2px solid #333; font-weight: 700; }
.stocks-profit { color: #166534; }
.stocks-loss { color: #991b1b; }
