/* =========================================================================
   Rhythm & Eats Partner Dashboard
   Brand: black & white primary, teal and wine red accents
   ========================================================================= */

:root {
  --bg:          #fafafa;
  --surface:     #ffffff;
  --ink:         #000000;
  --ink-soft:    #1a1a1a;
  --ink-muted:   #666666;
  --ink-hint:    #999999;
  --line:        #000000;
  --line-soft:   #dddddd;
  --teal:        #0a4d47;
  --teal-soft:   #e8f0ee;
  --wine:        #8b1e2f;
  --wine-soft:   #f5e7ea;

  --serif:  'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:   'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------------ header */
.site-header {
  background: var(--ink);
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 20px 32px;
  gap: 24px;
  position: sticky; top: 0; z-index: 10;
}

.brand { display: flex; align-items: center; }
.brand-wordmark {
  height: 30px;
  display: block;
}
.brand-sub {
  margin-left: 18px;
  padding-left: 18px;
  border-left: 1px solid #333;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #888;
}

.main-nav {
  display: flex;
  gap: 2px;
  justify-content: center;
}
.nav-link {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 400;
  color: #ccc;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
}
.nav-link:hover { color: #fff; }
.nav-link.active {
  background: #fff;
  color: var(--ink);
  font-weight: 500;
}

.header-actions { display: flex; gap: 6px; }
.action-link {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.action-link.secondary {
  color: #ccc;
  border-color: #333;
}
.action-link.secondary:hover { color: #fff; border-color: #555; }
.action-link.primary {
  background: var(--wine);
  color: #fff;
}
.action-link.primary:hover { background: #6f1826; }

/* ------------------------------------------------------------------- flash */
.flash-wrap { padding: 16px 32px 0; }
.flash {
  padding: 12px 18px;
  font-size: 13px;
  margin-bottom: 8px;
  border-left: 3px solid;
}
.flash-success { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }
.flash-error   { background: var(--wine-soft); border-color: var(--wine); color: var(--wine); }

/* --------------------------------------------------------------------- main */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 32px 48px;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.page-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 4vw, 2.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.page-title em {
  font-style: italic;
  color: var(--teal);
}
.page-meta {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: right;
}
.page-meta strong {
  display: block;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 3px;
}

/* ------------------------------------------------------ period navigation */
.period-nav {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 14px 20px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
}
.period-nav-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 20px;
  flex-wrap: wrap;
}
.period-nav-primary {
  display: flex;
  align-items: center;
  gap: 10px;
}
.period-nav-compare {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.period-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  transition: all 0.15s ease;
}
.period-arrow:hover:not(.disabled) {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.period-arrow.disabled {
  opacity: 0.25;
  pointer-events: none;
  cursor: default;
}
.period-select {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  padding: 6px 32px 6px 12px;
  border: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--ink);
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M0 0 L5 6 L10 0' fill='black'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  min-width: 180px;
}
.period-select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.period-select-compare { min-width: 180px; }
.compare-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.compare-open {
  font-size: 12px;
  color: var(--ink-muted);
  padding: 6px 12px;
  border: 1px dashed var(--line-soft);
  transition: all 0.15s ease;
}
.compare-open:hover {
  color: var(--ink);
  border-color: var(--ink);
  border-style: solid;
}
.compare-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1;
  transition: color 0.15s ease;
}
.compare-close:hover { color: var(--wine); }

/* Compare row KPIs — appears as a secondary stacked row under primary cards */
.kpi-grid.compare-row {
  border-top: 0;
  background: #f7f7f7;
  margin-bottom: 0;
}
.kpi-grid.compare-row + .kpi-grid {
  border-top: 0;
  margin-top: 0;
}
.kpi.compare {
  background: #f7f7f7;
  padding-top: 14px;
  padding-bottom: 18px;
  gap: 6px;
}
.kpi.compare:hover { background: #f0f0f0; }
.kpi-label.compare-label {
  color: var(--ink-muted);
  font-size: 9px;
  letter-spacing: 0.16em;
}
.kpi-value.compare {
  font-size: 24px;
  color: var(--ink-muted);
}

/* ------------------------------------------------------ metric cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--line);
}
.kpi-grid + .kpi-grid { border-top: 0; margin-bottom: 40px; }
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi {
  background: var(--surface);
  padding: 22px 20px 24px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.2s ease;
}
.kpi:last-child { border-right: 0; }
.kpi:hover { background: #fcfcfc; }
.kpi.highlight {
  background: var(--ink);
  color: #fff;
}
.kpi.highlight:hover { background: #0a0a0a; }
.kpi.highlight .kpi-label { color: #fff; opacity: 0.65; }
.kpi.highlight .kpi-sub { color: #fff; opacity: 0.7; }

.kpi-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.kpi-value {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  font-size: 11px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}
.delta {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.delta.up   { background: var(--teal-soft); color: var(--teal); }
.delta.down { background: var(--wine-soft); color: var(--wine); }
.kpi.highlight .delta.up   { background: var(--teal); color: #fff; }
.kpi.highlight .delta.down { background: var(--wine); color: #fff; }

/* Industry benchmark target line under KPI cards. Colored by whether the
   current value falls inside, above, or below the target range.
   - in-range: teal (healthy)
   - over/under: wine (watch) for cost metrics where either direction is bad
   We treat over-target as wine (labor/food/prime/occupancy high = bad).
   Under-target is gray for cost metrics (usually good) but wine for
   marketing (under-invested = bad). The Jinja template picks the class. */
.kpi-target {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #999;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dotted #e5e5e5;
  font-weight: 500;
}
.kpi-target.in-range { color: var(--teal); }
.kpi-target.in-range::before {
  content: "● ";
  font-size: 9px;
  letter-spacing: 0;
}
.kpi-target.over { color: var(--wine); }
.kpi-target.over::before {
  content: "▲ ";
  font-size: 9px;
  letter-spacing: 0;
}
.kpi-target.under-bad { color: var(--wine); }
.kpi-target.under-bad::before {
  content: "▽ ";
  font-size: 9px;
  letter-spacing: 0;
}
.kpi-target.under::before {
  content: "▽ ";
  font-size: 9px;
  letter-spacing: 0;
}

/* -------------------------------------------------- summary + insights --- */
.summary-grid {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 26px 30px;
  margin-bottom: 40px;
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 30px;
}
@media (max-width: 900px) {
  .summary-grid { grid-template-columns: 1fr; }
  .summary-divider { display: none; }
}
.summary-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
  margin-bottom: 14px;
}
.summary-text {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 400;
}
.summary-divider { background: var(--ink); }

.insight-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.insight {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}
.insight-bar {
  width: 4px;
  align-self: stretch;
  min-height: 36px;
}
.insight-bar.good    { background: var(--teal); }
.insight-bar.watch   { background: var(--wine); }
.insight-bar.neutral { background: #888; }
.insight-title {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  margin-bottom: 3px;
}
.insight-detail {
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

/* ----------------------------------------------------------------- section */
.section {
  margin-bottom: 40px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.section-title em { font-style: italic; color: var(--wine); }
.section-note {
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* -------------------------------------------------------------------- chart */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 22px;
  height: 360px;
  position: relative;
}
.chart-wrap canvas { max-height: 100% !important; }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
}
.data-table thead tr {
  background: var(--ink);
}
.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  font-weight: 500;
}
.data-table td {
  padding: 13px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}
.data-table td.num {
  font-family: var(--mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table td.num.pos { color: var(--teal); font-weight: 500; }
.data-table td.num.neg { color: var(--wine); font-weight: 500; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.total-row { background: #f0f0f0; }
.data-table tr.total-row td {
  font-weight: 600;
  border-top: 2px solid var(--ink);
}
.data-table .restaurant-name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

/* ----------------------------------------------------------- empty states */
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  padding: 4rem 2rem;
  text-align: center;
}
.empty h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--ink);
}
.empty p {
  color: var(--ink-muted);
  margin-bottom: 24px;
  max-width: 500px;
  margin-left: auto; margin-right: auto;
  font-size: 14px;
}

/* ---------------------------------------------------------- upload form */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 32px;
  max-width: 640px;
}
.form-card h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--ink);
}
.form-card p.lede {
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 28px;
}

.form-row {
  margin-bottom: 20px;
}
.form-row label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
  margin-bottom: 8px;
}
.form-row input[type="text"],
.form-row input[type="month"],
.form-row input[type="file"],
.form-row select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
}
.form-row input:focus,
.form-row select:focus {
  outline: 2px solid var(--ink);
  outline-offset: -1px;
}

