:root {
  --ink: #0f0e0d; --char: #181614; --char-2: #24211d; --line-dark: #34302b;
  --bg: #f6f2eb; --surface: #ffffff; --text: #1b1916; --muted: #73695d; --line: #e7dfd2;
  --brass: #c9a45c; --brass-dark: #8f6f2f; --brass-soft: #f3e8d2;
  --good: #23824b; --good-bg: #e2f3e8; --warn: #a15c07; --warn-bg: #fdf0d8; --bad: #b42318; --bad-bg: #fde7e4;
  --info: #1f4e8c; --info-bg: #e3ecf8;
  --mark: #a8853f;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --serif: "Playfair Display", Georgia, serif; --sans: "Manrope", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brass-dark); }
.hidden { display: none !important; }
h2 { font: 800 22px var(--serif); margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; }

/* Sidebar */
.side { background: var(--ink); color: #e9e2d6; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; border-bottom: 1px solid var(--line-dark); }
.side-brand img { height: 42px; width: auto; }
.side-brand span { font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); }
.side-nav { display: grid; gap: 2px; padding-top: 16px; }
.side-nav button { display: flex; align-items: center; gap: 12px; background: none; border: 0; color: #cfc6b8; text-align: left; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.side-nav button i { font-style: normal; width: 20px; text-align: center; opacity: .8; }
.side-nav button:hover { background: var(--char-2); color: #fff; }
.side-nav button.on { background: var(--char-2); color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
.side-foot { margin-top: auto; font-size: 12px; color: #8f877b; padding: 8px; }
.side-foot a { color: var(--brass); }

/* Top bar */
.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px; background: var(--bg); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top-title { display: flex; align-items: center; gap: 12px; }
.top-logo { display: none; }
.top h1 { font: 800 26px var(--serif); margin: 0; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
select, input, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: 1px; }
.demo-pill { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--info); background: var(--info-bg); padding: 4px 10px; border-radius: 999px; }
.sub-pill { font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--line); cursor: pointer; }
.sub-pill.live { background: var(--good-bg); color: var(--good); }
.sub-pill.overdue { background: var(--warn-bg); color: var(--warn); }
.sub-pill.paused { background: var(--bad-bg); color: var(--bad); }

.view { padding: 24px 28px 60px; max-width: 1280px; }

/* Building blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font: 800 28px/1.2 var(--serif); margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 13px; color: var(--muted); }
.up { color: var(--good); font-weight: 700; } .down { color: var(--bad); font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 14px; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.brass { background: var(--brass); border-color: var(--brass); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.b-booked { background: var(--info-bg); color: var(--info); }
.b-completed { background: var(--good-bg); color: var(--good); }
.b-no_show { background: var(--bad-bg); color: var(--bad); }
.b-cancelled { background: var(--line); color: var(--muted); text-decoration: line-through; }
.b-walk_in { background: var(--brass-soft); color: var(--brass-dark); }
.seg { display: inline-flex; background: var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Today: next-up + timeline */
.next { display: flex; align-items: center; gap: 14px; background: var(--ink); color: #f1eadf; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.next .when { font: 800 28px var(--serif); color: var(--brass); }
.next b { display: block; font-size: 17px; }
.timeline { display: grid; gap: 0; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tl-head { display: grid; position: sticky; top: 0; background: var(--surface); z-index: 2; border-bottom: 1px solid var(--line); }
.tl-head div { padding: 10px; font-weight: 800; font-size: 14px; border-left: 1px solid var(--line); }
.tl-head div:first-child { border-left: 0; }
.tl-body { display: grid; position: relative; }
.tl-hours { position: relative; }
.tl-hours span { position: absolute; left: 8px; font-size: 11px; color: var(--muted); transform: translateY(-50%); font-variant-numeric: tabular-nums; }
.tl-col { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); }
.tl-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 3; pointer-events: none; }
.tl-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.bk { position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 4px 8px; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; border: 0; text-align: left; border-left: 4px solid var(--info); background: var(--info-bg); }
.bk b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk span { color: var(--muted); white-space: nowrap; }
.bk.completed { background: var(--good-bg); border-left-color: var(--good); }
.bk.no_show { background: var(--bad-bg); border-left-color: var(--bad); }
.bk.cancelled { background: #f3f0ea; border-left-color: #c9c1b4; opacity: .65; }
.bk:hover { filter: brightness(.97); }
.list { display: grid; gap: 8px; }
.li { display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; }
.li .t { font: 800 16px var(--serif); }
.li b { display: block; }

/* Calendar week grid */
.week { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.week table { border-collapse: collapse; width: 100%; min-width: 760px; }
.week th, .week td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
.week th { font-size: 13px; color: var(--muted); font-weight: 700; }
.week th.today { color: var(--text); }
.week td.cell { cursor: pointer; border-left: 1px solid var(--line); }
.week td.cell:hover { background: #faf7f1; }
.week td.off { color: var(--muted); font-size: 13px; background: repeating-linear-gradient(135deg, #faf7f1 0 6px, #f4efe6 6px 12px); }
.cell .n { font-weight: 800; }
.cell .r { font-size: 12px; color: var(--muted); }
.util { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.util i { display: block; height: 100%; background: var(--mark); border-radius: 3px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbf9f5; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fbf8f2; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
.stamps-mini { display: inline-flex; gap: 3px; }
.stamps-mini i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--brass); display: inline-block; }
.stamps-mini i.on { background: var(--brass); }

/* Charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart .bar { fill: var(--mark); }
.chart .bar.partial { fill: #d9c49a; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g:hover .bar { fill: #8a6a2c; }
.chart .val { fill: var(--text); font-size: 11px; font-weight: 700; font-family: var(--sans); }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 12px; background: #f4efe6; border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--mark); border-radius: 0 4px 4px 0; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.heat { display: grid; grid-template-columns: 40px repeat(13, 1fr); gap: 3px; font-size: 11px; }
.heat .h { color: var(--muted); text-align: center; }
.heat .d { color: var(--muted); align-self: center; }
.heat .c { aspect-ratio: 1.6; border-radius: 4px; }
.legend-ramp { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend-ramp i { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #f4eee4, #8a6a2c); }
.tip { position: fixed; z-index: 80; pointer-events: none; background: var(--ink); color: #fff; font-size: 12.5px; padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow); white-space: nowrap; }

/* Website editor */
.hours-grid { display: grid; grid-template-columns: 100px 1fr 1fr auto; gap: 8px 10px; align-items: center; }
.hours-grid input[type=time] { padding: 6px 8px; }
.svc-edit { display: grid; grid-template-columns: 1fr 90px 80px auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.svc-edit input { padding: 6px 8px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d6cdbf; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::before { transform: translateX(18px); }

/* Automations */
.auto { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.auto .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--brass-soft); display: grid; place-items: center; font-size: 18px; }
.msg { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.msg time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* Subscription */
.sub-hero { border-radius: 18px; padding: 26px; color: #fff; background: var(--ink); display: grid; gap: 8px; }
.sub-hero .state { font: 800 34px var(--serif); }
.sub-hero.live .state { color: #6ee7a0; } .sub-hero.overdue .state { color: #fbbf24; } .sub-hero.paused .state { color: #f87171; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checks li::before { content: "✓  "; color: var(--good); font-weight: 800; }

/* Drawer / dialog / toast */
.drawer { position: fixed; inset: 0; background: rgba(15,14,13,.4); z-index: 60; display: flex; justify-content: flex-end; }
.drawer-panel { width: min(480px, 100%); height: 100%; overflow-y: auto; background: var(--surface); padding: 24px; position: relative; }
.x { position: absolute; right: 14px; top: 10px; background: none; border: 0; font-size: 28px; color: var(--muted); cursor: pointer; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; margin: 12px 0 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.sec { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100% - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15,14,13,.45); }
dialog form { padding: 22px; display: grid; gap: 12px; }
dialog label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
dialog label input, dialog label select { color: var(--text); }
.err { color: var(--bad); font-size: 13px; font-weight: 700; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 90; font-size: 14px; font-weight: 600; }
.bottom, .sheet { display: none; }

/* Photos & Instagram */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; min-height: 150px; border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; padding: 18px; background: var(--bg); transition: .15s; }
.drop:hover, .drop.over { border-color: var(--brass); background: var(--brass-soft); }
.drop b { font-size: 16px; }
.up-status { margin-top: 10px; font-weight: 700; color: var(--brass-dark); }
.cover { height: 150px; border-radius: 12px; background: var(--ink) center 22% / cover; position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 14px; }
.cover::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(15,14,13,.9), rgba(15,14,13,.2)); }
.cover span { position: relative; color: #f4eee4; font: 800 20px/1.05 var(--serif); }
.cover span i { font-style: normal; color: var(--brass); }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ph { position: relative; margin: 0; border-radius: 12px; overflow: hidden; background: var(--line); aspect-ratio: 4 / 5; cursor: grab; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ph.off img { opacity: .35; filter: grayscale(1); }
.ph.dragging { opacity: .4; outline: 2px dashed var(--brass); }
.ph-tag { position: absolute; top: 8px; left: 8px; background: var(--brass); color: var(--ink); font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.ph-tag.muted-tag { background: var(--ink); color: #fff; left: auto; right: 8px; }
.ph figcaption { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; gap: 2px; padding: 6px; background: linear-gradient(0deg, rgba(15,14,13,.85), transparent); }
.ic-btn { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); color: var(--ink); cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center; padding: 0; }
.ic-btn:hover { background: #fff; }
.ic-btn:disabled { opacity: .35; cursor: default; }
.ic-btn.danger { color: var(--bad); }
.ig-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ig { position: relative; margin: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.ig img { width: 100%; height: 100%; object-fit: cover; }
.ig.off img { opacity: .3; filter: grayscale(1); }
.ig .ic-btn { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; }
.note { background: var(--info-bg); color: var(--info); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 0 0 12px; }

@media (max-width: 900px) {
  .ph-grid { grid-template-columns: repeat(2, 1fr); }
  .ph { cursor: default; }
  body { display: block; }
  .side { display: none; }
  .top { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
  .top-logo { display: block; height: 30px; width: auto; filter: invert(1) brightness(.2); }
  .top h1 { font-size: 21px; }
  .top-actions { width: 100%; }
  .top-actions select { flex: 1; }
  .view { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile .v { font-size: 23px; }
  .bottom { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--ink); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom button { background: none; border: 0; color: #a99f91; display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 700; padding: 6px 0; border-radius: 10px; cursor: pointer; }
  .bottom button i { font-style: normal; font-size: 18px; }
  .bottom button.on { color: #fff; background: var(--char-2); }
  .sheet { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15,14,13,.45); }
  .sheet.hidden { display: none !important; }
  .sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 18px 18px 0 0; padding: 14px 14px calc(80px + env(safe-area-inset-bottom)); display: grid; gap: 4px; }
  .sheet-panel button, .sheet-panel a { display: flex; gap: 12px; align-items: center; background: none; border: 0; text-align: left; padding: 14px 12px; border-radius: 12px; font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; cursor: pointer; }
  .sheet-panel button:hover, .sheet-panel a:hover { background: var(--bg); }
  .sheet-panel i { font-style: normal; width: 24px; text-align: center; }
  .hours-grid { grid-template-columns: 76px 1fr 1fr auto; }
  .svc-edit { grid-template-columns: 1fr 72px 64px auto; }
  .svc-edit .save-col { grid-column: 1 / -1; justify-self: end; }
  .table .hide-m { display: none; }
  .hbar { grid-template-columns: minmax(90px, 40%) 1fr auto; }
  .heat { grid-template-columns: 30px repeat(13, 1fr); gap: 2px; font-size: 9px; }
  .drawer-panel { padding: calc(20px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* Opening-hours cards wrap instead of overflowing */
.hours-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.hours-grid { grid-template-columns: 44px minmax(0,1fr) minmax(0,1fr) auto; }
.hours-grid input[type=time] { min-width: 0; width: 100%; }
