/* ==========================================================================
   SiteKit — admin panel
   ========================================================================== */

body.admin {
    display: block;
    background-color: var(--surface-container-low);
}

/* ---- Buttons (admin-scoped) ------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    padding: 11px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn svg { width: 18px; height: 18px; }
.btn--primary { background-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background-color: var(--moss-shadow); color: var(--on-primary); }
.btn--secondary { background-color: var(--surface-container-high); color: var(--on-surface); }
.btn--secondary:hover { background-color: var(--surface-container-highest); color: var(--on-surface); }
.btn--outline { background-color: transparent; color: var(--primary-bright); border-color: var(--outline-variant); }
.btn--outline:hover { background-color: var(--surface-container); color: var(--primary-bright); }
.btn--danger { background-color: var(--error); color: #fff; }
.btn--danger:hover { background-color: #98151b; color: #fff; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- Shell ------------------------------------------------------------ */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 264px;
    flex: none;
    background-color: var(--primary);
    color: var(--on-primary);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.admin-sidebar__brand {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--on-primary);
    padding: 24px 24px 8px;
}

.admin-sidebar__sub {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--on-primary-container);
    padding: 0 24px 20px;
}

.admin-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px; flex: 1; overflow-y: auto; }

.admin-nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius);
    color: var(--primary-fixed-dim);
    font-weight: 600;
    font-size: 15px;
}

.admin-nav__link:hover { background-color: rgba(255, 255, 255, 0.08); color: var(--on-primary); }
.admin-nav__link.is-active { background-color: rgba(255, 255, 255, 0.14); color: var(--on-primary); }
.admin-nav__link svg { width: 20px; height: 20px; flex: none; }

.admin-nav__badge {
    margin-left: auto;
    background-color: var(--secondary-fixed-dim);
    color: var(--on-secondary-fixed-variant);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.admin-sidebar__footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 32px;
    background-color: var(--surface-container-lowest);
    border-bottom: 1px solid var(--surface-container-highest);
    position: sticky;
    top: 0;
    z-index: 20;
}

.admin-topbar__title { font-family: var(--font-display); font-size: 24px; color: var(--primary-bright); }
.admin-topbar__spacer { flex: 1; }
.admin-topbar__user { font-size: 14px; color: var(--on-surface-variant); }

.admin-menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: 1px solid var(--outline-variant);
    border-radius: var(--radius); background: transparent; color: var(--primary-bright);
}
.admin-menu-toggle svg { width: 22px; height: 22px; }

.admin-content { padding: 32px; max-width: 1100px; width: 100%; }

/* ---- Cards & layout --------------------------------------------------- */
.admin-card {
    background-color: var(--surface-container-lowest);
    border: 1px solid var(--surface-container-highest);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
}

.admin-card__head { margin-bottom: 18px; }
.admin-card__head h2 { font-size: 22px; }
.admin-card__head p { color: var(--on-surface-variant); font-size: 14px; margin-top: 4px; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }

