:root {
    --bg:      oklch(98% 0.005 250);
    --surface: oklch(100% 0 0);
    --fg:      oklch(22% 0.02 240);
    --muted:   oklch(50% 0.018 240);
    --border:  oklch(90% 0.008 240);
    --accent:  oklch(58% 0.16 145);

    --font-display: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
    --font-body:    -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
    --font-mono:    "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;

    --brand-blue: oklch(58% 0.18 255);
    --brand-blue-dark: oklch(42% 0.17 255);
    --nav: oklch(19% 0.025 248);
    --subtle: oklch(96% 0.006 250);
    --line: color-mix(in oklch, var(--border), var(--fg) 8%);
    --success: oklch(55% 0.15 145);
    --warning: oklch(68% 0.15 75);
    --danger: oklch(58% 0.19 25);
    --info-bg: oklch(96% 0.028 255);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--fg);
    background:
        linear-gradient(180deg, oklch(99% 0.003 250), var(--bg) 280px),
        var(--bg);
    line-height: 1.5;
}

a { color: var(--brand-blue-dark); text-decoration: none; }
a:hover { color: var(--brand-blue); text-decoration: underline; text-underline-offset: 3px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0.75rem clamp(1rem, 3vw, 2rem);
    background: color-mix(in oklch, var(--surface), transparent 3%);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--fg);
    font-family: var(--font-display);
    font-weight: 760;
    letter-spacing: -0.01em;
    text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--fg); }
.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    color: #fff;
    background: linear-gradient(135deg, var(--nav), var(--brand-blue));
    font-weight: 800;
    box-shadow: inset 0 0 0 1px color-mix(in oklch, #fff, transparent 75%);
}
.brand-word { font-size: 1.08rem; }
.brand-word .brand-em { color: var(--brand-blue); }
.topbar nav { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a, .topbar .user {
    border-radius: 8px;
    color: var(--fg);
    font-size: 0.9rem;
    padding: 0.45rem 0.65rem;
}
.topbar nav a:hover { background: var(--subtle); text-decoration: none; color: var(--brand-blue-dark); }
.topbar .user { color: var(--muted); font-family: var(--font-mono); }

.container {
    width: min(1180px, calc(100vw - 2rem));
    margin: 1.5rem auto 2.5rem;
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.015em; line-height: 1.15; }
h1 { font-size: clamp(1.7rem, 3vw, 2.4rem); margin: 0 0 1rem; }
h2 { font-size: 1.08rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.4rem; }
p { margin-top: 0; }
.muted { color: var(--muted); }
.num, .slot-time, .daynav strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.1rem;
    margin-bottom: 1rem;
}

