/* Keep sales log - warm paper, deep teal. Matches SEO pages. */

:root {
  --bg: #F7F4EF;
  --ink: #1A1A1A;
  --muted: #5C574F;
  --muted-soft: #8A847A;
  --card: #FFFFFF;
  --card-alt: #FAF8F4;
  --border: #E6E1D8;
  --border-strong: #D4CEC3;
  --teal: #0F6B5C;
  --teal-dark: #0A5247;
  --teal-soft: #E6F3F0;
  --teal-border: #B9D9D2;
  --on-teal: #FFFFFF;
  --clay: #C45C26;
  --clay-soft: #F8EDE6;
  --clay-border: #E8C9B5;
  --keep: #0F6B5C;
  --gap-pos: #0F6B5C;
  --gap-neg: #A33B1A;
  --topbar-bg: rgba(247, 244, 239, 0.92);
  --shadow: 0 1px 2px rgba(26, 26, 26, 0.04), 0 4px 12px rgba(26, 26, 26, 0.05);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1B19;
    --ink: #EDE8E0;
    --muted: #B3ACA1;
    --muted-soft: #9C958A;
    --card: #262421;
    --card-alt: #2C2A26;
    --border: #3A3733;
    --border-strong: #4A4640;
    --teal: #3FB39E;
    --teal-dark: #6CCBB8;
    --teal-soft: #16302B;
    --teal-border: #24534A;
    --on-teal: #141312;
    --clay: #E08A5A;
    --clay-soft: #33241C;
    --clay-border: #5A3B2A;
    --keep: #3FB39E;
    --gap-pos: #3FB39E;
    --gap-neg: #E08A5A;
    --topbar-bg: rgba(28, 27, 25, 0.92);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1C1B19;
  --ink: #EDE8E0;
  --muted: #B3ACA1;
  --muted-soft: #9C958A;
  --card: #262421;
  --card-alt: #2C2A26;
  --border: #3A3733;
  --border-strong: #4A4640;
  --teal: #3FB39E;
  --teal-dark: #6CCBB8;
  --teal-soft: #16302B;
  --teal-border: #24534A;
  --on-teal: #141312;
  --clay: #E08A5A;
  --clay-soft: #33241C;
  --clay-border: #5A3B2A;
  --keep: #3FB39E;
  --gap-pos: #3FB39E;
  --gap-neg: #E08A5A;
  --topbar-bg: rgba(28, 27, 25, 0.92);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-underline-offset: 2px; }
a:hover { color: var(--teal-dark); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.wrap {
  width: min(1100px, calc(100% - 32px));
  margin-inline: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  width: min(1100px, calc(100% - 32px));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--teal);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand:hover { color: var(--teal-dark); }

.keep-mark {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

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

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}

:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  padding: 10px 16px;
}

.btn-sm { padding: 7px 12px; font-size: 0.92rem; }

.btn-primary {
  background: var(--teal);
  color: var(--on-teal);
  border-color: var(--teal);
}

.btn-primary:hover {
  background: var(--teal-dark);
  color: var(--on-teal);
  border-color: var(--teal-dark);
}

.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  border-color: var(--teal-border);
  color: var(--teal-dark);
}

.btn-danger {
  background: transparent;
  color: var(--gap-neg);
  border-color: var(--clay-border);
}

.text-link {
  font-size: 0.92rem;
  font-weight: 600;
}

.hero { padding: 28px 0 8px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--teal);
}
.hero h1 {
  margin: 0 0 8px;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.lede {
  margin: 0;
  max-width: 68ch;
  color: var(--muted);
}

.upgrade-card {
  margin: 18px 0 8px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--teal-soft);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.upgrade-kicker {
  margin: 0 0 2px;
  font-weight: 750;
  color: var(--teal-dark);
}
.upgrade-body {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 62ch;
}
.upgrade-note {
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: var(--muted-soft);
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-family: Palatino, Georgia, serif;
}

.panel-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.options-grid {
  margin-top: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

label, legend {
  display: block;
  font-weight: 650;
  font-size: 0.9rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0;
  padding: 10px 12px 12px;
}

.choice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 450;
  margin-top: 6px;
  font-size: 0.9rem;
}

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card-alt);
  color: inherit;
  font: inherit;
}

textarea { resize: vertical; min-height: 72px; }

.hint {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  font-weight: 450;
  color: var(--muted);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

#form-error {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--gap-neg);
  font-weight: 650;
}

.totals-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.total-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.total-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.total-card strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.2rem;
  color: var(--keep);
}

.gap-card strong { color: var(--ink); }
.gap-card strong.pos { color: var(--gap-pos); }
.gap-card strong.neg { color: var(--gap-neg); }

.totals-warn {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.88rem;
  color: var(--clay);
  background: var(--clay-soft);
  border: 1px solid var(--clay-border);
  border-radius: 8px;
  padding: 8px 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sales-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

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

.sales-table th {
  background: var(--card-alt);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}

.sales-table tbody tr:last-child td { border-bottom: none; }
.sales-table tbody tr:hover { background: var(--teal-soft); }

.gap-cell.pos { color: var(--gap-pos); font-weight: 650; }
.gap-cell.neg { color: var(--gap-neg); font-weight: 650; }

.notes-cell {
  max-width: 220px;
  color: var(--muted);
  font-size: 0.88rem;
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.row-actions button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.row-actions button.delete {
  color: var(--gap-neg);
  border-color: var(--clay-border);
}

.empty {
  margin: 14px 0 0;
  color: var(--muted);
}

.empty[hidden],
#empty-state[hidden] { display: none; }

.footer {
  padding: 8px 0 40px;
}

.disclaimer, .meta {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 78ch;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 640px) {
  .sales-table th:nth-child(8),
  .sales-table td:nth-child(8) { display: none; }
}
