/* =========================================================
   ระบบจองห้องประชุม — ธีม "Architectural Silence"
   Luxury Minimalism: serif editorial + sharp corners + paper tones
   ========================================================= */

/* Google Sans (self-hosted, OFL) — อักษรละติน; ไทยใช้ Noto Sans Thai fallback */
@font-face {
    font-family: "Google Sans";
    src: url("../fonts/GoogleSans.ttf") format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg:          #f5f2ec;   /* off-white paper */
    --surface:     #ffffff;   /* elevated cards/inputs */
    --paper:       #faf8f3;   /* header / subtle fills */
    --ink:         #181818;   /* primary text + buttons */
    --ink-soft:    #525252;   /* secondary text */
    --ink-faint:   #8a8579;   /* metadata */
    --gold:        #ad9c82;   /* muted gold accent */
    --cream:       #f4e0c3;   /* "booked" fill */
    --cream-soft:  #faf3e7;   /* info surfaces */
    --line:        #e6e1d8;   /* hairline */
    --line-strong: #d8d2c6;   /* input borders */
    --red:         #ba1a1a;   /* error / maintenance / logout */
    --red-bg:      #fbeeee;
    --green-bg:    #eef3ee;
    --green-ink:   #33503a;
    --serif: "Libre Caslon Text", "Noto Serif Thai", Georgia, "Times New Roman", serif;
    --sans:  "Google Sans", "Noto Sans Thai", "Segoe UI", Tahoma, sans-serif;
    --shadow-soft: 0 20px 40px rgba(24,24,24,.05);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
.container { max-width: 1280px; margin: 0 auto; padding: 0 40px; }
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--ink); }
h1 { font-size: 2.4rem; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 8px; }
h2 { font-size: 1.5rem; margin: 32px 0 14px; }
h3 { font-size: 1.15rem; margin: 0 0 8px; }

/* label-caps helper (used by labels, table heads, meta) */
.eyebrow {
    font-family: var(--sans);
    text-transform: uppercase; letter-spacing: .15em;
    font-size: .7rem; font-weight: 600; color: var(--gold);
    margin: 0 0 12px;
}

/* ---------- Top bar (light, editorial) ---------- */
.topbar {
    background: var(--paper);
    color: var(--ink);
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}
.topbar a { color: var(--ink); }
.topbar-inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px; flex-wrap: nowrap;
}
.brand {
    display: inline-flex; align-items: center; gap: 14px;
    flex: 1 1 0; min-width: 0;   /* ฝั่งซ้าย */
}
.brand:hover { text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sep { width: 1px; height: 24px; background: var(--line-strong); }
.brand-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 400; letter-spacing: .03em; color: var(--ink); }
@media (max-width: 560px) { .brand-sep, .brand-title { display: none; } }
.brand-tag {
    font-family: var(--sans); font-size: .62rem; font-weight: 600;
    letter-spacing: .18em; text-transform: uppercase; color: var(--gold);
    border: 1px solid var(--gold); padding: 3px 7px;
}
.nav { display: flex; gap: 10px; flex-wrap: wrap; flex: 0 1 auto; justify-content: center; }
.nav a {
    padding: 8px 18px; border: 1px solid var(--line); border-radius: 999px;
    font-size: .82rem; letter-spacing: .03em; color: var(--ink-soft);
    background: var(--surface); white-space: nowrap;
    box-shadow: 0 2px 4px rgba(24,24,24,.09), inset 0 1px 0 rgba(255,255,255,.6);
    transition: transform .1s ease, box-shadow .15s ease, color .15s, background .15s, border-color .15s;
}
.nav a:hover { color: var(--ink); background: #fff; border-color: var(--gold); transform: translateY(-1px); box-shadow: 0 5px 12px rgba(24,24,24,.16); text-decoration: none; }
.nav a:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(24,24,24,.12); }
.user-box { display: flex; align-items: center; justify-content: flex-end; gap: 14px; font-size: .85rem; flex: 1 1 0; min-width: 0; }
.user-name { font-weight: 600; }
.user-dept { color: var(--ink-faint); }

/* ---------- Content ---------- */
.content { flex: 1 1 auto; width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px 40px 56px; }
.footer { background: var(--surface); border-top: 1px solid var(--line); padding: 22px 44px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; width: 100%; max-width: 1440px; margin: 0 auto; }
.footer-brand { font-family: var(--serif); font-size: 1.15rem; letter-spacing: .04em; }
.footer-copy { color: var(--ink-faint); font-size: .78rem; letter-spacing: .04em; }