.stat {
    background-color: var(--surface-container-lowest);
    border: 1px solid var(--surface-container-highest);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-decoration: none;
    display: block;
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.stat:hover { border-color: var(--soft-clay); transform: translateY(-2px); }
.stat__value { font-family: var(--font-display); font-size: 40px; color: var(--primary-bright); line-height: 1; }
.stat__label { color: var(--on-surface-variant); font-weight: 600; margin-top: 8px; }
.stat__hint { color: var(--outline); font-size: 13px; margin-top: 4px; }

.page-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.page-tile {
    display: flex; flex-direction: column; gap: 6px;
    padding: 20px; border-radius: var(--radius-lg);
    background-color: var(--surface-container-lowest);
    border: 1px solid var(--surface-container-highest);
    text-decoration: none; transition: border-color 0.2s ease;
}
.page-tile:hover { border-color: var(--soft-clay); }
.page-tile__name { font-family: var(--font-display); font-size: 20px; color: var(--primary-bright); text-transform: capitalize; }
.page-tile__meta { font-size: 13px; color: var(--on-surface-variant); }

/* ---- Tables ----------------------------------------------------------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
    text-align: left; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--on-surface-variant); padding: 10px 12px; border-bottom: 2px solid var(--surface-container-highest);
}
.admin-table td { padding: 14px 12px; border-bottom: 1px solid var(--surface-container-high); vertical-align: middle; }
.admin-table tr.is-unread td { background-color: var(--row-highlight); }
.admin-table tr:hover td { background-color: var(--surface-container-low); }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-full); }
.badge--unread { background-color: var(--tertiary-fixed); color: var(--tertiary); }
.badge--read { background-color: var(--surface-container-high); color: var(--on-surface-variant); }
.badge--archived { background-color: var(--surface-dim); color: var(--on-surface-variant); }
.badge--new { background-color: var(--tertiary-fixed); color: var(--tertiary); }
.badge--active { background-color: var(--primary-fixed); color: var(--on-primary-fixed); }
.badge--awaiting { background-color: var(--secondary-fixed); color: var(--on-secondary-fixed-variant); }
.badge--hold { background-color: var(--surface-dim); color: var(--on-surface-variant); }
.badge--closed { background-color: var(--surface-container-high); color: var(--outline); }

/* ---- Engagement detail layout ---------------------------------------- */
.engagement-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.engagement-main { min-width: 0; }
.engagement-aside { min-width: 0; }
@media (min-width: 1000px) {
    .engagement-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
}

hr.rule { border: 0; border-top: 1px solid var(--surface-container-high); margin: 18px 0; }
.linklike-danger { background: none; border: 0; color: var(--error); font-size: 12px; cursor: pointer; padding: 0; }
.linklike-danger:hover { text-decoration: underline; }

/* ---- Message thread (shared look in admin + portal) ------------------ */
.thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; max-height: 460px; overflow-y: auto; padding: 4px; }
.msg { display: flex; flex-direction: column; max-width: 80%; }
.msg--admin { align-self: flex-end; align-items: flex-end; }
.msg--customer { align-self: flex-start; align-items: flex-start; }
.msg__bubble { padding: 10px 14px; border-radius: var(--radius-lg); font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg--admin .msg__bubble { background-color: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; }
.msg--customer .msg__bubble { background-color: var(--surface-container-high); color: var(--on-surface); border-bottom-left-radius: 4px; }
.msg__meta { font-size: 11px; color: var(--outline); margin-top: 4px; }
.thread-compose { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.thread-compose .admin-textarea { width: 100%; }

/* ---- Case photo gallery ---------------------------------------------- */
.case-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.case-photo { margin: 0; border: 1px solid var(--surface-container-highest); border-radius: var(--radius); overflow: hidden; background: var(--surface-container-lowest); }
.case-photo img { width: 100%; height: 120px; object-fit: cover; display: block; }
.case-photo figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; font-size: 11px; color: var(--outline); }
.note { padding: 12px 14px; border: 1px solid var(--surface-container-highest); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface-container-lowest); }
.note__body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.note__meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--outline); margin-top: 6px; }

/* ---- Forms ------------------------------------------------------------ */
.admin-field { margin-bottom: 22px; }
.admin-field > label, .admin-field__label {
    display: block; font-weight: 600; font-size: 14px; color: var(--primary-bright); margin-bottom: 6px;
}
.admin-field__help { font-size: 13px; color: var(--outline); margin-top: 6px; }

.admin-input, .admin-textarea, .admin-select {
    width: 100%;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--on-surface);
    background-color: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius);
    padding: 11px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.admin-input:focus, .admin-textarea:focus, .admin-select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring);
}
.admin-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.admin-select {
    appearance: none;
    background-image: var(--select-chevron);
    background-position: right 12px center; background-repeat: no-repeat; background-size: 1.3em;
    padding-right: 36px;
}

