:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-alt: #fafaf7;
  --border: #e2e4de;
  --border-strong: #c8ccc2;
  --ink: #1a1d1a;
  --ink-dim: #55584f;
  --ink-mute: #8a8d82;
  --accent: #2d6a5f;
  --accent-hover: #23554c;
  --accent-soft: #e8f0ed;
  --danger: #a4322a;
  --warning: #b06f10;
  --shadow-sm: 0 1px 2px rgba(20, 25, 20, 0.04);
  --shadow: 0 2px 8px rgba(20, 25, 20, 0.06);
  --shadow-lg: 0 12px 32px rgba(20, 25, 20, 0.08);
  --r: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Top nav --- */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 24px; height: 24px;
  background: var(--accent);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 700;
}
.brand-sub {
  color: var(--ink-mute);
  font-weight: 400;
  font-size: 13px;
  margin-left: 0.5rem;
  border-left: 1px solid var(--border);
  padding-left: 0.7rem;
}

.nav-tabs {
  display: flex;
  gap: 0;
  margin-left: 2rem;
  flex: 1;
}
.nav-tab {
  padding: 0 1rem;
  height: 56px;
  display: inline-flex;
  align-items: center;
  color: var(--ink-dim);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.nav-tab:hover { color: var(--ink); text-decoration: none; background: var(--surface-alt); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.exit-demo {
  color: var(--ink-mute);
  font-size: 13px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: all 0.15s;
}
.exit-demo:hover { color: var(--ink); border-color: var(--border-strong); text-decoration: none; background: var(--surface-alt); }

/* --- Page layout --- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}
.page-head .subtitle {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 3px;
}
.breadcrumb {
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 500;
}
.breadcrumb a { color: var(--ink-mute); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { margin: 0 0.4rem; opacity: 0.5; }

/* --- Cards / panels --- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
}
.panel-head h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}
.panel-head .actions { display: flex; gap: 0.5rem; }
.panel-body { padding: 1.2rem; }
.panel-body.p0 { padding: 0; }

/* --- Stat tiles --- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 0.3rem;
}
.stat-sub.up { color: var(--accent); }
.stat-sub.down { color: var(--danger); }

/* --- Two-column dashboard row --- */
.dash-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) { .dash-row { grid-template-columns: 1fr; } }

/* --- Tables --- */
.tbl-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.tbl thead th {
  background: var(--surface-alt);
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
table.tbl tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover td { background: var(--surface-alt); }
table.tbl td .row-title {
  font-weight: 500;
  color: var(--ink);
}
table.tbl td .row-title:hover { color: var(--accent); }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }

/* --- Toolbar (search + filters) --- */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.toolbar .search {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.toolbar .search input {
  width: 100%;
  padding: 0.5rem 0.8rem 0.5rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.toolbar .search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.toolbar .search svg {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--ink-mute);
}
.toolbar select {
  padding: 0.5rem 2rem 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%238a8d82' d='M6 8L2 4h8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 10px;
  font-family: inherit;
}
.toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.result-count {
  color: var(--ink-mute);
  font-size: 12px;
  margin-left: auto;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.2rem;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 13px;
  color: var(--ink-dim);
}
.pagination .pages { display: flex; gap: 0.4rem; }
.pagination a, .pagination span {
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  color: var(--ink-dim);
  min-width: 32px;
  text-align: center;
}
.pagination a:hover { background: var(--surface); text-decoration: none; color: var(--ink); }
.pagination .current {
  background: var(--accent);
  color: white;
  font-weight: 500;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--ink-dim);
  border: 1px solid var(--border);
}
.badge.rating-G, .badge.rating-PG { background: #e8f4e8; color: #2d5a2d; border-color: #c8dcc8; }
.badge.rating-PG-13 { background: #fff4d6; color: #7a5510; border-color: #e8d998; }
.badge.rating-R { background: #fce4e0; color: #8a3020; border-color: #e8b8b0; }
.badge.rating-NC-17 { background: #f0dede; color: #6a1010; border-color: #d8a8a8; }
.badge.cat { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.rented { background: #eef2f9; color: #2d4a72; border-color: #c8d4e8; }
.badge.returned { background: var(--surface-alt); color: var(--ink-mute); }

/* --- Film detail --- */
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem 1.8rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.detail-hero h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
}
.detail-hero .subline {
  color: var(--ink-mute);
  font-size: 13px;
  margin-bottom: 1rem;
}
.detail-hero .subline .sep { margin: 0 0.5rem; opacity: 0.5; }
.detail-hero .desc {
  color: var(--ink-dim);
  font-size: 14px;
  max-width: 720px;
  line-height: 1.6;
}
.detail-cols {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) { .detail-cols { grid-template-columns: 1fr; } }

.kv-list { display: grid; gap: 0; }
.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-row:last-child { border-bottom: none; }
.kv-key { color: var(--ink-mute); }
.kv-val { color: var(--ink); font-weight: 500; text-align: right; }

.actor-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.actor-tag {
  padding: 4px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--ink-dim);
}

/* --- Empty state --- */
.empty {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--ink-mute);
  font-size: 13px;
}

/* --- Demo banner --- */
.demo-banner {
  background: var(--accent-soft);
  border-bottom: 1px solid #cfe0da;
  padding: 0.5rem 1.5rem;
  font-size: 12px;
  color: #1e4c43;
  text-align: center;
}
.demo-banner strong { color: var(--accent); }
.demo-banner a { color: #1e4c43; text-decoration: underline; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn:hover { border-color: var(--border-strong); color: var(--ink); text-decoration: none; background: var(--surface-alt); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; }

/* --- Small utilities --- */
.muted { color: var(--ink-mute); }
.small { font-size: 12px; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.text-right { text-align: right; }

/* --- Simple bar chart (for dashboard) --- */
.barchart { padding: 0.5rem 0; }
.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0;
  font-size: 12px;
}
.bar-label { color: var(--ink-dim); font-weight: 500; }
.bar-track { background: var(--surface-alt); border-radius: 3px; height: 8px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 3px; }
.bar-value { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }

/* --- Staff picker in top nav --- */
.staff-picker {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0 1rem;
}
.staff-picker label {
  font-size: 12px; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.staff-picker select {
  padding: 0.35rem 1.8rem 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%238a8d82' d='M6 8L2 4h8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  background-size: 9px;
  font-family: inherit;
}

/* --- Flash messages --- */
.flash {
  padding: 0.8rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align: center;
}
.flash-success { background: var(--accent-soft); color: #1e4c43; }
.flash-error   { background: #fce4e0; color: #8a3020; }
.flash-info    { background: #eef2f9; color: #2d4a72; }

/* --- Row action buttons in tables --- */
.row-actions {
  display: flex; gap: 0.35rem;
  justify-content: flex-end;
}
.icon-btn {
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-mute);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--border-strong); background: var(--surface-alt); text-decoration: none; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: #fce4e0; }

/* --- Modal / edit form panel (HTMX target) --- */
.edit-panel {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.edit-panel h3 {
  font-size: 15px; font-weight: 600; margin: 0 0 1rem;
  color: var(--ink);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 0.3rem; }
.form-field label {
  font-size: 11px; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.form-field input, .form-field select, .form-field textarea {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-field textarea { min-height: 80px; resize: vertical; }
.form-field .error-msg {
  color: var(--danger); font-size: 12px; margin-top: 0.15rem;
}
.form-field.has-error input, .form-field.has-error select, .form-field.has-error textarea {
  border-color: var(--danger);
}
.form-actions {
  display: flex; gap: 0.6rem; margin-top: 1.2rem;
  padding-top: 1rem; border-top: 1px solid var(--border);
}

/* --- HTMX loading indicator --- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Cashier page --- */
.cashier-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1rem;
}
@media (max-width: 900px) { .cashier-grid { grid-template-columns: 1fr; } }

.cart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
}
.cart-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-mute);
  font-size: 13px;
}
.cart-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item .rm {
  background: transparent; border: none; color: var(--danger);
  cursor: pointer; padding: 0.2rem 0.5rem; font-size: 16px;
  border-radius: 4px;
}
.cart-item .rm:hover { background: #fce4e0; }
.cart-total {
  display: flex; justify-content: space-between;
  padding: 0.9rem 0 0.2rem;
  border-top: 2px solid var(--border);
  margin-top: 0.5rem;
  font-weight: 600; font-size: 15px;
}
.film-picker {
  max-height: 500px; overflow-y: auto;
}

/* --- Checkout success screen --- */
.receipt {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 2rem;
  max-width: 500px;
  margin: 2rem auto;
  box-shadow: var(--shadow);
}
.receipt h2 {
  color: var(--accent);
  font-size: 20px; font-weight: 600;
  margin: 0 0 1rem;
}

/* --- Little "no data changed" indicator that reset banner uses --- */
.reset-banner {
  background: var(--warning); background: #fff4d6;
  border-bottom: 1px solid #e8d998;
  padding: 0.5rem 1.5rem;
  text-align: center; font-size: 12px; color: #7a5510;
}
