@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&display=swap");

:root {
    --bg: #f6f3ff;
    --bg-soft: #fbfaff;
    --surface: rgba(255, 255, 255, .92);
    --surface-strong: #ffffff;
    --line: #e6def8;
    --line-strong: #d8c9f3;
    --text: #24183d;
    --muted: #776a90;
    --accent: #6d28d9;
    --accent-dark: #4c1d95;
    --accent-soft: #efe7ff;
    --accent-warm: #a855f7;
    --danger: #b42318;
    --shadow: 0 18px 50px rgba(76, 29, 149, .10);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(168, 85, 247, .18), transparent 34rem),
        linear-gradient(180deg, #faf8ff 0%, var(--bg) 42%, #ffffff 100%);
    color: var(--text);
    font-family: "Noto Sans Thai", "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: linear-gradient(135deg, #2e1065 0%, #5b21b6 58%, #7c3aed 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    min-height: 78px;
    padding: 16px 30px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 12px 36px rgba(46, 16, 101, .22);
}

.topbar h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.topbar span {
    color: #e9ddff;
    font-size: 13px;
}

.brand-lockup {
    align-items: center;
    display: flex;
    gap: 12px;
    margin-bottom: 3px;
}

.brand-lockup img {
    background: #fff;
    border-radius: 8px;
    height: 40px;
    object-fit: contain;
    padding: 5px;
    width: 40px;
}

.topbar nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.topbar a,
button {
    align-items: center;
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 600;
    justify-content: center;
    min-height: 40px;
    padding: 9px 15px;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.topbar a {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .22);
}

.topbar a.nav-active {
    background: rgba(255, 255, 255, .24);
    border-color: rgba(255, 255, 255, .36);
}

.topbar a:hover,
button:hover {
    transform: translateY(-1px);
}

button:hover {
    background: var(--accent-dark);
    box-shadow: 0 12px 28px rgba(109, 40, 217, .24);
}

button:disabled {
    cursor: not-allowed;
    opacity: .45;
    transform: none;
}

.sync-pill {
    align-items: center;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 999px;
    display: inline-flex;
    min-height: 36px;
    padding: 8px 12px;
}

.page {
    margin: 0 auto;
    max-width: 1240px;
    padding: 26px;
}

.dashboard-head {
    align-items: end;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) 220px;
    margin-bottom: 18px;
}

.dashboard-head h2 {
    font-size: 30px;
    line-height: 1.2;
    margin: 4px 0 8px;
}

.dashboard-head p {
    color: var(--muted);
    margin: 0;
}

.eyebrow {
    color: var(--accent) !important;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.head-metric,
.filter-panel,
.stats div,
.table-wrap,
.panel,
.login-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.head-metric {
    padding: 18px;
    text-align: right;
}

.head-metric strong {
    display: block;
    font-size: 32px;
}

.head-metric span {
    color: var(--muted);
}

.filter-panel {
    padding: 16px;
}

.filters {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
}

label {
    color: var(--muted);
    display: grid;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
}

input,
select {
    background: var(--surface-strong);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    outline: none;
    padding: 9px 11px;
    width: 100%;
}

input[type="checkbox"] {
    min-height: auto;
    width: auto;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(109, 40, 217, .12);
}

.stats {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, 1fr);
    margin: 18px 0;
}

.stats div {
    min-height: 116px;
    padding: 20px;
}

.stats span {
    color: var(--muted);
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
}

.stats strong {
    display: block;
    font-size: 34px;
    line-height: 1;
}

.table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
}

.table-wrap.spaced {
    margin-top: 18px;
}

.section-title {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 18px 20px;
}

.export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.button-secondary {
    align-items: center;
    background: var(--accent-soft);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--accent-dark);
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
}

.button-secondary:hover {
    background: #e7d7ff;
}

.section-title h2 {
    font-size: 18px;
    margin: 0 0 4px;
}

.section-title p {
    color: var(--muted);
    margin: 0;
}

table {
    border-collapse: collapse;
    min-width: 860px;
    width: 100%;
}

