:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #4f46e5;
    --primary-soft: #eef2ff;
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);

    --brand-primary: var(--primary);
    --brand-accent: #10b981;
    --brand-bg: #f8fafc;
    --brand-text: var(--text);
    --brand-font: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
/* FocusOnNavigate moves focus to the h1 for screen readers - no visible ring needed */
h1:focus { outline: none; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.inline { display: inline; }
.spacer { flex: 1; }
.page-loading { padding: 40px; color: var(--muted); text-align: center; }
.error-text { color: var(--danger); font-size: .85rem; margin-top: 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

/* ---------- building blocks ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-header h2 { margin: 0; }

.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.page-header .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 8px;
    padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer;
    background: var(--primary); color: #fff; text-decoration: none; white-space: nowrap;
    transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: rgba(15,23,42,.05); }
.btn-danger { background: var(--danger); }
.btn-success { background: var(--success); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > label, .label { font-weight: 500; font-size: .88rem; }
.field .hint { color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=url], input[type=date], input[type=time], input[type=datetime-local], input[type=color], select, textarea {
    font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text); width: 100%;
}
input[type=color] { padding: 2px; height: 38px; width: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
.check input { margin-top: 3px; }
.check .hint { display: block; color: var(--muted); font-size: .8rem; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .value { font-size: 1.8rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 10px 14px; font: inherit; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; font-size: .8rem; }

/* ---------- admin shell ---------- */
.admin-header { display: flex; align-items: center; gap: 12px; height: 100%; }
.admin-logo { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.admin-nav { display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; }
.admin-nav a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.admin-nav a:hover { background: #f1f5f9; }
.admin-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.admin-nav .nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 12px 4px; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; }
.admin-rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0; }
.admin-rail a { text-decoration: none; font-size: 1.2rem; padding: 6px; border-radius: 8px; }
.admin-rail a:hover { background: #f1f5f9; }
.admin-content { max-width: 1200px; margin: 0 auto; }

/* ---------- public ---------- */
.public-shell {
    min-height: 100dvh; display: flex; flex-direction: column;
    background: var(--brand-bg); color: var(--brand-text); font-family: var(--brand-font);
}
.public-shell .btn { background: var(--brand-primary); }
.public-shell .btn-secondary { background: #fff; color: var(--brand-text); }
.public-shell .btn-ghost { background: transparent; color: var(--brand-text); }
.public-shell .btn-danger { background: var(--danger); }
.public-shell a { color: var(--brand-primary); }
.public-header { display: flex; align-items: center; gap: 16px; padding: 18px 24px; max-width: 1040px; width: 100%; margin: 0 auto; flex-wrap: wrap; }
.public-header .brand { text-decoration: none; display: flex; align-items: center; }
.public-header .brand img { max-height: 44px; max-width: 220px; }
.public-header .brand-name { font-size: 1.3rem; font-weight: 700; color: var(--brand-primary); }
.public-header .tagline { color: var(--muted); }
.public-main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 8px 24px 40px; }
.public-footer { display: flex; gap: 16px; justify-content: center; padding: 20px; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }

.type-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.type-card {
    display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
    border-top: 4px solid var(--type-color, var(--brand-primary)); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.type-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.1); }
.type-card h3 { margin: 0; font-size: 1.1rem; color: var(--brand-text); }
.type-card .meta { display: flex; gap: 12px; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }
.type-card p { margin: 0; color: #475569; font-size: .92rem; }

.booking-layout { display: grid; grid-template-columns: 300px 1fr; gap: 24px; background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.booking-info { padding: 24px; border-right: 1px solid var(--border); }
.booking-info h1 { font-size: 1.35rem; }
.booking-info .meta { display: flex; flex-direction: column; gap: 8px; color: #475569; margin-top: 16px; font-size: .92rem; }
.booking-main { padding: 24px; min-width: 0; }
@media (max-width: 760px) {
    .booking-layout { grid-template-columns: 1fr; }
    .booking-info { border-right: none; border-bottom: 1px solid var(--border); }
}

/* date + slot picker */
.picker { display: grid; grid-template-columns: minmax(260px, 1fr) 220px; gap: 24px; }
@media (max-width: 640px) { .picker { grid-template-columns: 1fr; } }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-nav strong { font-size: 1rem; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.month-grid .dow { font-size: .72rem; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.month-grid button {
    aspect-ratio: 1; border: none; border-radius: 50%; font: inherit; background: transparent; color: #cbd5e1; cursor: default;
}
.month-grid button.available { background: color-mix(in srgb, var(--brand-primary) 12%, white); color: var(--brand-primary); font-weight: 600; cursor: pointer; }
.month-grid button.available:hover { background: color-mix(in srgb, var(--brand-primary) 22%, white); }
.month-grid button.selected { background: var(--brand-primary); color: #fff; }
.month-grid button.today { outline: 1px solid var(--brand-primary); }
.slots { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.slots .slot {
    border: 1px solid var(--brand-primary); color: var(--brand-primary); background: #fff;
    border-radius: 8px; padding: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.slots .slot:hover { background: color-mix(in srgb, var(--brand-primary) 8%, white); }
.slots .slot.selected { background: var(--brand-primary); color: #fff; }
.tz-row { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--muted); font-size: .85rem; }
.tz-row select { width: auto; max-width: 260px; padding: 4px 8px; font-size: .85rem; }

.confirm-hero { text-align: center; padding: 16px 0 8px; }
.confirm-hero .icon { font-size: 2.6rem; }
.detail-list { display: grid; grid-template-columns: 110px 1fr; gap: 8px 16px; margin: 16px 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; word-break: break-word; }

/* weekly hours editor */
.hours-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.hours-row:last-child { border-bottom: none; }
.hours-windows { display: flex; flex-direction: column; gap: 6px; }
.hours-window { display: flex; gap: 6px; align-items: center; }
.hours-window input[type=time] { width: 130px; }

.setup-shell { max-width: 760px; margin: 40px auto; padding: 0 16px; }
.login-shell { max-width: 400px; margin: 10vh auto; padding: 0 16px; }

.link-box { display: flex; gap: 8px; align-items: center; background: #f8fafc; border: 1px dashed var(--border); padding: 8px 10px; border-radius: 8px; }
.link-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.setup-steps { margin: 0 0 12px; padding-left: 22px; line-height: 1.55; }
.setup-steps li + li { margin-top: 4px; }

.logo-preview { max-height: 60px; max-width: 220px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
.brand-preview { border-radius: var(--radius); padding: 18px; border: 1px solid var(--border); }

/* ---------- embedded (iframe on another site) ---------- */
/* height must follow content, never the viewport, or the auto-resize loops */
body.embedded { background: transparent; }
.embed-shell { min-height: 0; padding: 4px; }
.embed-shell .public-main { padding: 0; }
.embed-shell.embed-transparent { background: transparent; }
.embed-shell .booking-layout { box-shadow: none; }
.booking-layout.no-details { grid-template-columns: 1fr; }