.field-group {
    border: 1px solid var(--surface-container-highest);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 20px;
    background-color: var(--surface-container-lowest);
}
.field-group__title {
    font-family: var(--font-display); font-size: 18px; color: var(--primary-bright);
    margin-bottom: 18px; padding-bottom: 10px; border-bottom: 1px solid var(--surface-container-high);
}

/* Settings sub-navigation — pill tabs across the top of each Settings sub-page. */
.settings-subnav {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 22px;
}
.settings-subnav__link {
    padding: 8px 15px; border-radius: var(--radius-full);
    font-weight: 600; font-size: 14px; line-height: 1;
    color: var(--on-surface-variant);
    background: var(--surface-container-low);
    border: 1px solid var(--surface-container-highest);
    text-decoration: none; white-space: nowrap;
    transition: background-color .15s, color .15s, border-color .15s;
}
.settings-subnav__link:hover { background: var(--surface-container-high); color: var(--primary-bright); }
.settings-subnav__link.is-active {
    background: var(--primary); color: var(--on-primary); border-color: var(--primary);
}

.form-actions {
    position: sticky; bottom: 0;
    display: flex; gap: 12px; align-items: center;
    padding: 16px 0; margin-top: 8px;
    background: linear-gradient(to top, var(--surface-container-low) 70%, transparent);
}

.field-validation-error, .validation-summary-errors { color: var(--error); font-size: 13px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.admin-input.input-validation-error, .admin-textarea.input-validation-error { border-color: var(--error); }

/* ---- Rich-text editor ------------------------------------------------- */
.rte { border: 1px solid var(--outline-variant); border-radius: var(--radius); overflow: hidden; background: var(--surface-container-lowest); }
.rte__toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--surface-container-high); background: var(--surface-container-low); }
.rte__btn {
    min-width: 34px; height: 32px; padding: 0 8px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--on-surface-variant); font-weight: 700; font-size: 14px;
}
.rte__btn:hover { background: var(--surface-container-high); color: var(--primary-bright); }
.rte__surface { min-height: 180px; padding: 14px 16px; font-size: 15px; line-height: 1.6; color: var(--on-surface); }
.rte__surface:focus { outline: none; }
.rte__surface h2 { font-size: 22px; margin: 12px 0 8px; }
.rte__surface h3 { font-size: 18px; margin: 12px 0 8px; }
.rte__surface p { margin: 0 0 10px; }
.rte__surface ul, .rte__surface ol { margin: 0 0 10px; padding-left: 22px; }

/* ---- Image field & library ------------------------------------------- */
.image-field { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.image-field__preview {
    width: 200px; height: 140px; border-radius: var(--radius); overflow: hidden;
    background: var(--surface-container); border: 1px solid var(--outline-variant); flex: none;
    display: flex; align-items: center; justify-content: center;
}
.image-field__preview img { width: 100%; height: 100%; object-fit: cover; }
.image-field__controls { flex: 1; min-width: 220px; }

.file-input {
    display: block; width: 100%; font-size: 14px; color: var(--on-surface-variant);
    padding: 10px; border: 1px dashed var(--outline-variant); border-radius: var(--radius);
    background: var(--surface-container-low);
}

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.image-tile { border: 1px solid var(--surface-container-highest); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-container-lowest); }
.image-tile__thumb { height: 150px; background: var(--surface-container); display: flex; align-items: center; justify-content: center; }
.image-tile__thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-tile__body { padding: 12px 14px; }
.image-tile__name { font-size: 13px; font-weight: 600; color: var(--on-surface); word-break: break-all; }
.image-tile__meta { font-size: 12px; color: var(--outline); margin: 4px 0 10px; }
.image-tile__path { font-size: 12px; color: var(--secondary); word-break: break-all; }
.copy-field { display: flex; gap: 6px; margin-top: 8px; }
.copy-field input { flex: 1; font-size: 12px; padding: 6px 8px; border: 1px solid var(--outline-variant); border-radius: var(--radius-sm); }

