:root {
    --kc-blue: #2b3990;
    --kc-blue-dark: #171d52;
    --kc-green: #00a651;
    --kc-green-dark: #00793d;
    --signal: #f2a93b;
    --danger: #c23616;
    --danger-bg: #fdeae6;
    --ink: #11142a;
    --muted: #5b6178;
    --line: #e6e8f2;
    --bg: #edeff8;
    --card: #ffffff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(23, 29, 82, 0.06);
    --shadow-lift: 0 14px 30px rgba(23, 29, 82, 0.14);
    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ============ Header ============ */
.site-header {
    background: var(--card);
    border-bottom: 3px solid;
    border-image: linear-gradient(90deg, var(--kc-green), var(--kc-blue)) 1;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 0 rgba(23, 29, 82, 0.02);
}
.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 13px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-logo { height: 40px; width: auto; }
.brand-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    color: var(--kc-blue-dark);
    letter-spacing: 0.1px;
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.site-nav a {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--kc-blue);
    padding: 8px 14px;
    border-radius: 999px;
    transition: background 0.15s ease, color 0.15s ease;
}
.site-nav a:hover { background: var(--bg); }
.site-nav a[href$="logout.php"] { color: var(--danger); }
.site-nav a[href$="logout.php"]:hover { background: var(--danger-bg); }

.nav-user {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 600;
    padding: 6px 4px 6px 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-left: 1px solid var(--line);
    margin-left: 4px;
}
.role-badge {
    font-family: var(--font-mono);
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 4px;
}
.role-admin { background: var(--danger-bg); color: var(--danger); }
.role-user { background: #e3f7ec; color: var(--kc-green-dark); }

/* ============ Main / layout ============ */
.site-main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 24px 72px;
}

/* ============ Hero ============ */
.hero { margin-bottom: 32px; position: relative; }
.hero.hero-dark {
    margin: -40px calc(50% - 50vw) 36px;
    padding: 54px 24px 64px;
    background: linear-gradient(150deg, var(--kc-blue-dark), var(--kc-blue) 55%, var(--kc-green-dark));
    overflow: hidden;
}
.hero-dark-pattern { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.45; }
.hero-dark-inner { max-width: 1120px; margin: 0 auto; position: relative; z-index: 1; }
.hero-eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--kc-green-dark);
    display: block;
    margin-bottom: 10px;
}
.hero h1 {
    font-size: 32px;
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--kc-blue-dark);
    max-width: 620px;
}
.hero p {
    color: var(--muted);
    max-width: 560px;
    margin: 0 0 16px;
    font-size: 15px;
}
.hero-stat {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--kc-blue-dark);
    background: #eef0fb;
    border: 1px solid var(--line);
    padding: 6px 12px;
    border-radius: 999px;
}
.hero-stat .pulse {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--kc-green);
    box-shadow: 0 0 0 0 rgba(0, 166, 81, 0.5);
    animation: pulse 2.2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 166, 81, 0.45); }
    70% { box-shadow: 0 0 0 7px rgba(0, 166, 81, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 166, 81, 0); }
}

/* Dark hero variant overrides — must come after the base rules above */
.hero-dark .hero-eyebrow { color: #a9f0cb; }
.hero-dark h1 { color: #fff; }
.hero-dark p { color: #d3d7f2; }
.hero-dark .hero-stat { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); color: #fff; }

/* ============ Alerts ============ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
    font-weight: 600;
    border-left: 3px solid;
}
.alert-success { background: #e6f8ee; color: var(--kc-green-dark); border-color: var(--kc-green); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ============ Facility grid ============ */
.facility-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
}
.facility-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    position: relative;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.facility-card::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--kc-green), var(--kc-blue));
}
.facility-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.facility-card-link {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 22px 22px 20px;
    flex-grow: 1;
}
.facility-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--bg);
    box-shadow: inset 0 0 0 1.5px var(--line);
    color: var(--kc-blue);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    transition: background 0.18s ease, color 0.18s ease;
}
.facility-card:hover .facility-card-icon {
    background: var(--kc-blue);
    color: #fff;
}
.facility-card h2 { margin: 0; font-size: 17.5px; font-weight: 600; color: var(--kc-blue-dark); }
.facility-card p { margin: 0; color: var(--muted); font-size: 13.5px; flex-grow: 1; }
.facility-cta {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--kc-blue);
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: gap 0.15s ease;
}
.facility-card:hover .facility-cta { gap: 8px; }