.btn {
  display: inline-block;
  padding: 11px 20px;
  background: var(--ink);
  color: #fff;
  border: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s ease;
}
.btn:hover { background: #1a1a1a; }
.btn.primary-wine { background: var(--wine); }
.btn.primary-wine:hover { background: #6f1826; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-soft);
}
.btn.ghost:hover { background: #f5f5f5; }

.radio-group { display: flex; gap: 6px; }
.radio-group label {
  flex: 1;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  margin-bottom: 0;
  padding: 10px 14px;
  border: 1px solid var(--line-soft);
  cursor: pointer;
  text-align: center;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.radio-group input[type="radio"] { display: none; }
.radio-group label:has(input:checked) {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.info-callout {
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--wine-soft);
  border-left: 3px solid var(--wine);
  font-size: 13px;
  max-width: 640px;
  color: #5c1a22;
  line-height: 1.55;
}
.info-callout strong {
  font-family: var(--serif);
  font-weight: 500;
}

/* --------------------------------------------------------------- footer */
.site-footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px;
  border-top: 1px solid var(--line-soft);
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

/* ---------------------------------------------------------- misc helpers */
.hr-light {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 40px 0 24px 0;
}

/* ----------------------------------------------------------- data admin --- */
.unknown-banner {
  margin-bottom: 32px;
  padding: 18px 22px;
  background: var(--wine-soft);
  border-left: 3px solid var(--wine);
}
.unknown-banner h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  margin-bottom: 6px;
  color: #5c1a22;
}
.unknown-banner p {
  font-size: 13px;
  color: #5c1a22;
  margin-bottom: 14px;
  line-height: 1.55;
}

/* ============================================================= login page */
.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 2rem 1rem;
}
.login-shell {
  width: 100%;
  max-width: 420px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 48px 44px 36px;
}
.login-brand {
  text-align: center;
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.login-wordmark {
  display: block;
  margin: 0 auto 6px;
}
.login-sub {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 4px;
}
.login-form { display: flex; flex-direction: column; gap: 4px; }
.login-form .form-row { margin-bottom: 14px; }
.login-form label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  border-radius: 0;
}
.login-form input:focus {
  outline: 2px solid var(--ink);
  outline-offset: -1px;
  border-color: var(--ink);
}
.login-remember {
  margin-top: 4px;
  margin-bottom: 22px !important;
}
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--ink-soft) !important;
  font-weight: 400 !important;
}
.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--ink);
  cursor: pointer;
}
.login-submit {
  width: 100%;
  padding: 13px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.login-error {
  background: var(--wine-soft);
  color: var(--wine);
  border-left: 3px solid var(--wine);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}
.login-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* user menu in header */
.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
  padding-left: 14px;
  border-left: 1px solid #333;
}
.user-name {
  font-size: 11px;
  color: #bbb;
  letter-spacing: 0.04em;
}
.logout-link {
  font-size: 11px;
  color: #888;
  letter-spacing: 0.04em;
  transition: color 0.15s ease;
}
.logout-link:hover { color: #fff; }