/* ---- Alerts ----------------------------------------------------------- */
.alert { border-radius: var(--radius); padding: 13px 16px; font-size: 14px; margin-bottom: 20px; border: 1px solid transparent; }
.alert--success { background-color: var(--alert-success-bg); color: var(--alert-success-fg); border-color: var(--alert-success-bd); }
.alert--error { background-color: var(--error-container); color: var(--on-error-container); border-color: var(--alert-error-bd); }
.alert--info { background-color: var(--alert-info-bg); color: var(--alert-info-fg); border-color: var(--alert-info-bd); }

.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 15px; }
.detail-list dt { color: var(--on-surface-variant); font-weight: 600; }
.detail-list dd { margin: 0; color: var(--on-surface); }
.message-body { white-space: pre-wrap; background: var(--surface-container-low); padding: 16px; border-radius: var(--radius); margin-top: 8px; }

/* ---- Auth (login etc.) ------------------------------------------------ */
body.auth {
    display: flex; flex-direction: column; min-height: 100vh;
    background-color: var(--surface);
    background-image: radial-gradient(circle at 1px 1px, rgba(36, 54, 36, 0.06) 1px, transparent 0);
    background-size: 26px 26px;
}
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.auth-card {
    width: 100%; max-width: 440px; position: relative; overflow: hidden;
    background-color: var(--surface-container-lowest);
    border: 1px solid var(--surface-container-highest);
    border-radius: var(--radius-lg);
    padding: 44px 40px;
    box-shadow: var(--shadow-md);
}
.auth-card__accent { position: absolute; top: 0; right: 0; width: 120px; height: 120px; background: var(--primary-fixed); opacity: 0.25; border-bottom-left-radius: 100%; pointer-events: none; }
.auth-card__head { text-align: center; margin-bottom: 32px; position: relative; }
.auth-card__icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: var(--radius-full); background: var(--primary-fixed); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.auth-card__icon svg { width: 26px; height: 26px; }
.auth-card__head h1 { font-size: 28px; margin-bottom: 6px; }
.auth-card__head p { color: var(--on-surface-variant); font-size: 15px; }
.auth-brand { font-family: var(--font-display); font-weight: 700; color: var(--primary-bright); font-size: 22px; text-align: center; padding-top: 32px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 4px; font-size: 14px; }
.auth-footer { text-align: center; padding: 24px; color: var(--outline); font-size: 13px; }
.auth-footer a { color: var(--secondary); }

/* ---- Passkeys --------------------------------------------------------- */
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--outline); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--surface-container-highest); }

.btn--passkey { gap: 10px; }
.btn--passkey svg { width: 18px; height: 18px; }

.passkey-status { font-size: 13px; margin-top: 10px; min-height: 1em; }
.passkey-status.is-error { color: var(--error); }
.passkey-status.is-ok { color: var(--success); }

.passkey-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.passkey-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border: 1px solid var(--surface-container-highest);
    border-radius: var(--radius); background: var(--surface-container-lowest);
}
.passkey-item__icon { width: 38px; height: 38px; flex: none; border-radius: var(--radius-full); background: var(--primary-fixed); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.passkey-item__icon svg { width: 20px; height: 20px; }
.passkey-item__body { flex: 1; min-width: 0; }
.passkey-item__name { font-weight: 600; color: var(--on-surface); }
.passkey-item__meta { font-size: 12px; color: var(--outline); }
.passkey-add { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.passkey-add .admin-field { flex: 1; min-width: 200px; margin-bottom: 0; }

/* ---- Responsive ------------------------------------------------------- */
.admin-menu-toggle { display: none; }
@media (max-width: 860px) {
    .admin-sidebar {
        position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-100%);
        transition: transform 0.25s ease; box-shadow: var(--shadow-lg);
    }
    .admin-sidebar.is-open { transform: translateX(0); }
    .admin-menu-toggle { display: inline-flex; }
    .admin-content { padding: 20px; }
    .admin-topbar { padding: 14px 18px; }
    .admin-backdrop { display: none; position: fixed; inset: 0; background: rgba(28,28,25,0.4); z-index: 55; }
    .admin-backdrop.is-open { display: block; }
}

/* --- Quotes --- */
.price-input { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
.price-input > span { color: var(--on-surface-variant); font-size: 14px; }

.switch-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

tr.is-muted td { opacity: 0.55; }
tr.is-muted td .admin-input { opacity: 1; }

.quote-lines td { vertical-align: middle; }

.quote-add-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 4px; }
@media (min-width: 620px) { .quote-add-grid { grid-template-columns: 2fr 1fr 1fr; } }

.quote-add-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.quote-add-row > button { margin-bottom: 2px; }

.quote-pair { display: flex; gap: 8px; align-items: center; }
.quote-pair > .admin-input { flex: 1 1 auto; min-width: 0; }

.quote-totals { display: flex; flex-direction: column; gap: 8px; }
.quote-totals__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; }
.quote-totals__row > span:first-child { color: var(--on-surface-variant); }
.quote-totals__row > span:last-child { font-variant-numeric: tabular-nums; }
.quote-totals__row--total {
    border-top: 1px solid var(--outline-variant);
    margin-top: 4px; padding-top: 10px;
    font-size: 17px; font-weight: 700; color: var(--primary-bright);
}
.quote-totals__row--total > span:first-child { color: var(--primary-bright); }

