:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --dashboard-canvas: #000000;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #647184;
  --line: #dce2ea;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #a16207;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.brand-logo {
  display: block;
  width: clamp(142px, 15vw, 210px);
  height: auto;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

main {
  padding: 18px clamp(12px, 3vw, 36px) 40px;
}

.revenue-stage {
  background: var(--dashboard-canvas);
  padding: 18px clamp(12px, 3vw, 36px) 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.actions form {
  margin: 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  min-height: 36px;
  border-radius: 6px;
  padding: 0 13px;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #111827;
  text-decoration: none;
}

.icon-button:hover {
  border-color: transparent;
  background: #f3f4f6;
  color: #000;
}

.icon-button:active,
.icon-button.is-loading {
  background: #e5e7eb;
  color: #000;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: center;
}

.dashboard-view[hidden],
.history-view[hidden],
.history-banner[hidden] {
  display: none;
}

.icon-button.is-loading svg {
  animation: refresh-spin 0.8s linear infinite;
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.revenue-board {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 1080px);
  aspect-ratio: 1771 / 888;
  margin: 0 auto;
  overflow: hidden;
  border-radius: clamp(18px, 3vw, 34px);
  background: url("/static/spraypaint-background.png") center / cover no-repeat;
  box-shadow: 0 16px 34px rgba(12, 18, 28, 0.18);
  isolation: isolate;
}

.revenue-board::before {
  content: none;
}

.revenue-value {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}

.revenue-value canvas {
  display: block;
  width: 100%;
  height: 100%;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
}

button.secondary {
  background: #fff;
  color: var(--accent-dark);
}

button.secondary:hover {
  background: #eef7f6;
}

.table-shell {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.history-banner a,
.history-head a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.history-view {
  padding: 18px clamp(12px, 3vw, 36px) 40px;
}

.history-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f9fafb;
}

.history-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.history-list {
  display: grid;
}

.history-day {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.history-day:last-child {
  border-bottom: 0;
}

.history-day:hover {
  background: #eef7f6;
}

.history-day-date {
  font-weight: 700;
}

.history-day-revenue {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: #334155;
  background: #f9fafb;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr.hidden-row {
  color: var(--muted);
  background: #fbfbfc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.metric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.editable {
  display: inline-flex;
  max-width: 360px;
  min-height: 30px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--accent-dark);
  background: transparent;
  text-align: left;
  overflow-wrap: anywhere;
}

.editable:hover,
.editable:focus {
  border-color: #99d5cf;
  background: #eef7f6;
  outline: none;
}

.readonly-value {
  display: inline-block;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.placeholder {
  color: var(--warn);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.action-col {
  width: 86px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 12px;
    padding-block: 18px;
  }

  .brand {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .brand-logo {
    width: min(190px, 52vw);
  }

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

  .actions .toggle {
    display: none;
  }

  h1 {
    font-size: 22px;
  }

  main {
    padding: 14px 10px 32px;
  }

  .revenue-stage {
    padding: 2px;
  }

  .revenue-board {
    width: 100%;
    margin-inline: 0;
    border-radius: 16px;
  }

  .table-shell {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
  }

  table {
    width: 100%;
    min-width: 0;
    border-collapse: separate;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  th,
  td {
    padding: 9px 12px;
  }

  td {
    display: grid;
    grid-template-columns: minmax(88px, 36%) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    text-align: right;
    min-width: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
  }

  tbody tr:last-child td {
    border-bottom: 1px solid var(--line);
  }

  tbody tr td:last-child {
    border-bottom: 0;
  }

  .editable {
    max-width: 100%;
    justify-content: flex-end;
    justify-self: end;
    text-align: right;
    overflow: hidden;
    overflow-wrap: anywhere;
  }

  .readonly-value {
    max-width: 100%;
    justify-self: end;
    text-align: right;
  }

  td[data-label="Campaign"] {
    grid-template-columns: 1fr;
    text-align: left;
  }

  td[data-label="Campaign"]::before {
    margin-bottom: 2px;
  }

  td[data-label="Campaign"] .editable {
    justify-self: stretch;
    justify-content: flex-start;
    text-align: left;
  }

  td[data-label="Campaign"] .readonly-value {
    justify-self: stretch;
    text-align: left;
  }

  td[data-label="Hide"] {
    display: none;
  }

  .empty {
    display: block;
    text-align: center;
  }

  .empty::before {
    content: none;
  }

  .history-view {
    padding: 14px 10px 32px;
  }

  .history-head,
  .history-day {
    padding-inline: 14px;
  }

  .history-day {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .history-day-revenue {
    font-size: 20px;
  }
}

.login-body {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-wrap {
  width: min(100%, 420px);
  padding: 0;
}

.login-panel {
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.login-error {
  color: var(--danger);
  margin: 0;
}
