:root {
  --bg: #fffbf7;
  --bg-soft: #fdf5ee;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-soft: #fff7f1;
  --text: #53443a;
  --muted: #8f7f73;
  --line: #ece2d8;
  --primary: #f39a59;
  --primary-dark: #e68339;
  --primary-soft: #fff0e3;
  --accent: #e7e1db;
  --good: #699e78;
  --warn: #c57b33;
  --danger: #b35a4d;
  --shadow: 0 18px 40px rgba(150, 111, 73, 0.12);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 219, 190, 0.48) 0, transparent 24%),
    radial-gradient(circle at top right, rgba(233, 227, 220, 0.8) 0, transparent 22%),
    linear-gradient(180deg, #fffdfb 0%, var(--bg) 100%);
  color: var(--text);
}

.hero-shell {
  position: relative;
  overflow: hidden;
  min-height: 320px;
  background: linear-gradient(180deg, #fff6ec 0%, #fffaf5 100%);
}

.hero-art {
  position: absolute;
  inset: 0;
  background-image: url('header-cats.png');
  background-size: cover;
  background-position: center top;
  opacity: 1;
  transition: opacity 0.12s linear, transform 0.12s linear;
  will-change: opacity, transform;
}

.hero-fade {
  position: absolute;
  inset: auto 0 0 0;
  height: 140px;
  background: linear-gradient(180deg, rgba(255, 250, 245, 0) 0%, rgba(255, 251, 247, 1) 100%);
}

.topbar {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
  padding: 44px 22px 48px;
  min-height: 320px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.hero-copy {
  max-width: 720px;
  background: rgba(255, 252, 248, 0.62);
  backdrop-filter: blur(3px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 26px;
  padding: 18px 20px;
}

.eyebrow {
  color: var(--primary-dark);
  font-weight: 900;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
}

h1, h2, p { margin-top: 0; }
h1 {
  font-size: clamp(31px, 5vw, 54px);
  line-height: .98;
  margin-bottom: 12px;
}
h2 { font-size: 20px; margin-bottom: 6px; }
.subtitle {
  color: var(--muted);
  max-width: 680px;
  font-size: 17px;
  margin-bottom: 0;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: flex-start;
}

main { max-width: 1200px; margin: 0 auto; padding: 6px 22px 56px; }
.grid { display: grid; gap: 18px; margin-top: 18px; }
.cards { grid-template-columns: repeat(4, 1fr); }
.two-columns { grid-template-columns: 1fr 1fr; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), #ffd1a7);
}
.stat-card span { display: block; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.stat-card strong { display: block; font-size: 30px; line-height: 1.1; }
.stat-card small { display: block; color: var(--muted); margin-top: 9px; }

.section-title { margin-bottom: 16px; }
.section-title p { color: var(--muted); margin-bottom: 0; }
.row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.chart-controls {
  display: grid;
  gap: 10px;
  min-width: min(100%, 260px);
}
.date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
}
.date-range label {
  font-size: 12px;
  color: var(--muted);
}
.date-range input {
  padding: 10px 11px;
  border-radius: 14px;
}


.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 700; color: #5c4d43; font-size: 14px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(243, 154, 89, 0.15);
}
.full { grid-column: 1 / -1; }
.hidden { display: none; }

button, .file-label {
  border: none;
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 800;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background-color .12s ease;
}
button:hover, .file-label:hover { transform: translateY(-1px); }
.primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 8px 22px rgba(230, 131, 57, 0.22);
}
.primary:hover { filter: saturate(1.03) brightness(.99); }
.ghost {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  color: var(--text);
}
.ghost:hover { border-color: var(--primary); }
.delete-btn {
  color: var(--danger);
  background: transparent;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
}
.delete-btn:hover {
  background: #fff1ee;
  border-color: #f3c7c0;
}

.hint {
  margin-top: 18px;
  border: 1px dashed #e1c9b4;
  background: var(--panel-soft);
  padding: 14px;
  border-radius: 18px;
  color: var(--muted);
}

canvas {
  width: 100%;
  background: linear-gradient(180deg, #fffdfc, #fff7f0);
  border-radius: 18px;
  border: 1px solid #f1e6dc;
}

.table-wrap { overflow: auto; max-height: 420px; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  background: #f3efe9;
  color: #81685a;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}
.badge.good { background: #ecf7ef; color: var(--good); }
.badge.warn { background: #fff1e4; color: var(--warn); }

@media (max-width: 920px) {
  .topbar { flex-direction: column; min-height: 0; }
  .hero-shell { min-height: 0; }
  .top-actions { justify-content: flex-start; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .two-columns { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; }
  .chart-controls { width: 100%; }
  .date-range { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .row, .section-title-stack-mobile { align-items: flex-start; flex-direction: column; }
  .hero-copy { padding: 16px; }
  h1 { line-height: 1.05; }
}

.auth-shell {
  max-width: 1200px;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 18px;
  align-items: end;
}

.auth-shell h2 {
  margin-bottom: 8px;
}

.auth-shell p {
  color: var(--muted);
  margin-bottom: 0;
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.auth-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-weight: 700;
}

.auth-status.error {
  color: var(--danger);
}

.top-actions.hidden,
.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .auth-shell {
    margin-left: 22px;
    margin-right: 22px;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-form {
    grid-template-columns: 1fr;
  }
}