/* --- Audit log --- */
.audit-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.audit-table td { vertical-align: top; }
.audit-changes { margin-top: 6px; }
.audit-changes > summary { cursor: pointer; font-size: 12px; color: var(--secondary); }
.audit-json {
    margin: 6px 0 0; padding: 8px 10px; max-width: 520px; overflow-x: auto;
    background: var(--surface-container-low); border: 1px solid var(--outline-variant);
    border-radius: var(--radius-sm, 6px); font-size: 12px; line-height: 1.45;
    white-space: pre-wrap; word-break: break-word;
}
.audit-pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
.audit-pager > a:only-child { margin-left: auto; }

/* --- Appointments & calendar --- */
/* Appointment type colour tokens (accent + tint). */
.appt--consultation { --appt-color: #3a4d39; --appt-bg: #e6efe2; }
.appt--sitevisit    { --appt-color: #80543d; --appt-bg: #f4e4da; }
.appt--presentation { --appt-color: #4f6348; --appt-bg: #e7eee4; }
.appt--call         { --appt-color: #4a5e7a; --appt-bg: #e6ebf3; }
.appt--work         { --appt-color: #7a5d3a; --appt-bg: #f1e7d8; }
.appt--other        { --appt-color: #5a5f55; --appt-bg: #eaece7; }

.appt-dot { width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--appt-color, var(--outline)); flex: 0 0 auto; }

/* Appointment list inside an engagement */
.appt-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.appt-item { border: 1px solid var(--outline-variant); border-radius: var(--radius); background: var(--surface-container-lowest); }
.appt-item > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.appt-item > summary::-webkit-details-marker { display: none; }
.appt-item .appt-when { color: var(--on-surface-variant); font-size: 13px; white-space: nowrap; }
.appt-item .appt-title { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-item.is-past { opacity: 0.7; }
.appt-item.is-cancelled .appt-title { text-decoration: line-through; }
.appt-form { padding: 0 12px 12px; }
.appt-form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.appt-spacer { flex: 1 1 auto; }
.appt-add { margin-top: 4px; }
.appt-add > summary { list-style: none; cursor: pointer; }
.appt-add > summary::-webkit-details-marker { display: none; }

/* Calendar toolbar */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.cal-toolbar__nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-toolbar__title { margin: 0 0 0 6px; font-size: 20px; }
.cal-views { display: inline-flex; border: 1px solid var(--outline-variant); border-radius: var(--radius); overflow: hidden; }
.cal-view { padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); border-left: 1px solid var(--outline-variant); }
.cal-view:first-child { border-left: 0; }
.cal-view.is-active { background: var(--primary); color: var(--on-primary); }
.cal-hint { margin: 10px 0 0; color: var(--on-surface-variant); font-size: 13px; }

/* Shared chip (month cells + all-day strip) */
.cal-chip { display: block; padding: 2px 6px; border-radius: var(--radius-sm); background: var(--appt-bg, var(--surface-container)); border-left: 3px solid var(--appt-color, var(--outline)); font-size: 12px; line-height: 1.3; overflow: hidden; }
.cal-chip__t { display: block; font-weight: 600; color: var(--on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip__w { display: block; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.is-cancelled { opacity: 0.6; }
.cal-chip.is-cancelled .cal-chip__t { text-decoration: line-through; }

/* Month grid */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--outline-variant); border-left: 1px solid var(--outline-variant); }
.cal-weekday { padding: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--on-surface-variant); background: var(--surface-container-low); border-right: 1px solid var(--outline-variant); border-bottom: 1px solid var(--outline-variant); text-align: center; }
.cal-day { min-height: 104px; padding: 4px; border-right: 1px solid var(--outline-variant); border-bottom: 1px solid var(--outline-variant); display: flex; flex-direction: column; gap: 3px; }
.cal-day.is-out { background: var(--surface-container-low); }
.cal-day.is-out .cal-day__num { color: var(--outline); }
.cal-day.is-today { background: var(--row-highlight); }
.cal-day__num { text-align: right; font-size: 13px; font-weight: 600; }
.cal-day.is-today .cal-day__num a { background: var(--primary); color: var(--on-primary); border-radius: var(--radius-full); padding: 1px 7px; }
.cal-day__items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-more { font-size: 11px; color: var(--secondary); font-weight: 600; padding-left: 4px; }

/* Time grid (week / day) */
.cal-tg { overflow-x: auto; }
.cal-tg--week { min-width: 720px; }
.cal-tg__row, .cal-tg__body { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); }
.cal-tg__head .cal-tg__dayhead, .cal-tg__corner { border-bottom: 1px solid var(--outline-variant); }
.cal-tg__corner { padding: 6px; font-size: 11px; color: var(--on-surface-variant); display: flex; align-items: center; justify-content: center; }
.cal-tg__dayhead { padding: 6px; text-align: center; border-left: 1px solid var(--outline-variant); }
.cal-tg__dayhead.is-today { background: var(--row-highlight); }
.cal-tg__dow { display: block; font-size: 11px; text-transform: uppercase; color: var(--on-surface-variant); }
.cal-tg__dnum { display: block; font-size: 18px; font-weight: 700; }
.cal-tg__allday { border-bottom: 1px solid var(--outline-variant); }
.cal-tg__allcell { padding: 3px; border-left: 1px solid var(--outline-variant); display: flex; flex-direction: column; gap: 3px; min-height: 28px; }
.cal-tg__times { display: flex; flex-direction: column; }
.cal-tg__time { height: 3rem; position: relative; }
.cal-tg__time > span { position: absolute; top: -8px; right: 6px; font-size: 11px; color: var(--on-surface-variant); }
.cal-tg__col { position: relative; border-left: 1px solid var(--outline-variant); }
.cal-tg__col.is-today { background: var(--row-highlight); }
.cal-tg__slot { height: 3rem; border-bottom: 1px solid var(--surface-container-high); }
.cal-event { position: absolute; left: 0; box-sizing: border-box; padding: 2px 5px; margin: 0 2px; border-radius: var(--radius-sm); background: var(--appt-bg, var(--surface-container)); border: 1px solid var(--appt-color, var(--outline)); border-left-width: 3px; overflow: hidden; font-size: 11px; line-height: 1.25; min-height: 18px; }
.cal-event__time { font-weight: 700; color: var(--appt-color); margin-right: 4px; }
.cal-event__t { font-weight: 600; color: var(--on-surface); }
.cal-event__w { display: block; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.is-cancelled { opacity: 0.6; }
.cal-event.is-cancelled .cal-event__t { text-decoration: line-through; }

/* Dashboard: upcoming appointments */
.upcoming-list { display: flex; flex-direction: column; }
.upcoming-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--surface-container-high); }
.upcoming-item:last-child { border-bottom: 0; }
.upcoming-item:hover { background: var(--surface-container-low); }
.upcoming-item__dot { width: 12px; height: 12px; border-radius: var(--radius-full); background: var(--appt-color, var(--outline)); flex: 0 0 auto; }
.upcoming-item__when { width: 86px; flex: 0 0 auto; font-size: 12px; color: var(--on-surface-variant); }
.upcoming-item__main { display: flex; flex-direction: column; min-width: 0; }
.upcoming-item__meta { font-size: 13px; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 620px) {
    .appt-form__grid { grid-template-columns: 1fr; }
    .cal-day { min-height: 76px; }
}

/* --- Brand logo (shown in place of the text wordmark when a logo image is set) --- */
.brand-logo { display: inline-block; max-height: 38px; width: auto; vertical-align: middle; }
.admin-sidebar__brand .brand-logo { max-height: 34px; }
.auth-brand .brand-logo { max-height: 48px; }
/* --- Branding page --- */
.brand-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.brand-swatch { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); }
.brand-swatch input[type=color] { width: 100%; height: 44px; border: 1px solid var(--outline-variant); border-radius: var(--radius); background: none; cursor: pointer; padding: 4px; }
.brand-swatch code { font-size: 12px; color: var(--on-surface-variant); }
.brand-current { margin-bottom: 8px; padding: 10px; border: 1px solid var(--outline-variant); border-radius: var(--radius); background: var(--surface-container-low); display: inline-block; }
.brand-current img { max-height: 48px; width: auto; display: block; }
.brand-preview { padding: 24px; border: 1px solid var(--outline-variant); border-radius: var(--radius-lg); }
.brand-preview__row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.brand-pill { display: inline-block; padding: 9px 16px; border-radius: var(--radius-full); font-weight: 600; font-size: 14px; }

/* ==========================================================================
   Dark theme — admin overrides that need genuine dark values (not token swaps).
   ========================================================================== */
html[data-theme="dark"] .theme-toggle { color: var(--on-surface); }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) .theme-toggle { color: var(--on-surface); } }