.hero {
    display: grid;
    gap: 0.8rem;
    padding: clamp(2rem, 6vw, 4rem) 0;
}
.hero h1 { max-width: 780px; font-size: clamp(2.2rem, 6vw, 4.8rem); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0.48rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--fg);
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    white-space: nowrap;
}
.btn:hover { border-color: var(--brand-blue); color: var(--brand-blue-dark); text-decoration: none; }
.btn-primary { background: var(--brand-blue); color: #fff; border-color: var(--brand-blue); }
.btn-primary:hover { background: var(--brand-blue-dark); color: #fff; }
.btn-link { background: none; border: 0; color: var(--brand-blue-dark); cursor: pointer; padding: 0; font: inherit; font-size: 0.92rem; }
.btn-link.danger { color: var(--danger); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.danger-zone { border-color: color-mix(in oklch, var(--danger), white 70%); }
.danger-zone h3 { color: var(--danger); margin-top: 0; }

.actions { display: flex; gap: 0.55rem; flex-wrap: wrap; margin: 1rem 0; }
.inline { display: inline; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.section-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.span-2 { grid-column: span 2; }

label { display: block; margin-bottom: 0.75rem; color: var(--fg); font-size: 0.92rem; font-weight: 600; }
label.checkbox { display: inline-flex; gap: 0.4rem; align-items: center; margin-right: 1rem; font-weight: 500; }
input[type=text], input[type=number], input[type=time], input[type=date], textarea, select {
    width: 100%;
    max-width: 380px;
    min-height: 38px;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--fg);
    font: inherit;
    margin-top: 0.25rem;
}
input:focus, textarea:focus, select:focus {
    outline: 3px solid color-mix(in oklch, var(--brand-blue), transparent 82%);
    border-color: var(--brand-blue);
}
input[type=checkbox] { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 0.7rem 0; border-bottom: 1px solid var(--line); display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; }
.list li:last-child { border-bottom: none; }
.tree { list-style: none; padding: 0; }
.tree li { padding: 0.35rem 0; }

.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid th, .grid td { text-align: left; padding: 0.65rem; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: middle; }
.grid th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.grid code { font-size: 0.8rem; color: var(--muted); font-family: var(--font-mono); }

.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-success { background: color-mix(in oklch, var(--success), white 88%); color: oklch(34% 0.11 145); border-color: color-mix(in oklch, var(--success), white 70%); }
.flash-error { background: color-mix(in oklch, var(--danger), white 88%); color: oklch(38% 0.14 25); border-color: color-mix(in oklch, var(--danger), white 70%); }
.flash-info { background: var(--info-bg); color: var(--brand-blue-dark); border-color: color-mix(in oklch, var(--brand-blue), white 70%); }
.flash-warning { background: color-mix(in oklch, var(--warning), white 86%); color: oklch(39% 0.11 75); border-color: color-mix(in oklch, var(--warning), white 65%); }

.badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 0.42rem; font-size: 0.72rem; font-family: var(--font-mono); }
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    background: color-mix(in oklch, var(--brand-blue), white 86%);
    color: var(--brand-blue-dark);
    border: 1px solid color-mix(in oklch, var(--brand-blue), white 70%);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.eyebrow { color: var(--muted); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.metric strong { display: block; margin-top: 0.35rem; font-family: var(--font-mono); font-size: 1.55rem; line-height: 1; }

.daynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.calendar-shell { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.calendar-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
}
.date-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(130px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.date-panel .btn { align-self: end; }
.calendar-lane {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.lane-head {
    display: grid;
    grid-template-columns: 96px 1fr;
    border-bottom: 1px solid var(--line);
    background: color-mix(in oklch, var(--brand-blue), white 93%);
}
.lane-head > div { padding: 0.65rem 0.75rem; font-weight: 800; color: var(--brand-blue-dark); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; }
.slots {
    list-style: none;
    padding: 0;
    margin: 0;
}
.slot {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    min-height: 68px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.slot:last-child { border-bottom: 0; }
.slot-time {
    padding: 0.65rem 0.75rem;
    color: var(--muted);
    border-right: 1px solid var(--line);
    font-weight: 700;
    font-size: 0.78rem;
    background: color-mix(in oklch, var(--subtle), white 45%);
}
.slot-body {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.55rem 0.65rem;
    align-items: flex-start;
}
.slot-body::before {
    content: "";
    position: absolute;
    inset: 0.55rem auto 0.55rem 0.65rem;
    width: 3px;
    border-radius: 4px;
    background: var(--muted);
}
.slot-body > * { position: relative; }
.slot-available .slot-body { background: var(--surface); }
.slot-available .slot-body::before { background: var(--accent); }
.slot-taken .slot-body { background: color-mix(in oklch, var(--brand-blue), white 91%); }
.slot-taken .slot-body::before { background: var(--brand-blue); }
.slot-break .slot-time,
.slot-break .slot-body { background: color-mix(in oklch, var(--warning), white 88%); }
.slot-break .slot-body::before { background: var(--warning); }
.slot-past { opacity: 0.58; }
.slot-title { padding-left: 0.85rem; }
.slot-title strong { display: block; }
.slot-book { display: grid; justify-items: end; gap: 0.45rem; min-width: min(360px, 55%); }
.slot-book-row { display: flex; gap: 0.45rem; align-items: center; justify-content: flex-end; width: 100%; }
.slot-book-row select { max-width: 185px; margin-top: 0; }
.slot-extras { width: 100%; font-size: 0.84rem; }
.slot-extras summary { cursor: pointer; color: var(--brand-blue-dark); text-align: right; }
.slot-extras .extras-list { display: grid; gap: 0.2rem; margin: 0.45rem 0; }
.slot-extras label.checkbox { display: flex; margin: 0.15rem 0; }
.slot-extras textarea { max-width: none; width: 100%; box-sizing: border-box; margin-top: 0.3rem; }

.calendar-side { display: grid; gap: 1rem; }
.availability-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.availability-list { display: grid; gap: 0.65rem; margin-top: 0.8rem; }
.availability-item { display: grid; grid-template-columns: 12px 1fr; gap: 0.55rem; align-items: start; }
.availability-dot { width: 10px; height: 10px; margin-top: 0.35rem; border-radius: 50%; background: var(--accent); }
.availability-dot.busy { background: var(--brand-blue); }
.availability-dot.break { background: var(--warning); }
.availability-dot.closed { background: var(--muted); }
.repeat-options { display: grid; gap: 0.45rem; margin-top: 0.75rem; }

.unread { font-weight: 700; }
.read { opacity: 0.7; }

/* ── Notification list ── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    height: 1.4em;
    padding: 0 0.35em;
    border-radius: 99px;
    font-size: 0.7em;
    font-weight: 700;
    background: var(--brand-blue);
    color: #fff;
    vertical-align: middle;
    line-height: 1;
}
.notif-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.notif-item { border-radius: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.notif-unread { border-left: 3px solid var(--brand-blue); }
.notif-link {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    text-decoration: none;
    color: inherit;
}
.notif-link:hover { background: var(--subtle); }
.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    flex-shrink: 0;
    margin-top: 0.45rem;
}
.notif-unread .notif-dot { background: var(--brand-blue); }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 0.95rem; }
.notif-unread .notif-title { font-weight: 700; }
.notif-preview { color: var(--muted); font-size: 0.88rem; margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.35rem; }
.notif-new {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--brand-blue-dark);
    background: color-mix(in oklch, var(--brand-blue), white 82%);
    padding: 0.15em 0.55em;
    border-radius: 99px;
    white-space: nowrap;
    align-self: center;
    flex-shrink: 0;
}
/* ── Notification detail ── */
.notif-detail { padding: 1.5rem; }
.notif-body { font-size: 1rem; line-height: 1.7; margin: 0; white-space: pre-wrap; }
.notif-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.footer { text-align: center; color: var(--muted); padding: 2rem 1rem; border-top: 1px solid var(--line); }

/* ── Resource tabs ── */
.resource-tabs {
    display: flex;
    gap: 0.25rem;
    align-items: stretch;
    background: var(--subtle);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.35rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.resource-tabs::-webkit-scrollbar { display: none; }
.res-tab {
    display: inline-flex;
    align-items: center;
    height: 2.4rem;
    padding: 0 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1;
    color: var(--muted);
    text-decoration: none;
    border-radius: 7px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.res-tab:hover { color: var(--fg); background: color-mix(in oklch, var(--surface), transparent 25%); text-decoration: none; }
.res-tab-active {
    color: var(--brand-blue-dark);
    background: var(--surface);
    font-weight: 700;
    box-shadow: 0 1px 2px oklch(0% 0 0 / 0.08);
}
.res-tab-active:hover { background: var(--surface); }
.resource-subnav {
    display: flex;
    gap: 0.25rem;
    margin: -0.75rem 0 1.25rem;
}
.subnav-link {
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
}
.subnav-link:hover { background: var(--subtle); color: var(--fg); text-decoration: none; }
.subnav-link-active { background: var(--subtle); color: var(--fg); font-weight: 700; }

/* ── Mini calendar (schedule/days + calendar sidebar) ── */
.minical-wrap { }
.minical-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}
.minical-months { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.minical-month-name { font-weight: 700; font-size: 0.88rem; margin-bottom: 0.4rem; color: var(--fg); }
.minical-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.minical-dow { text-align: center; font-size: 0.68rem; color: var(--muted); font-weight: 700; padding: 0.2rem 0; letter-spacing: 0.03em; }
.minical-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--fg);
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
}
.minical-day:hover { background: var(--subtle); text-decoration: none; }
.minical-today { box-shadow: inset 0 0 0 2px var(--brand-blue); font-weight: 800; }
.minical-override { font-weight: 800; color: var(--fg); }
.minical-selected { box-shadow: inset 0 0 0 2px var(--brand-blue-dark); }
.minical-past { opacity: 0.5; pointer-events: none; }
.minical-dot { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--brand-blue-dark); margin-top: 2px; }

/* Availability colouring (resource calendar) */
.minical-av-open   { background: oklch(92% 0.09 145); color: oklch(35% 0.12 145); font-weight: 700; }
.minical-av-open:hover   { background: oklch(88% 0.11 145); }
.minical-av-low    { background: oklch(93% 0.11 95);  color: oklch(40% 0.12 75);  font-weight: 700; }
.minical-av-low:hover    { background: oklch(89% 0.13 95); }
.minical-av-full   { background: oklch(90% 0.08 25);  color: oklch(42% 0.18 25);  font-weight: 700; }
.minical-av-full:hover   { background: oklch(86% 0.10 25); }
.minical-av-closed { background: transparent; color: var(--muted); font-weight: 400; }

/* Availability legend */
.minical-legend { list-style: none; margin: 0.85rem 0 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); }
.minical-legend li { display: flex; align-items: center; gap: 0.5rem; }
.minical-legend-swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }
.minical-legend-swatch.sw-open   { background: oklch(92% 0.09 145); }
.minical-legend-swatch.sw-low    { background: oklch(93% 0.11 95); }
.minical-legend-swatch.sw-full   { background: oklch(90% 0.08 25); }
.minical-legend-swatch.sw-closed { background: var(--subtle); border: 1px solid var(--line); }
.minical-legend-swatch.sw-override { background: var(--surface); border: 1px solid var(--line); position: relative; }
.minical-legend-swatch.sw-override::after { content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--brand-blue-dark); }

@media (max-width: 900px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .container { width: min(100% - 1rem, 760px); }
    .section-grid, .metric-grid, .calendar-shell { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .calendar-toolbar, .date-panel { grid-template-columns: 1fr; }
    .slot, .lane-head { grid-template-columns: 72px minmax(0, 1fr); }
    .slot-book { min-width: 0; width: 100%; justify-items: stretch; }
    .slot-body { flex-direction: column; }
    .slot-book-row { justify-content: stretch; flex-wrap: wrap; }
    .slot-book-row .btn { flex: 1; }
    .page-head { flex-direction: column; }
    .minical-months { grid-template-columns: 1fr; }
}

/* Media gallery (resource & extra pictures) */
.media-gallery { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.75rem 0; }
.media-thumb { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.media-thumb img {
    width: 140px; height: 105px; object-fit: cover;
    border: 1px solid var(--line, #e5e7eb); border-radius: 8px; background: #fff;
}

/* Phase 7 shop grid */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 0.75rem; }
.shop-card { border: 1px solid var(--line, #e5e7eb); border-radius: 10px; overflow: hidden; background: var(--surface, #fff); display: flex; flex-direction: column; }
.shop-thumb { display: block; height: 130px; background: var(--subtle, #f1f5f9); }
.shop-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-thumb-empty { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 2.5rem; font-weight: 700; color: var(--muted, #94a3b8); }
.shop-body { padding: 0.85rem; display: flex; flex-direction: column; gap: 0.4rem; }
.shop-body h3 { margin: 0; font-size: 1.05rem; }
.shop-next { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.2rem 0; }
.shop-body .btn { margin-top: auto; }
