:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d9e0ea;
    --primary: #174a7c;
    --primary-dark: #123b63;
    --primary-soft: #e8f1fa;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --success: #027a48;
    --success-soft: #ecfdf3;
    --warning: #b54708;
    --warning-soft: #fffbeb;
    --shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

:root[data-theme="dark"] {
    --bg: #0f172a;
    --card: #111827;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #334155;
    --primary: #93c5fd;
    --primary-dark: #bfdbfe;
    --primary-soft: #1e3a5f;
    --danger: #fca5a5;
    --danger-soft: #3f1d1d;
    --success: #86efac;
    --success-soft: #123524;
    --warning: #fbbf24;
    --warning-soft: #422006;
    --shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top left, #e9f2fb 0, var(--bg) 38%, #eef2f7 100%);
    line-height: 1.5;
}

:root[data-theme="dark"] body { background: radial-gradient(circle at top left, #1e293b 0, var(--bg) 42%, #020617 100%); }

a { color: var(--primary); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.55);
    outline-offset: 2px;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

:root[data-theme="dark"] .app-topbar { background: rgba(15, 23, 42, 0.92); }

.app-brand {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.top-nav,
.toolbar-group,
.table-actions,
.pagination-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-shell {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}
.page-shell.wide { width: min(1240px, calc(100% - 32px)); }
.page-shell.narrow { width: min(560px, calc(100% - 32px)); }
.admin-shell { padding-top: 20px; }

.hero-card,
.card,
.alert {
    background: var(--card);
    border: 1px solid rgba(217, 224, 234, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
:root[data-theme="dark"] .hero-card,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .alert { border-color: rgba(51, 65, 85, 0.95); }

.hero-card {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    padding: 26px 28px;
    margin-bottom: 18px;
}
.admin-hero { padding: 18px 22px; }

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.05; }
.admin-hero h1 { font-size: clamp(1.45rem, 3vw, 2rem); }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; }
.lead { max-width: 680px; margin: 9px 0 0; color: var(--muted); font-size: 1rem; }
.admin-hero .lead { font-size: 0.93rem; }

.card { padding: 24px; }
.alert { padding: 12px 14px; margin-bottom: 16px; font-size: 0.95rem; }
.alert.success { color: var(--success); background: var(--success-soft); border-color: #abefc6; }
.alert.error { color: var(--danger); background: var(--danger-soft); border-color: #fecdca; }
.alert.warning-alert { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.alert span { display: block; margin-top: 3px; }
:root[data-theme="dark"] .alert.success { border-color: #166534; }
:root[data-theme="dark"] .alert.error { border-color: #7f1d1d; }
:root[data-theme="dark"] .alert.warning-alert { color: #fde68a; background: #422006; border-color: #92400e; }

.small-note, .hint, .privacy-note, .optional, .muted-text { color: var(--muted); font-size: 0.88rem; }
.required-note { margin: 0 0 18px; color: var(--muted); font-size: 0.92rem; }
.required-marker { color: var(--danger); }

.form-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.form-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { color: var(--text); background: #0b1220; border-color: var(--line); }
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #64748b; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(23, 74, 124, 0.12); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
textarea { resize: vertical; }
.field-error { margin: 7px 0 0; color: var(--danger); font-size: 0.88rem; }

.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 8px; }
.split-actions { justify-content: flex-start; }

.button,
.primary-button,
.secondary-link,
.danger-button,
.danger-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 999px;
    padding: 9px 16px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.1;
    white-space: nowrap;
}
.button-compact, .small-button, .small-link, .top-nav .button {
    min-height: 30px;
    min-width: 104px;
    padding: 5px 9px;
    font-size: 0.8rem;
}
.button-primary, .primary-button { color: #fff; background: var(--primary); border-color: var(--primary); }
.button-primary:hover, .primary-button:hover { background: var(--primary-dark); }
.button-secondary, .secondary-link { color: var(--primary); background: #fff; border-color: var(--line); }
.button-secondary:hover, .secondary-link:hover { background: var(--primary-soft); }
.button-success { color: #065f46; background: #d1fae5; border-color: #a7f3d0; }
.button-success:hover { background: #bbf7d0; }
.button-danger, .danger-button, .danger-link { color: var(--danger); background: var(--danger-soft); border-color: #fecdca; }
.button-danger:hover, .danger-button:hover, .danger-link:hover { background: #fee4e2; }
.button-disabled { color: var(--muted); background: #f3f4f6; border-color: var(--line); cursor: not-allowed; }
:root[data-theme="dark"] .button-secondary,
:root[data-theme="dark"] .secondary-link { color: var(--primary); background: #0b1220; border-color: var(--line); }
:root[data-theme="dark"] .button-secondary:hover,
:root[data-theme="dark"] .secondary-link:hover { background: #172554; }
:root[data-theme="dark"] .button-success { color: #bbf7d0; background: #064e3b; border-color: #047857; }
:root[data-theme="dark"] .button-success:hover { background: #065f46; }
:root[data-theme="dark"] .button-danger,
:root[data-theme="dark"] .danger-button,
:root[data-theme="dark"] .danger-link { color: #fecaca; background: #3f1d1d; border-color: #7f1d1d; }

.toolbar-card { margin-bottom: 18px; padding: 18px; }
.filter-form { display: grid; grid-template-columns: minmax(190px, 1.4fr) repeat(4, minmax(120px, 0.75fr)) auto; gap: 12px; align-items: end; }
.compact-field { margin-bottom: 0; }
.filter-actions { display: flex; gap: 8px; align-items: center; padding-bottom: 1px; flex-wrap: wrap; }

.table-card { padding: 0; overflow: hidden; }
.table-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.result-count { color: var(--muted); font-size: 0.88rem; }
.table-wrap { overflow-x: auto; max-height: 70vh; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 2; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.comments-cell { max-width: 320px; white-space: pre-wrap; }
.empty-state { margin: 0; padding: 24px; color: var(--muted); }
.compact-empty { padding: 0; }
.admin-list-card table { font-size: 0.88rem; }
.actions-cell { min-width: 180px; white-space: nowrap; }
:root[data-theme="dark"] th { background: #0b1220; }

.cancel-details { display: inline-block; margin-left: 6px; vertical-align: top; }
.cancel-details summary { list-style: none; }
.cancel-details summary::-webkit-details-marker { display: none; }
.inline-cancel-form { margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); min-width: 240px; box-shadow: var(--shadow); }
.inline-cancel-form label { display: block; margin-bottom: 6px; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.inline-cancel-form input { margin-bottom: 8px; padding: 8px 9px; border-radius: 8px; }
.cancel-panel { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }

.pagination-bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.page-indicator { color: var(--muted); font-weight: 700; }

.reason-label { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 9px; font-size: 0.78rem; font-weight: 700; border: 1px solid transparent; }
.reason-vacation { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }
.reason-personal-day { color: #6d28d9; background: #ede9fe; border-color: #ddd6fe; }
.reason-bereavement { color: #374151; background: #f3f4f6; border-color: #d1d5db; }
.reason-sick-day { color: #be123c; background: #ffe4e6; border-color: #fecdd3; }
.reason-other, .reason-none { color: #475569; background: #f1f5f9; border-color: #cbd5e1; }
:root[data-theme="dark"] .reason-vacation { color: #bfdbfe; background: #1e3a8a; border-color: #1d4ed8; }
:root[data-theme="dark"] .reason-personal-day { color: #ddd6fe; background: #4c1d95; border-color: #6d28d9; }
:root[data-theme="dark"] .reason-bereavement { color: #e5e7eb; background: #374151; border-color: #4b5563; }
:root[data-theme="dark"] .reason-sick-day { color: #fecdd3; background: #881337; border-color: #be123c; }
:root[data-theme="dark"] .reason-other, :root[data-theme="dark"] .reason-none { color: #cbd5e1; background: #334155; border-color: #475569; }

.calendar-card { padding: 18px; }
.calendar-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row { color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; overflow: hidden; }
.weekday-row div { padding: 9px; background: #f8fafc; border-right: 1px solid var(--line); }
.weekday-row div:last-child { border-right: 0; }
.calendar-grid { border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.calendar-day { min-height: 132px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.calendar-day[data-detail-url] { cursor: pointer; }
.calendar-day header { display: flex; justify-content: space-between; align-items: center; gap: 4px; margin-bottom: 6px; }
.muted-day { background: #f8fafc; color: #98a2b3; }
.calendar-day.is-today, .calendar-day.today-day { background-color: #fff8c5 !important; box-shadow: inset 0 0 0 2px #facc15; }
.calendar-day.is-today .day-number, .calendar-day.today-day .day-number { color: var(--primary-dark); }
.today-label { display: inline-flex; align-items: center; justify-content: center; min-height: 20px; border-radius: 999px; padding: 1px 7px; font-size: 0.68rem; font-weight: 700; color: #713f12; background: #fef3c7; border: 1px solid #facc15; }
.day-number { font-weight: 700; }
.day-count { display: inline-flex; align-items: center; justify-content: center; min-width: 21px; height: 21px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 0.76rem; font-weight: 700; text-decoration: none; }
.request-chip { display: block; margin-bottom: 5px; padding: 6px 7px; border-radius: 9px; font-size: 0.8rem; text-decoration: none; border: 1px solid #cbd5e1; }
.request-chip:hover { filter: brightness(0.98); }
.request-chip strong, .request-chip span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.request-chip span { font-size: 0.73rem; opacity: 0.88; }
.day-detail-link { display: inline-flex; align-items: center; gap: 5px; color: inherit; text-decoration: none; border-radius: 8px; }
.day-detail-link:hover .day-number { text-decoration: underline; }
.more-link { display: block; margin-top: 3px; padding: 4px 6px; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: 0.76rem; font-weight: 800; text-decoration: none; text-align: center; }
.more-link:hover { text-decoration: underline; }
.day-detail-toolbar { margin-bottom: 0; justify-content: flex-start; }
.day-detail-card table { min-width: 900px; }

:root[data-theme="dark"] .weekday-row div,
:root[data-theme="dark"] .muted-day { background: #0b1220; }
:root[data-theme="dark"] .calendar-day { background: #111827; }
:root[data-theme="dark"] .calendar-day.is-today,
:root[data-theme="dark"] .calendar-day.today-day { color: #1f2937; }
:root[data-theme="dark"] .day-count { background: #1e3a5f; color: #bfdbfe; }
:root[data-theme="dark"] .more-link { color: #bfdbfe; background: #1e3a5f; }

.calendar-text-list { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.calendar-text-list h3 { margin-bottom: 8px; }
.calendar-text-list ul { margin: 0; padding-left: 1.25rem; }
.calendar-text-list li { margin-bottom: 0.4rem; }

.help-list, .overlap-list { margin: 16px 0 0; padding-left: 1.25rem; }
.help-list li, .overlap-list li { margin-bottom: 0.45rem; }
.compact-card, .confirmation-card { margin-bottom: 18px; }
.summary-list { display: grid; gap: 8px; margin: 18px 0 0; }
.summary-list div { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.summary-list div:last-child { border-bottom: 0; }
.summary-list dt { color: var(--muted); font-weight: 700; }
.summary-list dd { margin: 0; white-space: pre-wrap; }

.print-only { display: none; }
.print-header { margin-bottom: 16px; }
.print-shell { padding-top: 20px; }
.week-print-grid .calendar-day { min-height: 190px; }
.print-page-body { background: var(--bg); }
.print-list-card .table-wrap { max-height: none; }

@media (max-width: 920px) {
    .app-topbar, .calendar-toolbar, .pagination-bar { align-items: stretch; flex-direction: column; }
    .top-nav, .toolbar-group, .pagination-actions { justify-content: flex-start; }
    .filter-form { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .hero-card, .form-actions { align-items: stretch; flex-direction: column; }
    .form-grid.two-col { grid-template-columns: 1fr; }
    .calendar-card { overflow-x: auto; }
    .weekday-row, .calendar-grid { min-width: 820px; }
    .summary-list div { grid-template-columns: 1fr; gap: 4px; }
    .button-compact, .top-nav .button { min-width: auto; }
}

@media print {
    @page { size: landscape; margin: 0.35in; }
    * { box-shadow: none !important; }
    body { background: #fff !important; color: #111827 !important; font-size: 10pt; }
    .no-print, .app-topbar, .toolbar-card, .calendar-toolbar, .pagination-bar, .actions-cell, .alert { display: none !important; }
    .print-only { display: block !important; }
    .page-shell, .page-shell.wide { width: 100% !important; padding: 0 !important; }
    .hero-card, .card { border: 0 !important; border-radius: 0 !important; padding: 0 !important; }
    .table-wrap { overflow: visible !important; max-height: none !important; }
    table { min-width: 0 !important; font-size: 8.5pt; page-break-inside: auto; }
    th { position: static; background: #f3f4f6 !important; color: #111827 !important; }
    th, td { padding: 5px 6px; }
    .weekday-row, .calendar-grid { min-width: 0 !important; }
    .weekday-row div { padding: 5px; background: #f3f4f6 !important; color: #111827; }
    .calendar-day { min-height: 92px; padding: 4px; background: #fff !important; page-break-inside: avoid; }
    .request-chip { padding: 3px 4px; margin-bottom: 3px; font-size: 7.5pt; color: #111827 !important; background: #f8fafc !important; border-color: #cbd5e1 !important; }
    .request-chip span { font-size: 7pt; }
    .calendar-text-list { page-break-before: auto; }
    .print-header h1 { font-size: 18pt; }
}