/* Solid danger button: in dark, --error is a light red, so use a fixed mid-red with white text. */
html[data-theme="dark"] .btn--danger { background-color: #c4332b; color: #fff; }
html[data-theme="dark"] .btn--danger:hover { background-color: #a52821; color: #fff; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .btn--danger { background-color: #c4332b; color: #fff; }
    html:not([data-theme="light"]) .btn--danger:hover { background-color: #a52821; color: #fff; }
}

/* Appointment palette: lighter accents + dark tint backgrounds for dark surfaces. */
html[data-theme="dark"] .appt--consultation { --appt-color: #8fb389; --appt-bg: #1e271b; }
html[data-theme="dark"] .appt--sitevisit    { --appt-color: #cda88f; --appt-bg: #2a201a; }
html[data-theme="dark"] .appt--presentation { --appt-color: #9fb597; --appt-bg: #20271e; }
html[data-theme="dark"] .appt--call         { --appt-color: #9db4d6; --appt-bg: #1c2230; }
html[data-theme="dark"] .appt--work         { --appt-color: #cbab85; --appt-bg: #29231a; }
html[data-theme="dark"] .appt--other        { --appt-color: #b0b3a8; --appt-bg: #232420; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .appt--consultation { --appt-color: #8fb389; --appt-bg: #1e271b; }
    html:not([data-theme="light"]) .appt--sitevisit    { --appt-color: #cda88f; --appt-bg: #2a201a; }
    html:not([data-theme="light"]) .appt--presentation { --appt-color: #9fb597; --appt-bg: #20271e; }
    html:not([data-theme="light"]) .appt--call         { --appt-color: #9db4d6; --appt-bg: #1c2230; }
    html:not([data-theme="light"]) .appt--work         { --appt-color: #cbab85; --appt-bg: #29231a; }
    html:not([data-theme="light"]) .appt--other        { --appt-color: #b0b3a8; --appt-bg: #232420; }
}