.btn-delete-facility {
    background: var(--danger-bg);
    color: var(--danger);
    border: none;
    border-top: 1px solid #f7d2ca;
    padding: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease;
}
.btn-delete-facility:hover { background: #f9d4cb; }
.facility-delete-form { margin: 0; }

/* ============ Panels (shared) ============ */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.panel h2 {
    margin: 0 0 14px;
    font-size: 15.5px;
    font-weight: 600;
    color: var(--kc-blue-dark);
}

/* ============ Admin: add facility ============ */
.admin-add-facility { margin-top: 28px; }
.admin-add-facility h2 {
    display: flex; align-items: center; gap: 8px;
}
.admin-add-facility h2::before {
    content: '+';
    width: 22px; height: 22px;
    background: var(--kc-green);
    color: #fff;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}
.add-facility-form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.add-facility-form label { font-size: 13px; font-weight: 600; color: var(--ink); }
.add-facility-form input,
.add-facility-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.add-facility-form input:focus,
.add-facility-form textarea:focus { outline: none; border-color: var(--kc-blue); background: #fff; }

/* ============ Dashboard ============ */
.dashboard-heading { margin-bottom: 24px; }
.dashboard-heading-dark {
    position: relative;
    margin: -40px calc(50% - 50vw) 30px;
    padding: 40px 24px 46px;
    background: linear-gradient(150deg, var(--kc-blue-dark), var(--kc-blue) 55%, var(--kc-green-dark));
    overflow: hidden;
}
.dashboard-heading-inner { max-width: 1120px; margin: 0 auto; position: relative; z-index: 1; }
.back-link {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s ease;
}
.back-link:hover { color: var(--kc-blue); }
.dashboard-heading h1 {
    margin: 8px 0 4px;
    color: var(--kc-blue-dark);
    font-size: 25px;
    font-weight: 600;
}
.dashboard-heading p { margin: 0; color: var(--muted); font-size: 14px; }

/* Dark banner overrides — must come after the base rules above */
.dashboard-heading-dark .back-link { color: rgba(255,255,255,0.75); }
.dashboard-heading-dark .back-link:hover { color: #fff; }
.dashboard-heading-dark h1 { color: #fff; }
.dashboard-heading-dark p { color: #d3d7f2; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 20px;
}
.form-panel { grid-column: 1 / -1; }

@media (min-width: 860px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr 1fr; }
    .form-panel { grid-column: 3; grid-row: 1 / 3; }
    .calendar-panel { grid-column: 1; }
    .schedule-panel { grid-column: 2; }
}

/* ============ Calendar ============ */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.calendar-nav h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.calendar-nav button {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    color: var(--kc-blue);
    transition: background 0.15s ease, transform 0.1s ease;
}
.calendar-nav button:hover { background: var(--line); }
.calendar-nav button:active { transform: scale(0.94); }

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.cal-day {
    aspect-ratio: 1;
    border: none;
    background: var(--bg);
    border-radius: 7px;
    font-size: 12.5px;
    font-family: var(--font-mono);
    cursor: pointer;
    color: var(--ink);
    position: relative;
    transition: background 0.15s ease, transform 0.1s ease;
}
.cal-day:hover { background: var(--line); }
.cal-day:active { transform: scale(0.92); }
.cal-empty { background: transparent; cursor: default; }
.cal-empty:hover { background: transparent; }
.cal-past { color: #bcbfd2; }
.cal-today { font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--signal); color: var(--signal); }
.cal-booked::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--kc-green);
}
.cal-selected { background: var(--kc-blue); color: #fff; box-shadow: none; }
.cal-selected.cal-today { color: var(--signal); box-shadow: inset 0 0 0 1.5px var(--signal); background: var(--kc-blue); }
.cal-selected.cal-booked::after { background: #fff; }

.calendar-legend {
    font-size: 11.5px;
    color: var(--muted);
    margin: 14px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-left: 10px; }
.dot-booked { background: var(--kc-green); margin-left: 0; }
.dot-selected { background: var(--kc-blue); }

/* ============ Schedule ============ */
.schedule-list { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow-y: auto; padding-right: 2px; }
.schedule-empty { color: var(--muted); font-size: 13.5px; }
.schedule-item {
    display: flex;
    gap: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    position: relative;
    align-items: flex-start;
    border-left: 3px solid var(--line);
    transition: background 0.15s ease;
}
.schedule-item:hover { background: #ebedf7; }
.schedule-time {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--kc-blue);
    white-space: nowrap;
    min-width: 88px;
    padding-top: 1px;
}
.schedule-info { flex-grow: 1; min-width: 0; }
.schedule-dept {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13.5px;
    font-weight: 600;
}
.schedule-dept .dept-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.schedule-info span.schedule-employee { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.schedule-info p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.btn-delete-booking {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 5px;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.btn-delete-booking:hover { background: var(--danger-bg); }

/* ============ Form ============ */
.form-panel form { display: flex; flex-direction: column; gap: 13px; }
.form-panel label { font-size: 13px; font-weight: 600; color: var(--ink); }
.req { color: var(--danger); }
.form-panel input,
.form-panel textarea,
.form-panel select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.form-panel select { appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235b6178'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}
.form-panel input:focus,
.form-panel textarea:focus,
.form-panel select:focus {
    outline: none;
    border-color: var(--kc-blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(43, 57, 144, 0.1);
}
.sub-division-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}
.sub-division-wrap.is-visible { max-height: 90px; opacity: 1; }
.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-submit {
    margin-top: 6px;
    background: var(--kc-green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn-submit:hover { background: var(--kc-green-dark); }
.btn-submit:active { transform: scale(0.98); }

/* ============ Login ============ */
.login-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}
.login-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
}
.login-brand-panel {
    flex: 1.1;
    position: relative;
    background: linear-gradient(155deg, var(--kc-blue-dark), var(--kc-blue) 60%, var(--kc-green-dark));
    color: #fff;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    overflow: hidden;
}
.login-cable-pattern { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.5; }
.login-brand-content { position: relative; z-index: 1; }
.login-wordmark {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.4px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 10px;
}
.login-wordmark img { height: 30px; background: #fff; border-radius: 6px; padding: 4px 6px; }
.login-headline {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 600;
    line-height: 1.2;
    margin: auto 0;
    max-width: 380px;
    position: relative;
    z-index: 1;
}
.login-caption {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.4px;
    opacity: 0.75;
    position: relative;
    z-index: 1;
}

.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}
.login-wrap { width: 100%; max-width: 360px; }
.login-mobile-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.login-mobile-logo img { height: 44px; }
.login-card h1 { font-size: 21px; font-weight: 600; margin: 0 0 4px; color: var(--kc-blue-dark); }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { font-size: 13px; font-weight: 600; color: var(--ink); }
.login-form input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg);
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.login-form input:focus {
    outline: none;
    border-color: var(--kc-blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(43, 57, 144, 0.1);
}
.login-card .alert { text-align: left; }

@media (min-width: 820px) {
    .login-brand-panel { display: flex; }
}

/* ============ Footer ============ */
.site-footer {
    background: var(--kc-blue-dark);
    color: #c3c7e2;
    margin-top: 44px;
}
.footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 24px;
    text-align: center;
}
.footer-logo { height: 28px; background: #fff; padding: 6px 10px; border-radius: var(--radius-sm); margin-bottom: 12px; }
.footer-inner p { margin: 2px 0; font-size: 13px; }
.footer-note { color: #8489ad; font-size: 11.5px; }
