/* TableTap platform admin: every restaurant, subscription and invoice in one place (the platform admin site). */
:root {
  color-scheme: light;
  --bg: #faf9f5;
  --card: #fff;
  --line: #e5e5dc;
  --ink: #1c211d;
  --muted: #666b63;
  --green: #174d32;
  --green-2: #376b49;
  --green-soft: #e8f0e5;
  --amber: #8a5a0b;
  --amber-soft: #fbefd7;
  --red: #a8321f;
  --red-soft: #fbe6e1;
  --grey-soft: #eeeee8;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,33,29,.04), 0 6px 18px rgba(28,33,29,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1, h2, .serif { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tt-logo { display: inline-block; flex: none; width: 44px; aspect-ratio: 488 / 482; background: url("brand/tabletap-logo-light.png") center / contain no-repeat; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
:focus-visible { outline: 3px solid #c98a1a; outline-offset: 2px; }

/* Buttons and fields */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; }
.button:hover { border-color: var(--green-2); }
.button.primary { border-color: var(--green); background: var(--green); color: #fff; }
.button.primary:hover { background: #123f29; }
.button.soft { border-color: transparent; background: var(--green-soft); color: var(--green); }
.button.danger { color: var(--red); }
.button.small { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.button:disabled { opacity: .55; cursor: default; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
input, select, textarea { width: 100%; min-height: 38px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
textarea { min-height: 76px; resize: vertical; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--green); }
label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 700; }
.field-hint { margin-top: 5px; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { min-height: 20px; margin-top: 10px; color: var(--red); font-weight: 600; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 9px; margin: 0; font-weight: 500; font-size: 13px; }

/* Sign-in gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: min(460px, 100%); padding: 32px 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.gate-card .tt-logo { width: 60px; margin-bottom: 14px; }
.gate-card h1 { margin: 6px 0 8px; font-size: 26px; }
.gate-card p { color: var(--muted); }
.gate-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.gate-card .form-stack { display: grid; gap: 12px; margin-top: 18px; }
.gate-card .form-stack p { margin: 0; }
.wide-button { width: 100%; margin-top: 12px; }
.code-input { font: 600 24px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 8px; text-align: center; }
.totp-steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.totp-qr { display: grid; place-items: center; min-height: 120px; color: var(--muted); font-size: 13px; text-align: center; }
.totp-qr svg { width: min(220px, 100%); height: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.totp-key { display: grid; gap: 4px; text-align: center; }
.totp-key span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.totp-key code { padding: 8px 10px; border-radius: 8px; background: var(--grey-soft); color: var(--ink); font: 600 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; word-break: break-all; user-select: all; }
/* Sign-in progress and problems, above the sign-in screens. */
.sign-in-message { position: fixed; z-index: 80; top: 16px; left: 50%; max-width: min(560px, calc(100% - 32px)); transform: translateX(-50%); padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); box-shadow: 0 12px 32px rgba(28,33,29,.14); font-size: 13px; }
.sign-in-message.error { border-color: #efc4b9; background: var(--red-soft); color: var(--red); }
.sign-in-message.success { border-color: #c7d8c4; background: var(--green-soft); color: var(--green); }

/* Layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 20px 14px; border-right: 1px solid var(--line); background: #fdfcf9; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: var(--ink); text-decoration: none; }
.brand strong { display: block; font: 600 22px/1.1 var(--serif); color: var(--green); }
.brand small { color: var(--muted); font-size: 11px; }
.nav { display: grid; gap: 4px; }
.nav a, .sidebar-foot a { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 10px; color: var(--ink); font-weight: 500; text-decoration: none; }
.nav a:hover, .sidebar-foot a:hover { background: var(--green-soft); }
.nav a[aria-current="page"] { background: var(--green); color: #fff; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(20,24,21,.4); }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); }
#menu-button { display: none; }
.range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.range select { width: auto; font-weight: 600; }
.range-custom { display: inline-flex; align-items: center; gap: 6px; }
.range-custom input { width: 150px; }
.range-label { color: var(--muted); font-size: 12px; }
.account { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; font-size: 13px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-text { display: grid; line-height: 1.2; min-width: 0; }
.account-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-size: 13px; }
.account-text small { color: var(--muted); font-size: 11px; }
.page { padding: 22px 24px 48px; max-width: 1640px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-top: 4px; font-size: 34px; line-height: 1.1; }
.page-head p { margin-top: 6px; color: var(--muted); }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { font-size: 22px; }
.card-head p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; align-items: start; align-content: start; padding: 14px 16px; }
.kpi .icon { grid-row: span 3; width: 26px; height: 26px; margin-top: 2px; color: var(--green); }
.kpi-label { font-size: 12px; font-weight: 600; }
.kpi-value { font: 600 22px/1.2 var(--serif); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-note { color: var(--muted); font-size: 12px; }
.kpi.warn .icon { color: var(--red); }
.grid-main { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
/* Grid children may shrink below their content, so a wide table scrolls inside its card instead of pushing the page sideways. */
.grid-main > *, .grid-two > *, .stack > *, .kpis > * { min-width: 0; }

/* Tables */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { width: auto; min-width: 150px; }
.filters .search { position: relative; flex: 1; min-width: 200px; }
.filters .search .icon { position: absolute; left: 11px; top: 9px; color: var(--muted); }
.filters .search input { padding-left: 38px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 10px; border-bottom: 1px solid var(--line); background: #f7f6f1; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-align: left; text-transform: uppercase; white-space: nowrap; }
th.num { text-align: right; }
td { padding: 10px; border-bottom: 1px solid #efeee7; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td strong { font-weight: 700; }
.cell-name { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.cell-name .avatar { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.row-actions { display: flex; gap: 6px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; color: var(--muted); font-size: 13px; }
.pager { display: flex; align-items: center; gap: 8px; }
.empty { padding: 26px 16px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.error-box { padding: 14px 16px; border: 1px solid var(--red); border-radius: 12px; background: var(--red-soft); color: var(--red); font-weight: 600; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, #eeede6 25%, #f7f6f1 50%, #eeede6 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton + .skeleton { margin-top: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--green-soft); color: var(--green); }
.pill.wait { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.off { background: var(--grey-soft); color: var(--muted); }
.pill.plan { background: var(--green-soft); color: var(--green); }
.pill.plan::before { content: none; }
.pill.plan.top { background: var(--green-2); color: #fff; }

/* Overview side column */
.donut-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { position: relative; width: 132px; aspect-ratio: 1; border-radius: 50%; flex: none; }
.donut::after { content: ""; position: absolute; inset: 17px; border-radius: 50%; background: var(--card); }
.donut-text { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut-text strong { font: 600 22px/1.1 var(--serif); font-variant-numeric: lining-nums; }
.donut-text span { color: var(--muted); font-size: 12px; }
.legend { flex: 1; min-width: 150px; display: grid; gap: 8px; }
.legend div { display: flex; justify-content: space-between; gap: 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; }
.mini-list { display: grid; gap: 2px; margin-top: 6px; }
.mini-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid #efeee7; }
.mini-list > div:first-child { border-top: 0; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick .button { justify-content: flex-start; min-width: 0; min-height: 42px; padding: 6px 12px; white-space: normal; text-align: left; line-height: 1.25; }
.plan-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.plan-count { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.plan-count strong { display: block; font: 600 24px/1.2 var(--serif); font-variant-numeric: lining-nums; }
.plan-count span { color: var(--muted); font-size: 12px; }

/* Bar chart */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; align-items: end; height: 190px; padding-top: 18px; }
.bar { display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; text-align: center; font-size: 12px; color: var(--muted); }
.bar-fill { position: relative; align-self: end; min-height: 2px; border-radius: 6px 6px 0 0; background: #bcd6b6; }
.bar:last-child .bar-fill { background: var(--green); }
.bar-fill span { position: absolute; left: 0; right: 0; top: -18px; color: var(--ink); font-size: 11px; font-weight: 700; }
.hbar { display: grid; grid-template-columns: minmax(110px, 1.2fr) 3fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.hbar-track { height: 10px; border-radius: 5px; background: var(--grey-soft); overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 5px; background: var(--green-2); }

/* Details */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 22px; }
.detail-grid dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-grid dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--amber-soft); color: #5e3d06; font-size: 13px; }
.notice.bad { background: var(--red-soft); color: var(--red); }
.notice.info { background: var(--green-soft); color: var(--green); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); font-weight: 600; font-size: 13px; }
.tabs button[aria-pressed="true"] { border-color: var(--green); background: var(--green); color: #fff; }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.plan-cards ul { margin: 12px 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
.plan-cards li.off { color: var(--muted); text-decoration: line-through; }

/* Dialog and toast */
dialog { width: min(720px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); box-shadow: 0 24px 60px rgba(0,0,0,.22); }
dialog.wide { width: min(980px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(20,24,21,.45); }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.dialog-head h2 { font-size: 22px; }
.dialog-body { padding: 18px 20px 22px; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 22px; max-width: min(620px, calc(100% - 24px)); transform: translateX(-50%); padding: 12px 16px; border-radius: 11px; background: #1c211d; color: #fff; box-shadow: 0 12px 32px rgba(0,0,0,.25); }
.toast.error { background: #8a2a1a; }

/* Invoice sheet (on screen and printed) */
.invoice { padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: #1c211d; font-size: 13px; }
.invoice-top { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.invoice-top h3 { font: 600 28px/1.1 var(--serif); color: var(--green); }
.invoice-brand { display: flex; gap: 12px; align-items: flex-start; }
.invoice-meta { text-align: right; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0; }
.invoice h4 { margin: 0 0 4px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.invoice pre { margin: 0; font: inherit; white-space: pre-wrap; }
.invoice-totals { margin: 14px 0 0 auto; width: min(320px, 100%); }
.invoice-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.invoice-totals .due { margin-top: 4px; padding-top: 9px; border-top: 2px solid var(--green); font-weight: 700; font-size: 15px; }
.invoice-foot { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  body { background: #fff; }
  .invoice { border: 0; padding: 0; }
  @page { margin: 16mm; }
}

/* Smaller screens */
@media (max-width: 1180px) {
  .grid-main, .grid-two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-105%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  #menu-button { display: inline-grid; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .page { padding: 16px 16px 40px; }
  .page-head h1 { font-size: 27px; }
  .account-text { display: none; }
  .form-grid, .invoice-parties, .quick { grid-template-columns: minmax(0, 1fr); }
  .invoice { padding: 16px; }
  .invoice-meta { text-align: left; }
  .range-custom input { width: 132px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