.holiday-table {
    min-width: 0;
    table-layout: fixed;
}

.holiday-table th:nth-child(1),
.holiday-table td:nth-child(1) {
    width: 110px;
}

.holiday-table th:nth-child(2),
.holiday-table td:nth-child(2) {
    white-space: normal;
    width: 160px;
}

.holiday-table th:nth-child(3),
.holiday-table td:nth-child(3) {
    width: auto;
}

.holiday-table td:nth-child(2) {
    line-height: 1.45;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 13px 14px;
    text-align: left;
    white-space: nowrap;
}

th {
    background: #f7f2ff;
    color: #5d4a7d;
    font-size: 13px;
    font-weight: 800;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
}

.sortable-header::after {
    color: var(--accent);
    content: " ↕";
    font-size: 12px;
}

.sortable-header[data-sort-direction="asc"]::after {
    content: " ↑";
}

.sortable-header[data-sort-direction="desc"]::after {
    content: " ↓";
}

.remark-text {
    color: var(--accent-dark);
    font-weight: 600;
}

.remark-text.compliance-ok {
    color: #1c7c4a;
}

.remark-text.compliance-bad {
    color: #b13c3c;
    background: #fdecec;
    border-left: 3px solid #b13c3c;
    padding-left: 8px;
}

tr.row-violation {
    background: #fff7f6;
}

.holiday-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.holiday-actions button {
    min-height: 34px;
    padding: 7px 10px;
}

.button-muted {
    background: #667085;
}

tbody tr:hover {
    background: #fbf8ff;
}

.empty {
    color: var(--muted);
    padding: 26px;
    text-align: center;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
}

.login-box {
    max-width: 390px;
    padding: 30px;
    width: calc(100% - 32px);
}

.login-box h1 {
    font-size: 28px;
    margin: 0;
}

.login-brand {
    align-items: center;
    display: grid;
    gap: 14px;
    justify-items: start;
    margin-bottom: 20px;
}

.login-brand img {
    height: 56px;
    object-fit: contain;
}

.login-box form,
.stack {
    display: grid;
    gap: 14px;
}

.login-divider {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    gap: 10px;
    margin: 18px 0;
}

.login-divider::before,
.login-divider::after {
    background: var(--line);
    content: "";
    flex: 1;
    height: 1px;
}

.alert,
.notice {
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 11px 13px;
}

.alert {
    background: #fff1f0;
    color: var(--danger);
}

.notice {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.two-col {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) 340px;
}

.calendar-grid {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) 360px;
    margin-top: 18px;
}

.calendar-filters {
    grid-template-columns: minmax(160px, 220px) 160px;
}

.head-actions {
    justify-self: end;
}

.panel {
    padding: 20px;
}

.panel h2 {
    font-size: 17px;
    margin: 0 0 12px;
}

.panel h2:not(:first-child) {
    margin-top: 24px;
}

.actions form {
    margin: 0;
}

.inline-edit-form {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(112px, auto) minmax(160px, 1fr);
    min-width: 0;
}

.inline-edit-form .holiday-actions {
    grid-column: 1 / -1;
}

.employee-filters {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.status-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    min-width: 76px;
    padding: 5px 10px;
    justify-content: center;
}

.status-badge.is-active {
    background: #ecfdf3;
    color: #027a48;
}

.status-badge.is-muted {
    background: #f2f4f7;
    color: #667085;
}

.status-badge.is-exempt {
    background: #f5edff;
    color: var(--accent-dark);
}

.danger-button {
    background: #b42318;
}

.danger-button:hover {
    background: #912018;
}

@media (max-width: 920px) {
    .topbar,
    .dashboard-head,
    .filters,
    .calendar-filters,
    .two-col {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: stretch;
        display: grid;
        gap: 12px;
        padding: 16px;
    }

    .topbar nav {
        justify-content: start;
    }

    .page {
        padding: 18px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .head-metric {
        text-align: left;
    }

    .head-actions {
        justify-self: start;
    }
}
