/* Office Manager Base Styles */

:root {
    --color-primary: #1565c0;
    --color-primary-hover: #0d47a1;
    --color-primary-soft: #e3f2fd;
    --color-primary-muted: #5c92d6;
    --color-accent: #00838f;
    --color-accent-soft: #e0f7fa;
    --color-surface: #ffffff;
    --color-bg: #eef2f7;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #cbd5e1;
    --topbar-height: 3.25rem;
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
}

body.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    background: linear-gradient(135deg, var(--color-primary) 0%, #0d47a1 100%);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 0.75rem 0 0.5rem;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 200;
}

.sidebar-toggle {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
}

.app-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.app-brand:hover {
    color: #e3f2fd;
}

.app-topbar-spacer {
    flex: 1;
}

.account-menu-anchor {
    flex-shrink: 0;
    position: relative;
}

.account-menu {
    position: relative;
}

.account-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    max-width: 220px;
}

.account-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.25);
}

.account-trigger-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-chevron {
    font-size: 0.65rem;
    opacity: 0.9;
    flex-shrink: 0;
}

.account-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 220px;
    max-width: 320px;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    padding: 0.75rem 0;
    z-index: 300;
    display: none;
}

.account-menu-panel.is-open {
    display: block;
}

.account-panel-section {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.account-panel-section:last-of-type {
    border-bottom: none;
}

.account-panel-name {
    font-weight: 600;
    color: var(--color-primary);
}

.account-panel-meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.35rem;
    word-break: break-word;
}

.account-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.35rem 0;
}

.account-panel-link {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.account-panel-link:hover {
    background: var(--color-primary-soft);
}

.account-logout-link {
    color: #c62828;
}

.account-logout-link:hover {
    background: #ffebee;
}

.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.site-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    transition: width 0.22s ease, min-width 0.22s ease, opacity 0.2s ease;
    overflow: hidden;
}

.site-sidebar-inner {
    padding: 1rem 0;
    width: var(--sidebar-width);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav a,
.sidebar-nav .sidebar-tab-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.65rem 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav .sidebar-tab-btn:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.sidebar-nav a.active,
.sidebar-nav .sidebar-tab-btn.active {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border-left-color: var(--color-primary);
    font-weight: 600;
}

.sidebar-back-link {
    display: block;
    padding: 0.5rem 1.25rem 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.5rem;
}

.sidebar-back-link:hover {
    color: var(--color-primary);
}

body.sidebar-collapsed .site-sidebar {
    width: 0;
    min-width: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}

body.sidebar-collapsed .site-sidebar-inner {
    opacity: 0;
}

.app-content-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding: 1.5rem 0 2rem;
}

.app-main--auth {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
}

