:root {
    --bg: #f0f4f3;
    --card: #fff;
    --primary: #185549;
    --primary-light: #1f6b5e;
    --accent: #d4e157;
    --danger: #c62828;
    --border: #dce3e1;
    --text: #24302e;
    --muted: #6b7c78;
    --font: 'Sarabun', sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #144a42 0%, #1f6b5e 50%, #0f3d36 100%);
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border-radius: 12px;
    padding: 2rem 1.75rem;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.auth-card h1 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--primary);
}

.auth-sub {
    margin: 0.25rem 0 1.25rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.auth-form label,
.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.auth-form input,
.admin-form input,
.admin-form select {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 1rem;
    color: var(--text);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.auth-hint {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.auth-back {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

.admin-header {
    background: linear-gradient(180deg, #1f6b5e 0%, #185549 100%);
    color: #fff;
    padding: clamp(0.85rem, 2vw, 1.35rem) clamp(1rem, 3vw, 2.75rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-header h1 {
    margin: 0;
    font-size: 1.25rem;
}

.admin-header p {
    margin: 0.15rem 0 0;
    opacity: 0.85;
    font-size: 0.85rem;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-main {
    width: 100%;
    min-height: calc(100vh - 86px);
    margin: 0;
    padding: clamp(0.75rem, 2.5vw, 2rem) clamp(0.75rem, 3vw, 3rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-menu {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding: 0.35rem;
    background: #dfe9e6;
    border-radius: 9px;
}

.admin-menu-item {
    flex: 1 0 auto;
    border: 0;
    border-radius: 6px;
    min-height: 3rem;
    padding: 0.7rem clamp(0.75rem, 2vw, 1.5rem);
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.admin-menu-item:hover { color: var(--primary); background: rgba(255, 255, 255, 0.55); }
.admin-menu-item.is-active { background: var(--card); color: var(--primary); box-shadow: 0 2px 7px rgba(24, 85, 73, 0.14); }

.tab-panel[hidden] { display: none; }

.download-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(1rem, 3vw, 2.5rem);
    align-items: start;
}

.download-filters { min-width: 0; }

.date-range-grid {
    margin-top: 0.85rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.availability-calendar {
    width: 100%;
    max-width: none;
    margin-top: 1rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfdfc;
}

.calendar-toolbar, .calendar-weekdays, .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    align-items: center;
}

.calendar-toolbar { grid-template-columns: 2rem 1fr 2rem; text-align: center; margin-bottom: 0.55rem; }
.calendar-nav { border: 0; border-radius: 5px; background: #e8f5f1; color: var(--primary); font-size: 1.25rem; cursor: pointer; }
.calendar-nav:hover { background: #d4e8e2; }
.calendar-weekdays { color: var(--muted); font-size: 0.75rem; text-align: center; }
.calendar-grid { margin-top: 0.25rem; }
.calendar-day { position: relative; min-height: 2rem; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--text); font-family: var(--font); cursor: pointer; }
.calendar-day.has-data:hover { border-color: var(--primary-light); background: #e8f5f1; }
.calendar-day:disabled { color: #c7d0cd; cursor: default; }
.calendar-day.is-empty { min-height: 2rem; }
.calendar-day i, .calendar-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--primary-light); vertical-align: middle; }
.calendar-day i { position: absolute; bottom: 3px; left: calc(50% - 2px); }
.calendar-legend { margin-top: 0.6rem; color: var(--muted); font-size: 0.75rem; }

.admin-card {
    width: 100%;
    background: var(--card);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.admin-card h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--primary);
}

.section-note { margin: -0.55rem 0 1rem; color: var(--muted); font-size: 0.85rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 0.85rem;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: #eceff1;
    color: var(--text);
}

.btn:hover { filter: brightness(0.97); text-decoration: none; }

.btn-primary {
    background: linear-gradient(180deg, #1f6b5e, #185549);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

.btn-ghost {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.admin-main .btn-ghost {
    background: #eceff1;
    color: var(--text);
}

.btn-danger {
    background: #ffebee;
    color: var(--danger);
    border-color: #ffcdd2;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.alert-error { background: #ffebee; color: #b71c1c; }
.alert-success { background: #e8f5e9; color: #1b5e20; }

.table-scroll { overflow-x: auto; }

.admin-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.admin-table thead th {
    background: #e8f5f1;
    color: var(--primary);
    white-space: nowrap;
}

.admin-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.admin-table tfoot th {
    background: #f5f5f5;
    font-weight: 700;
}

.admin-table .actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    white-space: nowrap;
}

.inline { display: inline; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem !important; }

code {
    background: #eceff1;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

@media (max-width: 640px) {
    .admin-header { align-items: flex-start; }
    .admin-header h1 { font-size: 1.15rem; }
    .admin-user { width: 100%; }
    .admin-user .btn { flex: 1 1 auto; }
    .admin-menu { margin-inline: -0.15rem; }
    .admin-menu-item { font-size: 0.85rem; }
    .admin-card { padding: 1rem; border-radius: 8px; }
    .admin-card h2 { font-size: 1rem; }
    .form-actions .btn { width: 100%; }
    .form-actions { flex-direction: column; }
    .availability-calendar { max-width: none; }
    .download-layout { grid-template-columns: 1fr; }
}

@media (min-width: 1600px) {
    .admin-main { padding-inline: 4vw; }
}
