:root {
  color-scheme: light dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0f172a;
  color: #e2e8f0;
}

#app {
  min-height: 100vh;
  display: block;
  padding: 20px;
}

.card {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: #94a3b8;
  margin: 0 0 8px;
}

h1,
h2,
p {
  margin-top: 0;
}

.muted {
  color: #94a3b8;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 14px 0;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: #38bdf8;
  color: #082f49;
}

button.secondary {
  background: transparent;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  padding: 16px;
}

pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cbd5e1;
}

.status {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.22);
  color: #bae6fd;
}

.error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.24);
  color: #fecaca;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  color: #e2e8f0;
  padding: 10px 12px;
  font: inherit;
}

select,
textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  color: #e2e8f0;
  padding: 10px 12px;
  font: inherit;
}

input::placeholder {
  color: #94a3b8;
}

.setup-note {
  margin: 4px 0 0;
}

.habit-setup-frequency {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.habit-setup-frequency h2 {
  margin: 0;
  font-size: 1rem;
}

.habit-setup-rows {
  display: grid;
  gap: 8px;
}

.habit-setup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 120px) auto auto auto;
  gap: 8px;
  align-items: center;
}

.habit-row-button {
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 44px;
}

.habit-add-row {
  justify-self: start;
  border-radius: 10px;
  padding: 8px 12px;
}

.rewards-summary h2 {
  margin: 0;
}

.rewards-ledger-panel {
  margin-top: 14px;
}

.tracker-table--rewards-ledger th:first-child,
.tracker-table--rewards-ledger td:first-child {
  width: 170px;
}

.tracker-table--rewards-ledger th:nth-child(2),
.tracker-table--rewards-ledger td:nth-child(2) {
  width: 120px;
}

.tracker-table--rewards-ledger th:nth-child(3),
.tracker-table--rewards-ledger td:nth-child(3) {
  width: 140px;
}

.tracker-table--rewards-ledger th:nth-child(5),
.tracker-table--rewards-ledger td:nth-child(5),
.tracker-table--rewards-ledger th:nth-child(6),
.tracker-table--rewards-ledger td:nth-child(6) {
  width: 110px;
  text-align: right;
}

.withdraw-dialog {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  width: min(460px, calc(100vw - 32px));
  padding: 18px;
}

.withdraw-dialog::backdrop {
  background: rgba(2, 6, 23, 0.65);
}

.withdraw-summary p {
  margin: 0;
  color: #cbd5e1;
}

.withdraw-summary {
  display: grid;
  gap: 6px;
}

.withdraw-summary .is-negative {
  color: #fecaca;
}

.tracker-section {
  margin-top: 14px;
}

.tracker-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 320px)) minmax(240px, 1fr);
  gap: 10px 14px;
  align-items: end;
}

.tracker-control {
  margin: 0;
}

.today-date {
  margin: 0;
  justify-self: end;
  color: #cbd5e1;
  font-weight: 600;
}

.table-wrap {
  overflow-x: clip;
}

.tracker-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.95rem;
}

.tracker-table th,
.tracker-table td {
  border: 1px solid rgba(148, 163, 184, 0.28);
  padding: 4px 6px;
  text-align: center;
}

.tracker-table th:first-child,
.tracker-table td:first-child {
  text-align: left;
  white-space: nowrap;
}

.tracker-table--daily th:first-child,
.tracker-table--daily td:first-child {
  width: clamp(120px, 16vw, 170px);
}

.tracker-table--daily th:not(:first-child),
.tracker-table--daily td:not(:first-child) {
  width: 2rem;
}

.tracker-table--weekly th:first-child,
.tracker-table--weekly td:first-child {
  width: clamp(140px, 24vw, 260px);
}

.tracker-table--weekly th:not(:first-child),
.tracker-table--weekly td:not(:first-child),
.tracker-table--monthly th:last-child,
.tracker-table--monthly td:last-child {
  width: 4.25rem;
}

.track-checkbox {
  width: 16px;
  height: 16px;
}

.tracker-highlight-today {
  background: rgba(56, 189, 248, 0.16);
}

.tracker-highlight-week {
  background: rgba(168, 85, 247, 0.16);
}

.notes-panel {
  margin-top: 14px;
}

.notes-copy {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.35;
}

@media (max-width: 900px) {
  #app {
    padding: 12px;
  }

  .card {
    padding: 16px;
  }

  .tracker-controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .today-date {
    justify-self: start;
  }

  .habit-setup-row {
    grid-template-columns: 1fr 110px auto auto auto;
  }
}

@media (max-width: 1200px) {
  .table-wrap {
    overflow-x: auto;
  }

  .tracker-table--daily {
    min-width: 980px;
  }
}

@page {
  size: landscape;
  margin: 10mm;
}

@media print {
  :root {
    color-scheme: light;
  }

  body {
    background: #fff;
    color: #000;
  }

  #app {
    padding: 0;
    min-height: auto;
  }

  .card {
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    padding: 0;
  }

  .actions,
  .today-date,
  .rewards-summary,
  .notes-panel,
  .rewards-ledger-panel,
  #withdrawDialog {
    display: none !important;
  }

  .tracker-controls {
    grid-template-columns: 1fr 1fr;
    margin-bottom: 8px;
  }

  .tracker-control select {
    border-color: #000;
    background: #fff;
    color: #000;
    padding: 4px 6px;
  }

  .tracker-section {
    margin-top: 10px;
    break-inside: avoid;
  }

  .table-wrap {
    overflow: visible;
  }

  .tracker-table {
    border-collapse: collapse;
    font-size: 9pt;
    color: #000;
  }

  .tracker-table th,
  .tracker-table td {
    border: 1px solid #000;
    background: #fff !important;
    color: #000;
  }

  .track-checkbox {
    display: none !important;
  }

  .tracker-table td:not(:first-child) {
    min-height: 18px;
    height: 18px;
  }

  .tracker-table--daily {
    width: 100%;
    table-layout: fixed;
  }

  .tracker-table--daily th:first-child,
  .tracker-table--daily td:first-child {
    width: 18%;
    font-size: 8.5pt;
    white-space: normal;
  }

  .tracker-table--daily th:not(:first-child),
  .tracker-table--daily td:not(:first-child) {
    width: calc(82% / 31);
    padding: 2px 1px;
    font-size: 8pt;
  }
}
