/* ===== Dashboard layout (denser, line-separated, light) ===== */
.brand { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
.brand-mark { width: 32px; height: 32px; color: var(--accent); grid-row: span 2; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
.rail-link { font-size: 13px; color: var(--text-3); text-decoration: none; }
.rail-link:hover { color: var(--text); text-decoration: underline; }

/* Login */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login[hidden], .app[hidden] { display: none; }
.login-art { background: var(--accent); color: #fff; padding: clamp(24px, 5vw, 64px); display: flex; flex-direction: column; justify-content: flex-end; }
.login-art h2 { font-size: clamp(34px, 4vw, 60px); line-height: 1; letter-spacing: -0.03em; max-width: 11ch; }
.login-art p { margin-top: 14px; opacity: 0.9; max-width: 36ch; font-size: 15px; }
.login-card { align-self: center; width: min(100%, 420px); margin: 0 auto; padding: 24px; display: grid; gap: 18px; }
.login-card h1 { font-size: 32px; margin-top: 16px; }
.login-card .muted { margin-top: -10px; font-size: 14px; }
.login-error { color: var(--danger); font-size: 14px; background: var(--danger-soft); border: 1px solid #f0c4bf; padding: 10px 12px; border-radius: 10px; }

/* App shell */
.app { max-width: 1400px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 40px) 40px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  background: rgba(247,245,239,0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.ranges { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.range { min-height: 38px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--text-2); font-size: 14px; font-weight: 500; transition: background 160ms, color 160ms; }
.range[aria-selected="true"] { background: var(--text); color: #fff; }
.actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.actions .btn { text-decoration: none; }

.block { padding: 28px 0; border-bottom: 1px solid var(--line); }
.block-head { display: grid; gap: 4px; margin-bottom: 18px; }
.block-head.row { grid-template-columns: 1fr auto; align-items: center; }
.block-head h2 { font-size: 24px; }
.block-head .muted { font-size: 14px; }
.count { font-size: 14px; color: var(--text-3); margin-left: 8px; font-weight: 500; }
.input-sm { min-height: 44px; padding: 8px 14px; font-size: 15px; width: min(100%, 320px); }

/* Lookup */
.lookup-form { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; max-width: 760px; }
.lookup-form #lookupClear[hidden] { display: none; }
.brand-home { text-decoration: none; color: inherit; border-radius: 10px; }
.brand-home:hover .brand-name { text-decoration: underline; }
.lookup-result { margin-top: 18px; max-width: 900px; }
.guest { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; padding: 18px 0; border-top: 1px solid var(--line); }
.guest-name { font-family: var(--font-display); font-size: 26px; }
.guest-meta { font-size: 14px; color: var(--text-2); display: flex; gap: 14px; flex-wrap: wrap; }
.guest-offer { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-size: 15px; }
.guest-offer strong { font-family: var(--font-display); font-size: 24px; font-weight: 800; }
.guest-offer.new { background: var(--surface-2); color: var(--text-2); }
.guest-visits { grid-column: 1 / -1; display: grid; gap: 0; }
.visit-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 14px; align-items: center; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 14px; color: var(--text-2); }
.visit-row .mono { color: var(--text); }
.lookup-none { padding: 14px 0; color: var(--text-3); border-top: 1px solid var(--line); }

/* Entries to complete */
.open-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 12px; }
.open-card { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.open-card .oc-name { font-family: var(--font-display); font-size: 19px; font-weight: 800; }
.open-card .oc-meta { font-size: 13px; color: var(--text-2); margin-top: -6px; }
.open-card .oc-meta .mono { color: var(--text); }
.oc-fields { display: grid; grid-template-columns: 1.5fr 1.5fr 1fr; gap: 10px; }
.oc-fields label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.oc-fields .input { min-height: 44px; font-size: 15px; padding: 8px 10px; }
.oc-fields .tpick .input { padding: 8px 4px; font-size: 15px; }
.oc-fields .input-wrap .input { padding-left: 30px; }
.oc-fields .input-wrap .prefix { left: 10px; font-size: 14px; }
.oc-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.btn-del { background: transparent; border: 1px solid transparent; color: var(--text-3); min-height: 40px; padding: 0 10px; border-radius: 10px; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn-del:hover { color: var(--danger); background: var(--danger-soft); }
.btn-del svg { width: 16px; height: 16px; }
.oc-actions .err { font-size: 12px; color: var(--danger); margin-right: auto; }
.open-empty { color: var(--text-3); font-size: 14px; padding: 10px 0; }
/* Stats */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); padding: 16px 0; }
.stat { display: grid; gap: 4px; padding: 4px 20px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat-v { font-family: var(--font-mono); font-size: 32px; font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; }
.stat-v small { font-size: 14px; color: var(--text-3); font-weight: 500; margin-left: 4px; }
.stat-l { font-size: 13px; color: var(--text-3); }
.skeleton-stat .stat-v { color: var(--line); }

/* Charts (CSS bars) */
.charts { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: stretch; }
.chart.tall { grid-row: span 2; }
.chart { display: flex; flex-direction: column; }
.chart .chart-body { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; }
.chart { margin: 0; min-width: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); padding: 18px 20px 20px; box-shadow: 0 1px 0 rgba(23,25,28,0.03); }
.span-8 { grid-column: span 8; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
.chart figcaption { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 14px; display: flex; justify-content: space-between; align-items: baseline; }
.chart figcaption span { color: var(--text-3); font-weight: 400; font-size: 13px; }
.chart-body { min-height: 120px; }
.chart-empty { color: var(--text-3); font-size: 14px; padding: 24px 0; }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 160px; border-bottom: 1px solid var(--line-strong); }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.col .bar { flex: none; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; transition: opacity 120ms; }
.col .bar.zero { background: var(--line); }
.col:hover .bar { opacity: 0.8; }
.col .v { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); text-align: center; margin-bottom: 4px; }
.col-labels { display: flex; gap: 6px; margin-top: 6px; }
.col-labels span { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 96px 1fr 72px; align-items: center; gap: 10px; font-size: 13px; }
.hbar .l { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 6px; }
.hbar .v { font-family: var(--font-mono); color: var(--text-2); text-align: right; }

.span-6 { grid-column: span 6; }
/* Donut */
.donut { display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: center; }
.donut svg { width: 150px; height: 150px; }
.donut .center { font-family: var(--font-mono); font-size: 26px; font-weight: 600; fill: var(--text); }
.donut .center-l { font-size: 11px; fill: var(--text-3); }
.legend { display: grid; gap: 7px; font-size: 13px; }
.legend div { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 10px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .l { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend .v { font-family: var(--font-mono); color: var(--text); }
.legend .p { font-family: var(--font-mono); color: var(--text-3); min-width: 38px; text-align: right; }
/* Calendar */
.cal { display: grid; gap: 6px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head span { font-size: 12px; font-weight: 700; color: var(--text-3); text-align: center; padding-bottom: 2px; }
.cal-head span.we { color: var(--accent); }
.cal-cell { min-height: 64px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 8px 10px; display: flex; flex-direction: column; justify-content: space-between; }
.cal-cell.we.l0 { background: #f3faf6; }
.cal-cell.today { outline: 2px solid var(--text); outline-offset: -2px; }
.cal-d { font-size: 13px; font-weight: 700; color: var(--text-2); display: flex; gap: 4px; align-items: baseline; }
.cal-d small { font-size: 11px; font-weight: 500; color: var(--text-3); }
.cal-n { font-family: var(--font-mono); font-size: 20px; font-weight: 600; line-height: 1; text-align: right; }
.cal-cell.l0 .cal-n { color: var(--line-strong); }
.cal-cell.l1 { background: #e9f5ee; } .cal-cell.l2 { background: #cfeadb; } .cal-cell.l3 { background: #a9dbbf; border-color: #8fcfab; } .cal-cell.l4 { background: var(--accent); border-color: var(--accent); color: #fff; }
.cal-cell.l4 .cal-d, .cal-cell.l4 .cal-d small { color: rgba(255,255,255,0.85); }
.cal-legend { display: flex; align-items: center; gap: 6px; justify-content: flex-end; flex-wrap: wrap; font-size: 12px; color: var(--text-3); margin-top: 6px; }
.cal-note { margin-left: 10px; }
.cal-legend i { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.cal-legend .l1 { background: #e9f5ee; } .cal-legend .l2 { background: #cfeadb; } .cal-legend .l3 { background: #a9dbbf; } .cal-legend .l4 { background: var(--accent); }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.cal-day { border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 12px; display: grid; gap: 2px; text-align: center; }
.cal-day.today { outline: 2px solid var(--text); outline-offset: -2px; }
.cal-day.l3, .cal-day.l4 { background: var(--accent-soft); border-color: #8fcfab; }
.cal-wd { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-date { font-size: 13px; color: var(--text-2); }
.cal-big { font-family: var(--font-mono); font-size: 30px; font-weight: 600; line-height: 1.1; margin-top: 6px; }
.cal-sub { font-size: 12px; color: var(--text-3); }
.cal-amt { font-family: var(--font-mono); font-size: 13px; color: var(--text-2); margin-top: 6px; }
/* Heatmap */
.heat-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.heat { display: grid; gap: 4px; font-size: 11px; color: var(--text-3); min-width: 480px; }
.heat-row, .heat-x { display: grid; grid-template-columns: 36px repeat(13, 1fr); gap: 4px; align-items: center; }
.heat-cell { aspect-ratio: 1.6; border-radius: 4px; background: var(--accent); }
.heat-cell.z { background: var(--surface-2); }
.heat-x span { text-align: center; }
/* Stacked bar */
.stack { display: grid; gap: 10px; }
.stack-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.stack-bar span { display: block; height: 100%; }
.stack-big { font-family: var(--font-mono); font-size: 34px; font-weight: 600; line-height: 1; }
.stack-big small { font-size: 13px; color: var(--text-3); font-weight: 500; margin-left: 6px; font-family: var(--font-body); }
.splits { display: grid; gap: 18px; }
.split .split-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.split .split-head b { font-family: var(--font-mono); color: var(--text); font-weight: 600; }
/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; padding: 8px 12px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table th.num, .table td.num { text-align: right; font-family: var(--font-mono); }
.table td.wrap { white-space: normal; min-width: 160px; }
.table tr:hover td { background: rgba(23,25,28,0.025); }
.table .name { font-weight: 500; }
.table .sub { display: block; font-size: 12px; color: var(--text-3); }
.empty { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty svg { width: 36px; height: 36px; color: var(--text-3); }
.foot { padding: 20px 0; font-size: 13px; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(23,25,28,0.5); }
.modal[hidden] { display: none; }
.modal-card { width: min(100%, 520px); background: var(--surface); border-radius: var(--radius-lg); padding: 26px; display: grid; gap: 16px; box-shadow: 0 30px 60px -20px rgba(23,25,28,0.45); }
.modal-card h2 { font-size: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.dropzone { display: grid; place-items: center; min-height: 96px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--text-2); cursor: pointer; text-align: center; background: var(--surface-2); }
.dropzone:hover { border-color: var(--accent); }
.dropzone input { position: absolute; opacity: 0; width: 0; height: 0; }
.restore-summary { font-size: 14px; color: var(--text-2); display: grid; gap: 4px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; }
.restore-summary strong { color: var(--text); }

/* Responsive */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); row-gap: 20px; }
  .stat:nth-child(4) { border-left: 0; }
  .span-8, .span-5, .span-4, .span-3, .span-6 { grid-column: span 6; }
  .chart.tall { grid-row: auto; grid-column: span 12; }
}
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }
@media (max-width: 720px) {
  .topbar { gap: 12px; }
  .ranges { order: 3; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .actions { order: 2; margin-left: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); padding: 8px 0; }
  .stat { padding: 10px 16px; }
  .stat:nth-child(odd) { border-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .span-8, .span-5, .span-4, .span-3, .span-6 { grid-column: span 12; }
  .chart.tall { grid-row: auto; }
  .charts { gap: 12px; }
  .chart { padding: 14px; }
  .cal-head, .cal-grid { gap: 4px; }
  .cal-cell { min-height: 54px; padding: 6px; border-radius: 8px; }
  .cal-d { font-size: 12px; } .cal-d small { display: none; } .cal-n { font-size: 16px; }
  .cal-week { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .cal-day { padding: 8px; } .cal-big { font-size: 24px; }
  .donut { grid-template-columns: 120px 1fr; gap: 14px; }
  .donut svg { width: 120px; height: 120px; }
  .cols { gap: 3px; }
  .col .v { font-size: 10px; }
  .col-labels { gap: 3px; }
  .col-labels span { font-size: 10px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-v { font-size: 24px; }
  .actions { width: 100%; margin-left: 0; }
  .actions .btn { flex: 1 1 auto; padding: 0 10px; font-size: 14px; }
  .lookup-form { grid-template-columns: 1fr 1fr; }
  .lookup-form .input { grid-column: 1 / -1; }
  .block-head.row { grid-template-columns: 1fr; }
  .input-sm { width: 100%; }
  .guest, .visit-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
