:root {
    --brand: #8b1528;
    --brand-dark: #6b0f1e;
    --brand-soft: #fbf0f2;
    --ink: #282d34;
    --muted: #5b6470;
    --line: #e0e4e9;
    --page: #f5f6f8;
    --pending: #855400;
    --approved: #176b39;
    --rejected: #ad2430;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--page); display: flex; flex-direction: column; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: var(--brand); font-weight: 600; text-decoration: none; text-underline-offset: 4px; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
::selection { background: #eed0d6; color: #46101b; }

/* Shared KPTM navigation. */
.site-nav { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; min-height: 72px; padding: 12px max(28px, calc((100vw - 1280px) / 2)); color: white; background: var(--brand); }
.site-nav > span { order: 1; flex: 1; font-size: 15px; font-weight: 700; letter-spacing: .06em; }
.site-nav nav { order: 2; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.site-logo { order: 0; flex-shrink: 0; width: 112px; height: 56px; padding: 6px; object-fit: contain; background: white; border-radius: 6px; }
.site-nav a, button.logout-link { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 13px; border-radius: 6px; color: white; font-size: 13px; font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current="page"], button.logout-link:hover { background: #ffffff1f; text-decoration: none; }
.site-nav a[aria-current="page"] { font-weight: 700; }
.site-nav a:focus-visible, .site-nav button:focus-visible { outline-color: white; }
.logout-form { display: inline-flex; }
button.logout-link { width: auto; margin: 0; border: 0; background: transparent; letter-spacing: normal; text-transform: none; }

/* Shared forms and page surfaces. */
.main-content { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 48px 28px; }
.container { width: 100%; max-width: 460px; padding: 32px 36px; background: white; border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: 12px; }
.auth-container { max-width: 460px; }
.form-container { max-width: 560px; }
.wide-container { max-width: 1280px; }
.history-container { max-width: 1080px; }
.brand-header { margin-bottom: 28px; text-align: left; }
.brand-header h2 { color: var(--brand); font-size: 25px; line-height: 1.25; font-weight: 650; letter-spacing: -.025em; overflow-wrap: anywhere; }
.brand-header p { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.brand-header .home-greeting { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; }
.page-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; margin-bottom: 28px; }
.page-heading .brand-header { margin: 0; }
.page-heading .btn-primary { width: auto; margin: 0; flex-shrink: 0; }
form { display: flex; flex-direction: column; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label { color: #343a43; font-size: 13px; font-weight: 600; }
input:not([type="hidden"]), select, textarea { width: 100%; min-width: 0; min-height: 46px; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid #c9cfd7; border-radius: 6px; font-size: 16px; outline: none; caret-color: var(--brand); transition: border-color .15s ease; }
input::placeholder, textarea::placeholder { color: #69717d; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid #8b15282b; outline-offset: 1px; }
textarea { resize: vertical; line-height: 1.6; }
button, .btn-primary { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; margin-top: 4px; padding: 11px 18px; background: var(--brand); color: white; border: 1px solid var(--brand); border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color .15s ease; }
button:hover, .btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
button:active, .btn-primary:active { background: #510b17; }
button:disabled { opacity: .6; cursor: not-allowed; }
.alert { margin-bottom: 20px; padding: 12px 16px; border-radius: 6px; font-size: 13px; line-height: 1.6; }
.alert-danger { color: #842029; background: #fce9eb; border: 1px solid #f0ccd0; }
.alert-success { color: #0f5132; background: #e9f5ed; border: 1px solid #c7e4d2; }
.help-text { margin: 16px 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.page-links { margin-top: 24px; text-align: center; font-size: 13px; }

/* Password buttons share the input's height without changing its value. */
.password-field { position: relative; }
.password-field input { padding-right: 56px; }
button.password-toggle { position: absolute; inset: 1px 1px 1px auto; width: 44px; height: calc(100% - 2px); min-height: 44px; margin: 0; padding: 10px; background: transparent; border: 0; color: var(--brand); }
button.password-toggle:hover { background: var(--brand-soft); }
.password-toggle[hidden], .password-toggle .eye-hide { display: none; }
.password-toggle[aria-pressed="true"] .eye-show { display: none; }
.password-toggle[aria-pressed="true"] .eye-hide { display: block; }
.password-toggle svg { width: 21px; height: 21px; }

/* Calendar and daily availability sit alongside each other on wide screens. */
.calendar-container { max-width: 1280px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.calendar-container > .page-heading .brand-header h2 { font-size: 30px; }
.schedule-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); align-items: start; gap: 24px; }
.calendar-panel, .day-slots { min-width: 0; padding: 24px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.calendar-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.month-navigation { display: flex; align-items: center; gap: 8px; }
.month-navigation h3 { min-width: 160px; text-align: center; font-size: 20px; font-weight: 650; letter-spacing: -.02em; color: var(--ink); }
.calendar-arrow { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; }
.calendar-arrow svg { width: 18px; height: 18px; }
.calendar-arrow:hover, .calendar-today:hover { background: var(--brand-soft); text-decoration: none; }
.calendar-today { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; margin-left: auto; padding: 8px 13px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.date-filter { width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 7px 10px; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.date-filter label { grid-column: 1 / -1; font-size: 12px; }
.date-filter input { width: 100%; min-height: 42px; padding: 8px 12px; font-size: 14px; }
.date-filter button { width: auto; min-height: 42px; margin: 0; padding: 9px 16px; font-size: 13px; }
.calendar-panel > .help-text { margin: 14px 0 18px; font-size: 12px; }
.booking-calendar { width: 100%; margin: 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-variant-numeric: tabular-nums; }
.booking-calendar th { padding: 11px 2px; background: #f8f1f3; color: var(--brand); border: 0; font-size: 12px; font-weight: 600; text-align: center; }
.booking-calendar td { padding: 0; vertical-align: top; border: 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
.booking-calendar td:last-child { border-right: 0; }
.calendar-day { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-height: 84px; padding: 8px; color: var(--ink); font-weight: 400; }
.calendar-day:hover { background: #fcf7f8; text-decoration: none; }
.calendar-day-number { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; font-size: 14px; font-weight: 600; border-radius: 50%; }
.calendar-is-today .calendar-day-number { color: white; background: var(--brand); }
.calendar-selected .calendar-day { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.calendar-empty { background: #f7f8fa; }
.calendar-free { font-size: 10px; color: var(--muted); visibility: hidden; }
.calendar-selected .calendar-free { visibility: visible; }
.calendar-count { font-size: 11px; color: var(--brand); font-weight: 600; }
.calendar-markers { display: flex; gap: 4px; }
.marker-Pending, .marker-Approved { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.marker-Pending { background: var(--pending); }
.marker-Approved { background: var(--approved); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.calendar-legend > span { display: flex; align-items: center; gap: 7px; }
.day-slots { scroll-margin-top: 24px; }
.day-slots h3 { color: var(--ink); font-size: 18px; line-height: 1.4; font-weight: 650; letter-spacing: -.015em; }
.day-slots > .help-text { margin: 8px 0 20px; font-size: 12px; }
.facility-slots { list-style: none; border-top: 1px solid var(--line); }
.facility-slot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 17px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.facility-slot:last-child { border-bottom: 0; padding-bottom: 0; }
.facility-name { min-width: 0; }
.facility-name h4 { font-size: 14px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.facility-name > span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.facility-reservations { grid-column: 1; display: flex; flex-direction: column; gap: 8px; font-size: 11px; }
.reserved-slot { display: flex; flex-wrap: wrap; gap: 4px 8px; font-variant-numeric: tabular-nums; }
.slot-available { color: var(--approved); }
.slot-book { grid-column: 2; grid-row: 1 / 3; align-self: center; padding: 8px 10px; border: 1px solid #d9b9c0; border-radius: 6px; font-size: 12px; text-align: center; }
.slot-book:hover { background: var(--brand-soft); text-decoration: none; }
.slot-past { grid-column: 2; grid-row: 1 / 3; color: var(--muted); font-size: 11px; }
.status-Pending { color: var(--pending); font-weight: 600; }
.status-Approved { color: var(--approved); font-weight: 600; }
.status-Rejected { color: var(--rejected); font-weight: 600; }
.status-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.status-badge.status-Pending { background: #fff3d9; }
.status-badge.status-Approved { background: #e9f5ed; }
.status-badge.status-Rejected { background: #fce9eb; }

/* Management and booking history share readable, responsive tables. */
.view-switcher { display: flex; flex-wrap: wrap; gap: 4px; width: fit-content; margin-bottom: 24px; padding: 4px; background: #e9ecf0; border-radius: 8px; }
.view-switcher a { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 16px; color: var(--muted); border-radius: 5px; font-size: 13px; }
.view-switcher a:hover { color: var(--brand); text-decoration: none; }
.view-switcher a[aria-current="page"] { color: var(--brand); background: white; }
.admin-reservations { list-style: none; border-top: 1px solid var(--line); }
.admin-reservations > li { padding: 20px 0; border-bottom: 1px solid var(--line); }
.admin-reservations > li:last-child { border-bottom: 0; padding-bottom: 0; }
.reservation-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.reservation-heading h4 { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.reservation-time { margin-top: 8px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reservation-applicant { margin-top: 6px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.admin-day-slots .status-form { min-width: 0; margin-top: 16px; }
.table-wrap { width: 100%; overflow-x: auto; }
.management-table { width: 100%; margin-top: 4px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.management-table th { padding: 13px 16px; background: #f8f1f3; color: #672032; font-size: 12px; font-weight: 600; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.management-table th:first-child { border-radius: 6px 0 0 0; }
.management-table th:last-child { border-radius: 0 6px 0 0; }
.management-table td { padding: 18px 16px; border-bottom: 1px solid var(--line); font-size: 13px; text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
.management-table tbody tr:hover { background: #fcfcfd; }
.management-table small { color: var(--muted); line-height: 1.8; }
.status-form { display: grid; grid-template-columns: minmax(110px, 1fr) auto; align-items: center; gap: 7px 8px; min-width: 220px; }
.status-form label { grid-column: 1 / -1; font-size: 11px; color: var(--muted); font-weight: 500; }
.status-form select { min-height: 38px; padding: 7px 9px; font-size: 13px; }
.status-form button { min-height: 38px; width: auto; margin: 0; padding: 7px 13px; font-size: 12px; }
.status-form button[value="delete_booking"] { grid-column: 1 / -1; background: white; color: var(--brand); }
.status-form button[value="delete_booking"]:hover { background: var(--brand-soft); }
.venue-management { margin-top: 36px; }
.venue-management > .help-text { margin: 8px 0 20px; }
.venue-management .facility-slots { display: block; }
.venue-management button { width: auto; margin: 0; padding: 10px 12px; font-size: 12px; }
.venue-management .facility-slot { grid-template-columns: minmax(0, 1fr) auto; }

@media (max-width: 1000px) {
    .schedule-layout { grid-template-columns: minmax(0, 1fr); }
    .facility-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
    .facility-slot:last-child { border-bottom: 1px solid var(--line); padding-bottom: 17px; }
    .calendar-day { min-height: 90px; }
    .wide-container, .history-container { padding: 28px; }
}
@media (max-width: 700px) {
    .site-nav { padding: 12px 20px; gap: 8px; }
    .site-nav > span { min-width: 0; font-size: 14px; }
    .site-nav nav { order: 3; width: 100%; gap: 3px; }
    .site-logo { order: 0; width: 88px; height: 48px; padding: 5px; }
    .site-nav a, button.logout-link { padding: 8px 11px; font-size: 12px; }
    .site-nav a:first-child { margin-left: -11px; }
    .main-content { padding: 28px 16px; }
    .container { padding: 28px 24px; }
    .calendar-container { padding: 0; }
    .calendar-container > .page-heading .brand-header h2 { font-size: 26px; }
    .page-heading { align-items: flex-start; gap: 16px; margin-bottom: 24px; }
    .page-heading .btn-primary { min-height: 42px; padding: 9px 14px; font-size: 13px; }
    .brand-header h2 { font-size: 23px; }
    .calendar-panel, .day-slots { padding: 20px; }
    .facility-slots { grid-template-columns: minmax(0, 1fr); }
    .management-table, .management-table tbody, .management-table tr, .management-table td { display: block; width: 100%; }
    .management-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); }
    .management-table tbody tr { padding: 18px 0; border-top: 1px solid var(--line); }
    .management-table td { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: start; gap: 12px; padding: 6px 0; border: 0; }
    .management-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; }
    .management-table td[data-label="Action"] { display: block; padding-top: 14px; }
    .management-table td[data-label="Action"]::before, .management-table td[colspan]::before { display: none; }
    .management-table td[colspan] { display: block; }
    .management-table td[data-label="Status"] .status-badge { justify-self: start; }
    .status-form { min-width: 0; width: 100%; }
}
@media (max-width: 480px) {
    .calendar-panel, .day-slots { padding: 16px; }
    .month-navigation { gap: 4px; }
    .month-navigation h3 { min-width: 132px; font-size: 18px; }
    .calendar-arrow { width: 36px; height: 40px; }
    .calendar-today { padding: 8px 10px; }
    .calendar-toolbar { gap: 8px; }
    .booking-calendar th { font-size: 10px; padding: 11px 1px; }
    .calendar-day { min-height: 66px; padding: 5px 3px; gap: 3px; }
    .calendar-day-number { width: 24px; height: 24px; font-size: 12px; }
    .calendar-free, .calendar-count-label { display: none; }
    .calendar-count { padding-left: 3px; font-size: 10px; }
    .calendar-markers { padding-left: 3px; }
    .calendar-container > .page-heading .brand-header h2 { font-size: 24px; }
    .form-row { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}