/* ---------- Layout: Sidebar (SaaS) ---------- */
.app-sidebar { display: flex; align-items: flex-start; }
.main-wrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.sidebar {
    flex: 0 0 264px; width: 264px;
    position: sticky; top: 0; align-self: flex-start; height: 100vh;
    background: var(--surface); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 24px 16px 22px; overflow-y: auto;
}
.sidebar-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 4px 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.sidebar-brand .brand-logo {
    height: 30px; width: auto; display: block;
    /* มิติ 3D: เงายกนูน + ไฮไลต์ขอบบนบางๆ (ทำงานตามรูปทรงโลโก้เพราะพื้นโปร่งใส) */
    filter: drop-shadow(0 1px 0 rgba(255,255,255,.55))
            drop-shadow(0 1px 1px rgba(24,24,24,.16))
            drop-shadow(0 3px 4px rgba(24,24,24,.08));
    transition: filter .15s ease, transform .15s ease;
}
.sidebar-brand .brand-logo:hover {
    filter: drop-shadow(0 1px 0 rgba(255,255,255,.6))
            drop-shadow(0 2px 3px rgba(24,24,24,.2))
            drop-shadow(0 5px 7px rgba(24,24,24,.1));
    transform: translateY(-1px);
}
.sidebar-brandsub { font-size: .78rem; color: var(--ink-soft); letter-spacing: .02em; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-link {
    display: flex; align-items: center; gap: 12px; position: relative;
    padding: 10px 12px; border-radius: 10px; color: var(--ink-soft);
    font-size: .9rem; text-decoration: none;
    transition: background .15s, color .15s;
}
.side-link:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.side-link.active { background: var(--cream-soft); color: var(--ink); font-weight: 600; }
.side-link.active::before {
    content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px;
    width: 3px; background: var(--gold); border-radius: 0 3px 3px 0;
}
.side-ico { width: 19px; height: 19px; flex: 0 0 19px; }

.sidebar-spacer { flex: 1 1 auto; min-height: 20px; }
.quick-book { width: 100%; margin: 12px 0 16px; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 6px 4px; border-top: 1px solid var(--line);
}
.side-user-info { flex: 1 1 auto; min-width: 0; }
.side-user-name { font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: .72rem; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-logout {
    display: inline-flex; padding: 8px; border-radius: 8px; color: var(--ink-soft);
    border: 1px solid var(--line-strong); flex: 0 0 auto;
}
.side-logout svg { width: 18px; height: 18px; }
.side-logout:hover { color: var(--red); border-color: var(--red); background: var(--red-bg); text-decoration: none; }

@media (max-width: 900px) {
    .app-sidebar { flex-direction: column; }
    .sidebar {
        position: static; height: auto; width: 100%; flex: none;
        flex-direction: column; border-right: none; border-bottom: 1px solid var(--line);
        padding: 16px 20px;
    }
    .sidebar-brand { border-bottom: none; margin-bottom: 12px; padding-bottom: 4px; }
    .side-nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .side-link.active::before { display: none; }
    .sidebar-spacer { display: none; }
    .quick-book { width: auto; margin: 12px 0 0; }
    .sidebar-user { border-top: none; padding: 12px 6px 0; }
    .content { padding: 24px 20px 48px; }
    .footer { padding: 20px; }
}

/* ---------- Flash ---------- */
.flashes { margin-bottom: 24px; }
.flash {
    padding: 14px 18px; border-radius: 0; margin-bottom: 10px;
    border: 1px solid transparent; font-size: .9rem;
}
.flash-success { background: var(--green-bg); color: var(--green-ink); border-color: #cfe0cf; }
.flash-danger  { background: var(--red-bg);   color: #8a1414;        border-color: #e8c9c9; }
.flash-warning { background: var(--cream-soft);color: #6a5c46;        border-color: var(--gold); }
.flash-info    { background: var(--paper);     color: var(--ink-soft);border-color: var(--line-strong); }

/* ---------- Forms / Buttons ---------- */
.form { display: flex; flex-direction: column; gap: 20px; }
.form label {
    display: flex; flex-direction: column; gap: 8px;
    font-family: var(--sans); text-transform: uppercase;
    letter-spacing: .09em; font-size: .72rem; font-weight: 600; color: var(--ink-soft);
}
.form input, .form select, .form textarea {
    padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 0;
    font-size: 1rem; font-family: var(--sans); background: var(--surface); color: var(--ink);
}
.form textarea { resize: vertical; }
.form input::placeholder, .form textarea::placeholder { color: #b7b2a6; }
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--ink);
    box-shadow: 0 1px 0 0 var(--ink);
}
.row { display: flex; gap: 20px; }
.row .col { flex: 1; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.required { color: var(--red); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 13px 28px; border-radius: 12px; border: 1px solid transparent;
    font-family: var(--sans); font-size: .82rem; font-weight: 600; letter-spacing: .06em;
    cursor: pointer; text-decoration: none;
    box-shadow: 0 3px 6px rgba(24,24,24,.18), inset 0 1px 0 rgba(255,255,255,.15);
    transition: transform .1s ease, box-shadow .15s ease, background .15s, color .15s, border-color .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 8px 18px rgba(24,24,24,.26), inset 0 1px 0 rgba(255,255,255,.2); }
.btn:active { transform: translateY(1px); box-shadow: 0 2px 4px rgba(24,24,24,.22); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover { background: #9a1414; }
.btn-ghost   { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: #fff; border-color: var(--gold); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 16px; font-size: .72rem; letter-spacing: .05em; border-radius: 9px; }

/* ---------- Cards (login / form) ---------- */
.login-card, .form-card {
    max-width: 540px; margin: 48px auto; background: var(--surface);
    border: 1px solid var(--line); border-radius: 0; padding: 48px;
    box-shadow: var(--shadow-soft);
}
.login-card h1, .form-card h1 { font-size: 2.6rem; }
.login-logo {
    height: 34px; width: auto; display: block; margin: 4px auto 22px;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,.55)) drop-shadow(0 2px 3px rgba(24,24,24,.16));
}
/* หน้า login: จัดส่วนหัวให้อยู่กึ่งกลาง + "Sign In" เล็กลง (ฟอร์มยังชิดซ้าย) */
.login-card > .eyebrow,
.login-card > h1,
.login-card > .subtitle { text-align: center; }
.login-card h1 { font-size: 2rem; }
.login-card .subtitle { margin-bottom: 32px; }

/* บล็อกการจองโทนอ่อน (สบายตา): ตัวอักษรเข้ม + เงานุ่มลง */
.agenda-event, .mini-event {
    color: #3a2f24;
    background-image: linear-gradient(to bottom, rgba(255,255,255,.38), rgba(255,255,255,0) 55%, rgba(0,0,0,.03));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.55),
                inset 0 -14px 22px rgba(0,0,0,.04),
                0 3px 10px rgba(24,24,24,.10);
}
.agenda-event .event-meta { opacity: .72; }
.mini-ev-time { color: rgba(58,47,36,.72); }
.agenda-event:hover {
    box-shadow: inset 0 1px 0 rgba(255,255,255,.65),
                inset 0 -14px 22px rgba(0,0,0,.05),
                0 10px 22px rgba(24,24,24,.16);
}
.subtitle { color: var(--ink-soft); margin: 6px 0 28px; font-size: .95rem; }

/* login: underline-only inputs (editorial) */
.login-card .form input,
.login-card .form select {
    border: none; border-bottom: 1px solid var(--line-strong); border-radius: 0;
    padding: 10px 2px; background: transparent;
}
.login-card .form input:focus,
.login-card .form select:focus { border-bottom-color: var(--ink); box-shadow: 0 1px 0 0 var(--ink); }
/* แสดง placeholder ของ select เป็นสีจาง จนกว่าจะเลือกจริง */
.login-card .form select:invalid { color: #b7b2a6; }

.admin-link {
    margin-top: 28px; text-align: center; font-size: .85rem;
    padding-top: 20px; border-top: 1px solid var(--line);
}
.admin-link a { color: var(--ink-soft); }
.admin-link a:hover { color: var(--ink); }

/* ---------- Page header ---------- */
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 20px; flex-wrap: wrap; margin-bottom: 28px;
    padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.page-header h1 { font-size: 2.4rem; margin-bottom: 0; }
.page-sub { color: var(--ink-soft); margin: 8px 0 0; font-size: .95rem; }
.date-picker { flex-wrap: wrap; }
.date-picker { display: flex; align-items: center; gap: 10px; }
.date-picker input[type=date],
.filter-bar input, .filter-bar select {
    padding: 9px 12px; border-radius: 0; border: 1px solid var(--line-strong);
    background: var(--surface); font-family: var(--sans); font-size: .9rem;
}

/* ---------- Schedule (Gantt) ---------- */
.schedule {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 0; overflow-x: auto;
}
.schedule-header, .schedule-row {
    display: grid; grid-template-columns: 240px 1fr;
    border-bottom: 1px solid var(--line);
    min-width: 940px;   /* กันคอลัมน์บีบ — จอแคบเลื่อนแนวนอนแทน */
}
.schedule-header {
    background: var(--paper); font-weight: 600; font-size: .7rem;
    text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft);
}
.schedule-header .room-col { padding: 16px; }

.time-axis {
    display: grid; grid-template-columns: repeat(10, 1fr);
    position: relative; border-left: 1px solid var(--line-strong);
}
.time-tick { position: relative; padding: 14px 0 14px 10px; border-right: 1px solid var(--line-strong); }
.time-tick:last-child { border-right: none; }
.tick-label { font-size: .7rem; color: var(--ink-faint); font-weight: 600; letter-spacing: .04em; }
.tick-end { position: absolute; right: 8px; top: 12px; font-size: .7rem; color: var(--ink-faint); font-weight: 600; letter-spacing: .04em; }

.timeline {
    position: relative; height: 108px; border-left: 1px solid var(--line-strong);
    background-color: var(--surface);
    /* เส้นแบ่งคอลัมน์ทุก 10% (10 ช่วงเวลา) — ให้เห็นแต่ละช่วงชัด */
    background-image: linear-gradient(to right, transparent calc(10% - 1px), var(--line-strong) calc(10% - 1px), var(--line-strong) 10%);
    background-size: 10% 100%;
}

.schedule-row .room-col {
    padding: 18px 16px; border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 5px;
}
.room-name { font-family: var(--serif); font-size: 1.15rem; font-weight: 400; }
.room-meta { font-size: .8rem; color: var(--ink-soft); }
.room-facility { font-size: .72rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }

/* booking block — cream with gold spine (matches design) */
.booking-bar {
    position: absolute; top: 10px; bottom: 10px;
    background: var(--cream); border-radius: 0;
    border-left: 3px solid var(--gold); color: var(--ink);
    padding: 6px 10px; overflow: hidden;
    display: flex; flex-direction: column; justify-content: center;
    font-size: .76rem; line-height: 1.3; cursor: default;
    transition: box-shadow .12s;
}
.booking-bar:hover { box-shadow: var(--shadow-soft); z-index: 5; }
.bar-time {
    font-weight: 600; font-size: .68rem; letter-spacing: .04em;
    text-transform: uppercase; color: #6a5c46;
    align-self: flex-start; margin-bottom: 2px; white-space: nowrap;
}
.bar-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-user  { color: var(--ink-soft); font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking-bar-narrow .bar-title, .booking-bar-narrow .bar-user { display: none; }
.booking-bar-narrow .bar-time { font-size: .64rem; }

.schedule-legend {
    display: flex; gap: 24px; flex-wrap: wrap; align-items: center;
    margin-top: 16px; padding: 4px 2px; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft);
}
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-bar { display: inline-block; width: 22px; height: 12px; border-radius: 0; background: var(--cream); border-left: 3px solid var(--gold); }
.legend-bar.legend-free { background: var(--surface); border: 1px solid var(--line-strong); }
.legend-bar.legend-maint { background: var(--red-bg); border-left: 3px solid var(--red); }

/* ---------- Agenda (ปฏิทินรายวันแนวตั้ง) ---------- */
.room-chips { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.chip {
    padding: 8px 18px; border: 1px solid var(--line-strong); border-radius: 999px;
    background: var(--surface); color: var(--ink-soft);
    font-family: var(--sans); font-size: .85rem; letter-spacing: .02em; cursor: pointer;
    box-shadow: 0 2px 4px rgba(24,24,24,.08), inset 0 1px 0 rgba(255,255,255,.6);
    transition: transform .1s ease, box-shadow .15s ease, color .15s, background .15s, border-color .15s;
}
.chip:hover { color: var(--ink); border-color: var(--gold); transform: translateY(-1px); box-shadow: 0 5px 12px rgba(24,24,24,.15); }
.chip-active, .chip-active:hover {
    background: var(--ink); color: #fff; border-color: var(--ink);
    box-shadow: 0 2px 6px rgba(24,24,24,.28);   /* เอาไฮไลต์ขาวออก เหลือเงานุ่ม */
    transform: none;
}
.agenda-book { margin-left: auto; }

.agenda {
    display: grid; grid-template-columns: 78px 1fr;
    border: 1px solid var(--line); background: var(--surface);
}
.agenda-head-gutter { background: var(--paper); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.agenda-daybar { background: var(--paper); border-bottom: 1px solid var(--line); padding: 14px 20px; text-align: center; }
.agenda-weekday { font-family: var(--serif); font-size: 1.35rem; color: var(--ink); line-height: 1.15; }
.agenda-date { font-size: .78rem; color: var(--ink-soft); letter-spacing: .06em; margin-top: 3px; }

.agenda-gutter {
    position: relative; border-right: 1px solid var(--line);
    background-image: linear-gradient(to bottom, var(--line-strong) 1px, transparent 1px);
    background-size: 100% 64px; background-position: 0 0;   /* เส้นชั่วโมงต่อเนื่อง (pad 16, ทุก 64px) */
}
.agenda-hourlabel {
    position: absolute; right: 12px; transform: translateY(-50%);
    font-size: .72rem; color: var(--ink-faint); font-weight: 600; letter-spacing: .03em;
    background: var(--surface); padding: 0 3px;
}
/* ป้ายแรก/ท้าย: จัดให้อยู่ในกรอบ (ไม่โผล่บน-ล่าง) ขณะที่เส้น/บล็อกชิดขอบ */
.agenda-hourlabel:first-child { transform: translateY(2px); }
.agenda-hourlabel:last-child  { transform: translateY(calc(-100% - 2px)); }
.agenda-col {
    position: relative;
    background-image: linear-gradient(to bottom, var(--line-strong) 1px, transparent 1px);
    background-size: 100% 64px; background-position: 0 0;   /* ตรงกับฝั่งเวลาเป๊ะ */
}

.agenda-event {
    position: absolute; left: 4px; right: 4px; box-sizing: border-box;
    background: var(--ink); color: #fff; border-radius: 8px; border-left: 3px solid var(--gold);
    padding: 6px 12px; overflow: hidden;
    box-shadow: 0 3px 8px rgba(24,24,24,.24);
    cursor: default; transition: transform .12s, box-shadow .12s;
}
.agenda-event:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(24,24,24,.3); z-index: 5; }
.event-title { font-weight: 600; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-meta { font-size: .7rem; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.agenda-hint { margin: 12px 2px 0; font-size: .78rem; }

/* ---------- หน้าจอง: 2 คอลัมน์ (ฟอร์ม + ตารางว่าง) ---------- */
.book-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; max-width: 1060px; margin: 0 auto; }
.book-wrap .form-card { max-width: none; margin: 0; }
.book-availability { background: var(--surface); border: 1px solid var(--line); padding: 20px; position: sticky; top: 20px; }
.book-availability h3 { margin: 0 0 4px; font-size: 1.05rem; }
.avail-room { margin: 0 0 14px; font-weight: 600; color: var(--ink); }
.avail-hint { margin: 12px 0 0; font-size: .74rem; }

.mini-agenda { display: grid; grid-template-columns: 52px 1fr; border: 1px solid var(--line); }
.mini-gutter {
    position: relative; border-right: 1px solid var(--line);
    background-image: linear-gradient(to bottom, var(--line-strong) 1px, transparent 1px);
    background-size: 100% 42px; background-position: 0 0;
}
.mini-hour {
    position: absolute; right: 6px; transform: translateY(-50%);
    font-size: .66rem; color: var(--ink-faint); font-weight: 600;
    background: var(--surface); padding: 0 2px;
}
.mini-hour:first-child { transform: translateY(1px); }
.mini-hour:last-child { transform: translateY(calc(-100% - 1px)); }
.mini-col {
    position: relative;
    background-image: linear-gradient(to bottom, var(--line-strong) 1px, transparent 1px);
    background-size: 100% 42px; background-position: 0 0;
}
.mini-empty {
    position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
    text-align: center; color: var(--ink-faint); font-size: .78rem; line-height: 1.6; padding: 0 8px;
}
.mini-event {
    position: absolute; left: 4px; right: 4px; box-sizing: border-box;
    background: var(--ink); color: #fff; border-left: 3px solid var(--gold); border-radius: 6px;
    padding: 3px 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(24,24,24,.22);
}
.mini-ev-time { display: block; font-size: .62rem; color: #d7c4a8; letter-spacing: .03em; }
.mini-ev-title { display: block; font-size: .7rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 820px) {
    .book-wrap { grid-template-columns: 1fr; }
    .book-availability { position: static; }
}

/* ============================================================
   Apple-style "Magic Move" — การเปลี่ยนหน้าแบบลื่นไหล
   (View Transitions API — Chrome/Edge; เบราว์เซอร์อื่นข้ามไปเฉยๆ)
   ============================================================ */
@view-transition { navigation: auto; }

/* เนื้อหาหลัก: จางออก+เลื่อนขึ้นเล็กน้อย แล้วหน้าใหม่เด้งเข้าแบบสปริง */
::view-transition-old(root) { animation: mm-out .30s cubic-bezier(.4, 0, .2, 1) both; }
::view-transition-new(root) { animation: mm-in  .44s cubic-bezier(.22, .9, .25, 1) both; }
@keyframes mm-out { to   { opacity: 0; transform: translateY(-6px) scale(.994); } }
@keyframes mm-in  { from { opacity: 0; transform: translateY(12px) scale(.988); } }

/* magic move: องค์ประกอบคงอยู่ (ทำงานเฉพาะเบราว์เซอร์ที่รองรับ cross-document VT) */
.sidebar { view-transition-name: mm-sidebar; }
.footer  { view-transition-name: mm-footer; }

/* เคารพผู้ที่ตั้งค่าลดการเคลื่อนไหว */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) { animation: none !important; }
}

/* ============================================================
   Apple-style softening — โค้งมน นุ่มนวล ไม่แข็ง (ทับค่ามุมคม 0px เดิม)
   ============================================================ */
.login-card, .form-card, .book-availability {
    border-radius: 18px;
    border-color: rgba(24,24,24,.07);
    box-shadow: 0 1px 3px rgba(24,24,24,.05), 0 14px 34px rgba(24,24,24,.07);
}
.stat-card, .filter-bar, .fieldset, .info-box, .empty {
    border-radius: 16px; border-color: rgba(24,24,24,.08);
}
.schedule, .agenda, .mini-agenda { border-radius: 16px; overflow: hidden; }
.data-table {
    border-radius: 14px; border-collapse: separate; border-spacing: 0; overflow: hidden;
    border-color: rgba(24,24,24,.08);
}

/* ช่องกรอก: มุมมน + โฟกัสเป็นวงนุ่มแบบ Apple */
.form input, .form select, .form textarea,
.date-picker input[type=date], .filter-bar input, .filter-bar select {
    border-radius: 11px;
}
.form input:focus, .form select:focus, .form textarea:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(24,24,24,.09);
}
.flash { border-radius: 13px; }

/* ปุ่ม: เงานุ่มฟุ้งแบบ Apple (คงมิติ แต่ไม่แข็ง) */
.btn {
    border-radius: 13px;
    box-shadow: 0 1px 2px rgba(24,24,24,.12), 0 6px 16px rgba(24,24,24,.11);
}
.btn:hover  { box-shadow: 0 2px 5px rgba(24,24,24,.14), 0 12px 26px rgba(24,24,24,.17); }
.btn:active { box-shadow: 0 1px 2px rgba(24,24,24,.16); }

/* ชิปเลือกห้อง + เมนู sidebar ให้มนนุ่มขึ้นอีกนิด */
.side-link { border-radius: 12px; }
.side-link.active::before { border-radius: 3px; }

/* ============================================================
   More Apple — กระจกฝ้า + สัมผัสสปริง + มุม iOS + เงาหลายชั้น
   ============================================================ */
:root { --spring: cubic-bezier(.34, 1.4, .5, 1); }

/* มุมมนขึ้นแบบ iOS */
.login-card, .form-card, .book-availability { border-radius: 22px;
    box-shadow: 0 1px 2px rgba(24,24,24,.04), 0 8px 20px rgba(24,24,24,.05), 0 26px 50px rgba(24,24,24,.07);
}
.stat-card, .filter-bar, .fieldset, .info-box, .empty,
.schedule, .agenda, .mini-agenda, .data-table { border-radius: 18px; }
.btn { border-radius: 14px; }
.flash { border-radius: 15px; }

/* Sidebar: วัสดุกระจกฝ้า (vibrancy) แบบ macOS */
.sidebar {
    background: rgba(250, 248, 243, 0.72);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    border-right: 1px solid rgba(24,24,24,.06);
}

/* สัมผัสสปริงแบบ iOS: กดแล้วยุบ แล้วเด้งกลับ */
.btn      { transition: transform .2s var(--spring), box-shadow .18s ease, background .15s, color .15s, border-color .15s; }
.side-link, .chip { transition: transform .2s var(--spring), box-shadow .18s ease, background .15s, color .15s, border-color .15s; }
.btn:active      { transform: scale(.96); }
.chip:active     { transform: scale(.95); }
.side-link:active { transform: scale(.975); }

/* การ์ดสถิติ: hover ลอยนุ่มแบบสปริง */
.stat-card { transition: transform .28s var(--spring), box-shadow .2s ease; }
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 2px 6px rgba(24,24,24,.05), 0 18px 42px rgba(24,24,24,.1); }

/* สีบล็อกการจอง: กำหนดเป็น hsl ตาม ID ห้อง (ใน template/JS) — ห้องใหม่ไม่ซ้ำสี */
.agenda-event .event-meta { opacity: .85; }
.mini-ev-time { color: rgba(255, 255, 255, .72); }

/* บล็อกการจอง: กระจก 3D เงาวาว + เด้งเข้าตอนโหลด (โมเดิร์น มีการเคลื่อนไหว) */
.agenda-event, .mini-event {
    background-image: linear-gradient(to bottom, rgba(255,255,255,.14), rgba(255,255,255,0) 45%, rgba(0,0,0,.06));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.22),
                inset 0 -16px 26px rgba(0,0,0,.16),
                0 4px 12px rgba(24,24,24,.22);
}
.agenda-event { animation: ev-in .55s var(--spring) both; }
.mini-event   { animation: ev-in .45s var(--spring) both; }
@keyframes ev-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.agenda-event:hover {
    transform: translateY(-3px) scale(1.006);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.28),
                inset 0 -16px 26px rgba(0,0,0,.18),
                0 12px 26px rgba(24,24,24,.32);
}
/* เหลื่อมเวลาเข้าแบบ cascade */
.agenda-col .agenda-event:nth-child(1) { animation-delay: .00s; }
.agenda-col .agenda-event:nth-child(2) { animation-delay: .05s; }
.agenda-col .agenda-event:nth-child(3) { animation-delay: .10s; }
.agenda-col .agenda-event:nth-child(4) { animation-delay: .15s; }
.agenda-col .agenda-event:nth-child(5) { animation-delay: .20s; }
.agenda-col .agenda-event:nth-child(6) { animation-delay: .25s; }
.agenda-col .agenda-event:nth-child(7) { animation-delay: .30s; }
.agenda-col .agenda-event:nth-child(8) { animation-delay: .35s; }
.agenda-col .agenda-event:nth-child(n+9) { animation-delay: .4s; }

@media (prefers-reduced-motion: reduce) {
    .agenda-event, .mini-event { animation: none; }
}

/* หัวข้อทั้งหมดใช้ฟอนต์เดียวกับเมนู (Google Sans) — เลิกใช้ serif */
h1, h2, h3, .page-header h1, .login-card h1, .form-card h1,
.brand-title, .footer-brand, .stat-value, .agenda-weekday, .room-name {
    font-family: var(--sans);
    font-weight: 600;
    letter-spacing: -0.015em;
}

/* หัวข้อใหญ่: ให้มีมิติ 3D + ไล่เฉดอุ่นๆ สวยหรูขึ้น */
h1, .page-header h1, .login-card h1, .form-card h1 {
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.08;
    background: linear-gradient(172deg, #4a4139 0%, #1c1a17 52%, #2c2018 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,.55))
            drop-shadow(0 2px 3px rgba(24,24,24,.16))
            drop-shadow(0 6px 10px rgba(24,24,24,.08));
}

/* ---------- Table ---------- */
.data-table {
    width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--line); border-radius: 0;
}
.data-table th, .data-table td {
    text-align: left; padding: 16px 18px; border-bottom: 1px solid var(--line);
    font-size: .9rem;
}
.data-table th {
    background: var(--paper); color: var(--ink-soft); font-weight: 600;
    text-transform: uppercase; letter-spacing: .07em; font-size: .7rem;
}
.data-table tr:last-child td { border-bottom: 0; }
.row-muted { color: var(--ink-faint); }
.empty {
    background: var(--surface); border: 1px solid var(--line); padding: 48px 20px;
    border-radius: 0; text-align: center; color: var(--ink-faint);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 0;
    font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
}
.badge-success { background: var(--cream); color: #6a5c46; }
.badge-muted   { background: #ececea; color: var(--ink-soft); }

/* ---------- Stat / KPI ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin: 20px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 24px; }
.stat-label { color: var(--ink-soft); font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; }
.stat-value { font-family: var(--serif); font-size: 2.8rem; font-weight: 400; color: var(--ink); margin-top: 6px; line-height: 1; }

.bar-track { background: var(--line); height: 6px; border-radius: 0; overflow: hidden; min-width: 120px; }
.bar-fill     { height: 100%; background: var(--ink); }
.bar-fill-alt { background: var(--gold); }
.muted { color: var(--ink-faint); font-weight: 400; font-size: .85rem; }

/* ---------- Admin accents ---------- */
.topbar-admin { background: var(--paper); border-bottom: 2px solid var(--ink); }
.login-admin h1 { color: var(--ink); }
.login-admin .eyebrow { color: var(--red); }

/* ---------- Filter bar / layout ---------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 16px; align-items: end;
    background: var(--surface); border: 1px solid var(--line); padding: 18px 20px;
    border-radius: 0; margin-bottom: 24px;
}
.filter-bar label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: .72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .08em; color: var(--ink-soft);
}
.actions-cell { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 24px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.fieldset { border: 1px solid var(--line); border-radius: 0; padding: 16px 20px 20px; margin: 0; }
.fieldset legend {
    padding: 0 8px; font-family: var(--sans); font-weight: 600; color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: .08em; font-size: .72rem;
}
.info-box {
    background: var(--cream-soft); border: 1px solid var(--gold); color: #6a5c46;
    padding: 16px 20px; border-radius: 0;
}
.info-box ul { margin: 8px 0 0 18px; padding: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .container { padding: 0 20px; }
    .content { padding: 28px 20px 56px; }
    .login-card, .form-card { padding: 32px 24px; margin: 24px auto; }
    h1, .page-header h1, .login-card h1 { font-size: 2rem; }
    .schedule-header, .schedule-row { grid-template-columns: 150px 1fr; }
    .topbar-inner { gap: 12px; flex-wrap: wrap; }
    .brand, .nav, .user-box { flex: 1 1 100%; justify-content: flex-start; }
    .nav { gap: 8px; }
}

/* ===== บล็อกการจองโทนอ่อน: ตัวอักษรเข้ม + เงานุ่ม (วางท้ายสุดให้ชนะทุกกฎ) ===== */
.agenda-event, .mini-event {
    color: #3a2f24;
    background-image: linear-gradient(to bottom, rgba(255,255,255,.40), rgba(255,255,255,0) 55%, rgba(0,0,0,.03));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.55),
                inset 0 -14px 22px rgba(0,0,0,.04),
                0 3px 10px rgba(24,24,24,.10);
}
.agenda-event .event-title, .agenda-event .event-meta,
.mini-ev-title { color: #3a2f24; }
.agenda-event .event-meta { opacity: .72; }
.mini-ev-time { color: rgba(58,47,36,.72); }
.agenda-event:hover {
    box-shadow: inset 0 1px 0 rgba(255,255,255,.65),
                inset 0 -14px 22px rgba(0,0,0,.05),
                0 10px 22px rgba(24,24,24,.16);
}

/* login: smaller "Sign In" + subtitle wraps within the card (placed last to win) */
.login-card h1 { font-size: 1.55rem; line-height: 1.2; }
.login-card .subtitle {
    font-size: .85rem; margin-bottom: 28px;
    overflow-wrap: break-word; word-break: break-word;
    max-width: 100%; padding: 0 4px;
}

/* booking blocks: emphasized outline (placed last to win) */
.agenda-event, .mini-event {
    border: 1.5px solid rgba(58,47,36,.34);
    border-left-width: 4px;
}

/* dark booking blocks: white text + light outline (placed last to win) */
.agenda-event, .mini-event { color: #fff; border-color: rgba(255,255,255,.28); }
.agenda-event .event-title, .agenda-event .event-meta, .mini-ev-title { color: #fff; }
.agenda-event .event-meta { opacity: .85; }
.mini-ev-time { color: rgba(255,255,255,.75); }

/* remove gloss gradient -> solid color blocks (placed last) */
.agenda-event, .mini-event { background-image: none; }

/* ===== Reliable page transition: content slides+fades in on every load ===== */
@keyframes page-enter {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.content { animation: page-enter .5s cubic-bezier(.22, .9, .25, 1) both; }
@media (prefers-reduced-motion: reduce) { .content { animation: none; } }

/* DD/MM/YYYY overlay for native date inputs (hide native text, keep picker icon) */
.date-dmy { position: relative; display: block; }
.date-picker .date-dmy, .filter-bar .date-dmy { display: inline-block; }
.date-dmy > input[type="date"] { color: transparent; }
.date-dmy > input[type="date"]::-webkit-datetime-edit { color: transparent; }
.date-dmy-overlay {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    pointer-events: none; font-family: var(--sans); font-size: .95rem;
    color: var(--ink); white-space: nowrap;
}
.date-dmy-overlay.is-empty { color: #b7b2a6; }

/* stat numbers: use Google Sans like the rest (placed last to win over serif base) */
.stat-value { font-family: var(--sans); font-weight: 600; letter-spacing: -0.01em; }

/* fix: keep inputs/fieldset from overflowing the card (flex + fieldset min-width) */
.form input, .form select, .form textarea { width: 100%; min-width: 0; }
.row { min-width: 0; }
.row .col { min-width: 0; }
.fieldset { min-width: 0; }

/* Filter bar: keep every control on a single row */
.filter-bar { flex-wrap: nowrap; gap: 12px; align-items: end; overflow-x: auto; }
.filter-bar label { min-width: 0; }
.filter-bar select { min-width: 84px; }
.filter-bar .date-dmy > input[type="date"] { width: 146px; min-width: 146px; }
.filter-bar .date-dmy-overlay { font-size: .8rem; left: 12px; }
.filter-bar .btn { flex: 0 0 auto; align-self: end; white-space: nowrap; }

/* ===== Mobile/tablet: wide tables scroll inside their own box (page never breaks) ===== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; }
.table-scroll .data-table { min-width: 680px; }
@media (max-width: 900px) {
    /* filter bar: ตกบรรทัดบนจอเล็ก/ไอแพดแทนการเลื่อนแนวนอน (ใช้ง่ายกว่า) */
    .filter-bar { flex-wrap: wrap; overflow-x: visible; }
    .filter-bar .btn { align-self: end; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-header .btn { flex: 0 0 auto; }
    /* กันหน้าเลื่อนแนวนอนเด็ดขาด — ตารางกว้างให้เลื่อนในกล่อง .table-scroll เท่านั้น
       (ที่ ≤900 sidebar เป็น static แล้ว จึงใส่ที่ body ได้โดยไม่กระทบ sticky sidebar เดสก์ท็อป) */
    html, body { overflow-x: hidden; }
    .content { overflow-x: hidden; }
}

/* Phone (≤560): filter fields stack full-width — เรียงสวย ไม่ถูกตัดขอบ */
@media (max-width: 560px) {
    .filter-bar label { flex: 1 1 100%; }
    .filter-bar .date-dmy { display: block; width: 100%; }
    .filter-bar .date-dmy > input[type="date"],
    .filter-bar select { width: 100%; min-width: 0; }
    .date-picker { flex-wrap: wrap; }
}