.app-footer {
    background: linear-gradient(135deg, #0d47a1 0%, var(--color-primary) 100%);
    color: #e3f2fd;
    text-align: center;
    padding: 1.25rem 1rem;
    margin-top: auto;
}

.app-footer a {
    color: #fff;
}

header:not(.app-topbar) {
    background-color: var(--color-primary);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-container h1 {
    font-size: 1.5rem;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.nav-menu a:hover {
    opacity: 0.8;
}

main:not(.app-main) {
    min-height: calc(100vh - 200px);
    padding: 2rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.card h3 {
    margin-bottom: 1rem;
    color: var(--color-primary);
}

.card p {
    margin-bottom: 1.5rem;
    color: #666;
}

button {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--color-primary-hover);
}

footer:not(.app-footer) {
    background-color: var(--color-primary);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

/* Form styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Table styles */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: var(--color-primary);
    color: white;
    font-weight: 600;
}

tr:hover {
    background-color: #f9f9f9;
}

/* Utility classes */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

.error {
    color: #e74c3c;
    background-color: #fdf2f2;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.success {
    color: #27ae60;
    background-color: #f2fdf5;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.availability-counter {
    background-color: var(--color-primary-soft);
    color: var(--color-primary);
    padding: 1rem 1.5rem;
    border-radius: 6px;
    margin: 1rem 0;
    border-left: 4px solid var(--color-primary);
    font-size: 1.1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.availability-counter strong {
    color: var(--color-primary-hover);
    font-size: 1.2rem;
}

/* Booking form styles */
.booking-form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

/*
 * Phase 30 / spec section 25: shared row layout for an input + adjacent
 * action button so every form row across the app sits on the same Y axis.
 *
 * The drift this fixes: `.form-group` has `margin-bottom: 1.5rem` and a
 * label that stacks above the input, while a sibling button has no label
 * above it. With `align-items: flex-end` the form-group's bottom margin
 * still pushes the input bottom 1.5rem above the button bottom — so the
 * input and the button are visibly out of alignment even though the
 * container says they're "end-aligned".
 *
 * `.form-row` is additive: existing rows keep their original class
 * (`.booking-form`, `.search-filter-group`, `.filters-panel`, etc.) so
 * page-specific styling is preserved, and gain the `.form-row` class to
 * pin the row layout primitives. The child rule zeros the form-group's
 * bottom margin inside the row and pins a `min-height` on direct
 * input / select / button children so the row baseline is stable.
 */
.form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.form-row .form-group {
    margin-bottom: 0;
}

/*
 * Buttons and bare inputs / selects that sit directly inside a `.form-row`
 * (i.e. without their own `.form-group` wrapper, which usually contributes
 * a label) need an explicit min-height so they line up with the inputs
 * that DO have a label-stacked-above wrapper.
 */
.form-row > button,
.form-row > input,
.form-row > select {
    min-height: 2.75rem;
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
    height: fit-content;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Desk cards */
.desks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.desk-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.desk-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.desk-card h4 {
    margin-bottom: 0.5rem;
    color: var(--color-primary);
}

.desk-card p {
    margin-bottom: 1rem;
    color: #666;
    font-size: 0.9rem;
}

/*
 * Phase 28: shared per-card action button class for Select / Book on desk
 * cards and Select / Reserve on parking cards. Pins min-width, min-height,
 * padding, font, and box-sizing so the four buttons render at identical
 * dimensions regardless of label length. Replaces an older
 * `.desk-card .book-desk-btn { width: 100%; margin-top: 1rem; }` rule
 * that gave Book a top margin Select did not have, leaving Book visibly
 * shorter than Select inside the flex row.
 */
.btn-card-action {
    flex: 1;
    min-width: 7rem;
    min-height: 2.5rem;
    margin: 0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.2;
    border-radius: 6px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/*
 * Phase 28: visual style for the Select toggle's active state. Mirrors the
 * primary action colour so a "Selected" button reads as engaged. The
 * `aria-pressed="true"` attribute is also exposed for assistive tech.
 */
.btn-card-action.is-selected,
.btn-card-action[aria-pressed="true"] {
    background-color: var(--color-primary);
    color: white;
    border: 1px solid var(--color-primary);
}

.desk-card.selected {
    border: 2px solid var(--color-primary);
    background-color: var(--color-primary-soft);
}

.desk-card .selection-indicator {
    background-color: var(--color-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.desk-card-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    align-items: stretch;
}

/*
 * Phase 23.12 / spec section 19: uniform button sizing across Select, Book
 * (desk), Select, Reserve (parking), plus the aggregate Book Selected /
 * Reserve Selected controls below.
 */
.desk-card-buttons .select-desk-btn,
.desk-card-buttons .book-desk-btn,
.desk-card-buttons .select-space-btn,
.desk-card-buttons .book-space-btn {
    flex: 1;
    height: auto;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/*
 * Phase 23.12 / spec section 19: when a card is in the multi-select
 * selection, the immediate Book/Reserve control for that item must not
 * appear (Book Selected / Reserve Selected takes its place). The JS
 * toggles `hidden` on the button; this rule ensures the flex display
 * above does not override the default [hidden] display:none behaviour.
 */
.desk-card-buttons .book-desk-btn[hidden],
.desk-card-buttons .book-space-btn[hidden] {
    display: none;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
    height: fit-content;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.selection-controls {
    background-color: #f8f9fa;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.selection-controls #book-selected-btn,
.selection-controls #reserve-selected-btn {
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selection-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.selection-info #selection-count {
    font-weight: 600;
    color: var(--color-primary);
    font-size: 1.1rem;
}

#book-selected-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

#book-selected-btn:disabled:hover {
    background-color: #bdc3c7;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-active {
    background-color: #d4edda;
    color: #155724;
}

.status-cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-approved {
    background-color: #d4edda;
    color: #155724;
}

.status-rejected {
    background-color: #f8d7da;
    color: #721c24;
}

.text-muted {
    color: #999;
}

.last-admin-user {
    background-color: #fff3cd;
}

.last-admin-user td {
    font-weight: 500;
    font-style: italic;
}

/* Admin tabs (horizontal fallback; primary UI uses .sidebar-tab-btn in left nav) */
#admin-tabs {
    display: none;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--color-primary);
    background-color: var(--color-primary-soft);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

.sidebar-nav .sidebar-tab-btn.active {
    border-bottom: none;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.help-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
    font-style: italic;
}

/* Dashboard styles */
.dashboard-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.summary-card h3 {
    font-size: 1rem;
    color: #666;
    margin-bottom: 1rem;
    font-weight: 500;
}

.summary-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-accent);
    margin: 0.5rem 0;
}

.summary-label {
    font-size: 0.85rem;
    color: #999;
    margin: 0;
}

.upcoming-items {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 2rem;
}

.upcoming-items h3 {
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}

.upcoming-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.upcoming-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.upcoming-item:last-child {
    border-bottom: none;
}

.upcoming-item:hover {
    background-color: #f9f9f9;
}

.upcoming-date {
    min-width: 100px;
    font-weight: 600;
    color: var(--color-primary);
    margin-right: 1.5rem;
}

.upcoming-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.upcoming-details strong {
    color: var(--color-primary);
}

.upcoming-location {
    font-size: 0.9rem;
    color: #666;
}

.upcoming-period {
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
}

/* Search and filter styles */
.bookings-controls {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.search-filter-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.filter-select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Notification styles */
.notification-container {
    position: fixed;
    top: calc(var(--topbar-height) + 12px);
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.notification {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.notification.success {
    border-left: 4px solid #27ae60;
}

.notification.error {
    border-left: 4px solid #e74c3c;
}

.notification.info {
    border-left: 4px solid var(--color-primary);
}

.notification.warning {
    border-left: 4px solid #f39c12;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    margin-left: auto;
}

.notification-close:hover {
    color: #333;
}

/* ------------------------------------------------------------------ */
/* Phase 23e: Floor plan map renderer                                  */
/* ------------------------------------------------------------------ */

.map-panel {
    margin: 1rem 0 1.25rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.map-panel h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--color-primary);
}

.map-empty {
    background: #f6f8fa;
    border: 1px dashed #ccc;
    border-radius: 4px;
    padding: 1rem;
    text-align: center;
    color: #555;
    font-size: 0.9rem;
}

.map-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 720px;
    margin: 0 auto;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    user-select: none;
}

.map-floor-plan {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    z-index: 1;
}

.map-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
}

/* Landmarks: orientation only, MUST NOT block clicks on resource markers. */
.map-landmark {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #555;
    font-size: 0.7rem;
    line-height: 1;
}

.map-landmark-icon {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid #aaa;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #444;
}

.map-landmark-label {
    margin-top: 0.15rem;
    background: rgba(255, 255, 255, 0.85);
    padding: 0 0.25rem;
    border-radius: 2px;
    white-space: nowrap;
}

/* Resource markers (desks / parking spaces): clickable, dispatch a
 * CustomEvent that page scripts subscribe to. Higher z-index than
 * landmarks so they sit on top in case of overlap. */
.map-resource-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 4;
    background: var(--color-primary);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    padding: 0;
}

.map-resource-marker:hover,
.map-resource-marker:focus {
    background: var(--color-primary-hover);
    outline: none;
}

.map-resource-marker--selected {
    background: #2e7d32;
}

.map-resource-marker-label {
    pointer-events: none;
}

/* Admin map editor */
.map-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.5rem 0 0.75rem;
    padding: 0.5rem;
    background: #f6f8fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.map-editor-toolbar label {
    font-weight: 500;
    margin-right: 0.25rem;
}

.map-editor-toolbar select,
.map-editor-toolbar input[type="text"] {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.9rem;
}

.map-editor-status {
    margin-top: 0.5rem;
    color: #555;
    font-size: 0.85rem;
}

.map-editor .map-viewport {
    cursor: crosshair;
}

.map-editor .map-resource-marker--editor {
    background: #1565c0;
}

.map-editor .map-resource-marker--unplaced {
    background: #999;
}

/* Phase 29: inline loading indicator for buttons such as Save Configuration.
   The spinner sits beside the button label; the success flash briefly
   replaces it on a successful response before the button returns to idle. */
.btn-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-left: 0.5rem;
    vertical-align: -0.15em;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: btn-spinner-rotate 0.8s linear infinite;
    flex-shrink: 0;
}

.btn-success-flash {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-left: 0.5rem;
    vertical-align: -0.15em;
    color: #ffffff;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

@keyframes btn-spinner-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

button[aria-busy="true"] {
    cursor: progress;
    opacity: 0.85;
}

button[aria-busy="true"]:disabled,
button:disabled {
    cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
    .btn-spinner {
        animation: none;
        border-top-color: rgba(255, 255, 255, 0.45);
    }
}

/*
 * Phase 31 / spec section 26: Booking Matrix initial-state polish.
 *
 * Filter card frames the .form-row of date inputs and selects with a
 * subtle border and the blue accent from section 14 so the toolbar
 * reads as a deliberate panel rather than a stray row above an empty
 * region.
 */
.matrix-filter-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

/*
 * #matrix-region hosts one of four mutually exclusive child states:
 * .matrix-empty-state, .matrix-loading-state, .matrix-error-state, or
 * the rendered matrix grid (the legacy #matrix-container). matrix.js
 * sets [data-state="empty|loading|loaded|error"] for testability and
 * for any future state-specific styling.
 */
.matrix-region {
    min-height: 12rem;
}

.matrix-empty-state,
.matrix-loading-state,
.matrix-error-state {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.matrix-state-icon {
    color: var(--color-primary);
    margin-bottom: 0.25rem;
    line-height: 0;
}

.matrix-state-title {
    margin: 0;
    color: var(--color-text);
    font-size: 1.1rem;
    font-weight: 600;
}

.matrix-state-description {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    max-width: 36rem;
}

/*
 * Loading state: a larger spinner than the inline button spinner. It
 * reuses the existing btn-spinner-rotate keyframe and respects
 * prefers-reduced-motion via the rule below.
 */
.matrix-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: btn-spinner-rotate 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .matrix-spinner {
        animation: none;
        border-top-color: var(--color-border);
    }
}

/*
 * Error state: red accent on the icon to signal failure, recoverable
 * with the Retry button which re-fires the same Load Matrix request
 * with the current filters.
 */
.matrix-error-state .matrix-state-icon {
    color: #c0392b;
}

.matrix-error-message {
    margin: 0;
    color: var(--color-text);
    font-size: 0.95rem;
    max-width: 40rem;
}

.matrix-retry-btn {
    margin-top: 0.5rem;
}

/*
 * Narrow viewports: keep the filter card and state placeholders from
 * causing horizontal scroll. The .form-row already wraps; here we
 * just trim the card padding so the controls have room to wrap.
 */
@media (max-width: 600px) {
    .matrix-filter-card {
        padding: 1rem;
    }
    .matrix-empty-state,
    .matrix-loading-state,
    .matrix-error-state {
        padding: 1.75rem 1rem;
    }
}

.map-editor-resource-list {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.map-editor-resource-list button {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
}

.map-editor-resource-list button.is-active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.map-editor-resource-list button.is-placed {
    background: #e8f5e9;
    border-color: #66bb6a;
    color: #1b5e20;
}

/* Phase 27c: Key Fob subsystem visual elements. */

/* Small "Fob" badge on My Bookings rows that requested a fob. */
.status-badge.fob-badge {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffb74d;
    margin-left: 0.4rem;
}

/* Inline availability hint shown below "Check Availability" on the desk
   booking page when an inventory limit is configured. */
.fob-availability-hint {
    padding: 0.6rem 0.8rem;
    margin-top: 0.5rem;
}

.fob-availability-hint ul {
    list-style: disc inside;
    margin: 0.3rem 0 0;
    padding: 0;
}

.fob-availability-exhausted,
.fob-day-exhausted {
    color: #b71c1c;
    font-weight: 600;
}

/* Calendar / History tables share a compact look with the rest of the
   admin tables; the only thing we add is a soft red row tint when the
   day's available count is zero. */
.fob-calendar-table .fob-calendar-row.fob-day-exhausted td {
    background: #fff5f5;
}


