:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #69756f;
  --line: #dce4df;
  --panel: #ffffff;
  --page: #f3f5f2;
  --accent: #1f7a5a;
  --accent-strong: #12271f;
  --gold: #b8872f;
  --danger: #b94646;
  --good: #227246;
  --pending: #52677a;
  --shadow: 0 18px 45px rgba(24, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 22px;
  background: #12271f;
  color: #f9fbf7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: #1f7a5a;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  text-align: left;
  padding: 0 12px;
}

.tab.active,
.tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.side-summary {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.side-summary span,
.side-summary small {
  color: rgba(255, 255, 255, 0.64);
}

.side-summary strong {
  font-size: 26px;
}

.workspace {
  min-width: 0;
  padding: 28px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h2 {
  font-size: 32px;
}

.top-actions,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.icon-btn,
.link-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  background: var(--accent-strong);
  color: #fff;
}

.secondary,
.icon-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 42px;
  padding: 0;
  font-size: 22px;
}

.link-button {
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: var(--accent);
}

.file-btn {
  display: inline-grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics,
.dashboard-grid,
.entry-layout,
.limit-cards,
.sync-grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric,
.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric span,
.metric small,
.panel-head span,
.quiet {
  color: var(--muted);
}

.metric strong {
  font-size: 30px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.bar-chart {
  min-width: 0;
  display: flex;
  align-items: end;
  gap: 12px;
  min-height: 230px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.bar-slot {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 8px;
  flex: 1 0 86px;
  min-height: 210px;
}

.bar-track {
  display: flex;
  align-items: end;
  min-height: 160px;
  border-radius: 8px;
  background: #eef3ef;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  min-height: 4px;
  background: var(--good);
}

.bar-fill.negative {
  background: var(--danger);
}

.bar-value,
.bar-label {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.outcome-list,
.recent-list,
.limit-cards {
  display: grid;
  gap: 10px;
}

.outcome-row,
.recent-row,
.limit-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.outcome-top,
.recent-top,
.limit-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.progress span.warning {
  background: var(--gold);
}

.progress span.danger {
  background: var(--danger);
}

.entry-layout {
  grid-template-columns: minmax(320px, 0.7fr) minmax(0, 1.3fr);
  align-items: start;
}

.form-grid,
.limits-form,
.sync-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.12);
}

.form-panel {
  display: grid;
  gap: 14px;
}

.ledger-head {
  align-items: flex-start;
}

.filters {
  justify-content: flex-end;
}

.filters select {
  max-width: 150px;
}

.filters input {
  max-width: 220px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 740px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.bet-title {
  display: grid;
  gap: 3px;
}

.bet-title strong {
  font-size: 14px;
}

.bet-title span {
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  background: #eef3ef;
  color: var(--pending);
}

.pill.won {
  background: #e5f3ea;
  color: var(--good);
}

.pill.lost {
  background: #f8e8e8;
  color: var(--danger);
}

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

.row-actions button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.money-good {
  color: var(--good);
}

.money-bad {
  color: var(--danger);
}

.empty-state,
.empty-inline {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 160px;
  color: var(--muted);
  text-align: center;
}

.limits-form {
  align-items: end;
}

.limit-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0;
}

.sync-form {
  align-items: end;
}

.sync-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.sync-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    padding: 14px;
  }

  .tabs {
    grid-template-columns: repeat(4, auto);
    margin-left: auto;
  }

  .tab {
    text-align: center;
  }

  .side-summary {
    display: none;
  }

  .metrics,
  .dashboard-grid,
  .entry-layout,
  .limit-cards,
  .sync-grid {
    grid-template-columns: 1fr 1fr;
  }

  .entry-layout,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .workspace {
    padding: 18px 14px;
  }

  .sidebar,
  .topbar,
  .panel-head,
  .ledger-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    width: 100%;
  }

  .tabs {
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
    margin-left: 0;
  }

  .top-actions,
  .filters {
    width: 100%;
  }

  .secondary,
  .file-btn,
  .filters input,
  .filters select {
    max-width: none;
    flex: 1;
  }

  .metrics,
  .form-grid,
  .limits-form,
  .limit-cards,
  .sync-form,
  .sync-grid {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 28px;
  }
}
