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

:root {
    --brand: #f97316;
    --brand-2: #fb923c;
    --brand-grad: linear-gradient(135deg, #ff9a3c, #f4611a);
    --ink: #1e2538;
    --muted: #6b7280;
    --bg: #f5f6fb;
    --line: #eaecf3;
    --radius: 16px;
    --shadow: 0 4px 24px rgba(31, 41, 55, .06);
    --shadow-hover: 0 12px 32px rgba(249, 115, 22, .16);
    --side: #241a12;
    --side-2: #30241a;
}

* { -webkit-font-smoothing: antialiased; }
body { background: linear-gradient(125deg, #fff2e6 0%, #ffe2cc 28%, #fbe6ff 62%, #e6eeff 100%) fixed; color: var(--ink); font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif; min-height: 100vh; }
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
a { text-decoration: none; }
.text-muted { color: var(--muted) !important; }

/* แถบบนมือถือ */
.app-navbar { background: var(--side); }
.app-navbar .navbar-brand { color: #fff; font-weight: 600; }

/* ===== Sidebar (ธีมมืด) ===== */
.app-shell { min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, rgba(33,26,18,.86), rgba(48,36,26,.86)); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); color: #e8ddd2; }
@media (min-width: 768px) { .sidebar { width: 256px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
.sidebar-brand { display: block; font-weight: 700; font-size: 1.2rem; color: #fff; padding: 1rem .9rem .4rem; letter-spacing: -.02em; }
.sidebar .group-label { font-size: .68rem; color: #6b7299; font-weight: 700; letter-spacing: .08em; margin: 1rem .85rem .35rem; text-transform: uppercase; }
.sidebar .group-sub { font-size: .76rem; color: #565d86; margin: .55rem .85rem .15rem; }
.sidebar .nav-link { color: #c2c8e0; border-radius: 12px; padding: .55rem .8rem; margin: 1px .3rem; font-size: .92rem; transition: all .15s ease; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar .nav-link.active { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px rgba(249, 115, 22, .42); }
.sidebar .border-top { border-color: rgba(255, 255, 255, .08) !important; }
.sidebar .text-muted { color: #8b91b5 !important; }
.sidebar .text-danger { color: #fca5a5 !important; }

.content { padding: 1.6rem 1.4rem 2.5rem; }
@media (min-width: 768px) { .content { padding: 2rem 2.4rem 3rem; } }

/* ===== Cards ===== */
.card { background: rgba(255,255,255,.62); backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5); border: 1px solid rgba(255,255,255,.6); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(120,80,40,.10); transition: box-shadow .18s ease, transform .18s ease; }
.card.shadow-sm { box-shadow: 0 8px 32px rgba(120,80,40,.10) !important; }
.card .card-header, .card .table-light, .card .table-light > * { background: rgba(255,255,255,.45) !important; }
.card:hover { box-shadow: var(--shadow-hover); }
.card-footer, .card-header { background: transparent; border-color: var(--line); }

/* ===== Buttons ===== */
.btn { border-radius: 10px; font-weight: 500; transition: all .15s ease; }
.btn-warning { background: var(--brand-grad); border: none; color: #fff; box-shadow: 0 4px 14px rgba(249, 115, 22, .3); }
.btn-warning:hover, .btn-warning:focus { filter: brightness(1.07); color: #fff; box-shadow: 0 7px 20px rgba(249, 115, 22, .42); }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: #ea580c; border-color: #ea580c; }
.btn-outline-primary { color: var(--brand); border-color: #fdba74; }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-outline-secondary { color: #5b6273; border-color: #dfe2ec; }
.btn-outline-secondary:hover { background: #5b6273; border-color: #5b6273; }
.btn-outline-dark { border-color: #d2d6e0; color: #2a3142; }
.btn-success { background: #10b981; border-color: #10b981; }
.btn-success:hover { background: #0ea271; border-color: #0ea271; }

/* ===== Tables ===== */
.table { --bs-table-bg: transparent; }
.table thead th, .table-light, .table-light > th, .table-light > td { background: #f7f8fd !important; color: #707890; font-weight: 600; }
.table > :not(caption) > * > * { border-color: var(--line); }
.table-hover > tbody > tr:hover > * { background: #f7f8ff; }
tfoot.table-light th { color: var(--ink); }

/* ===== Forms ===== */
.form-control, .form-select { border-radius: 10px; border-color: #e3e6ef; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(249, 115, 22, .15); }
.form-label { font-weight: 500; font-size: .9rem; color: #4b5263; }
.required::after { content: " *"; color: #ef4444; }

/* ===== Badges & alerts ===== */
.badge { font-weight: 500; padding: .42em .7em; border-radius: 8px; }
.alert { border-radius: 13px; border: none; }
.alert-info { background: #eef2ff; color: #3730a3; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-danger { background: #fef2f2; color: #991b1b; }
.alert-light { background: #fff; border: 1px solid var(--line); }

/* ===== Stat chip (แดชบอร์ด) ===== */
.stat-card .card-body { display: flex; align-items: center; gap: .9rem; }
.stat-chip { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px rgba(249, 115, 22, .28); }
.stat-chip.green { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: 0 6px 16px rgba(16, 185, 129, .28); }
.stat-chip.red { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: 0 6px 16px rgba(239, 68, 68, .28); }
.stat-chip.amber { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 6px 16px rgba(245, 158, 11, .28); }
.stat-card .num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-card .lbl { font-size: .82rem; color: var(--muted); }

/* ===== ผังห้อง ===== */
.floor-title { border-left: 4px solid var(--brand); padding-left: .75rem; font-weight: 600; margin: 1.5rem 0 .9rem; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 1rem; }
.room-card { border-radius: 14px; padding: 1.15rem .5rem; text-align: center; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); transition: all .15s ease; }
.room-card .no { font-weight: 700; font-size: 1.15rem; }
.room-card .st { font-size: .82rem; margin-top: .35rem; color: var(--muted); }
.room-card.clickable { cursor: pointer; }
.room-card.clickable:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: #fdba74; }
.room-card.occupied { background: linear-gradient(135deg, #ecfdf5, #fff); border-color: #a7f3d0; }
.room-card.occupied .st { color: #059669; font-weight: 600; }
.room-card.reserved { background: linear-gradient(135deg, #fffbeb, #fff); border-color: #fde68a; }
.room-card.reserved .st { color: #b45309; font-weight: 600; }
.room-card.maint { background: linear-gradient(135deg, #fef2f2, #fff); border-color: #fecaca; }

/* ===== Stepper (สร้างหอพัก) ===== */
.stepper { display: flex; justify-content: center; gap: 1rem; margin: 1.5rem 0; }
.stepper .step { display: flex; align-items: center; gap: .5rem; padding: .5rem 1.25rem; border: 2px solid var(--line); border-radius: 2rem; color: #9aa3af; background: #fff; font-weight: 600; }
.stepper .step.active { border-color: var(--brand); color: var(--brand); }
.stepper .step .num { width: 1.7rem; height: 1.7rem; border-radius: 50%; background: #dee2e6; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.stepper .step.active .num { background: var(--brand-grad); }

#map { height: 320px; border-radius: 12px; border: 1px solid var(--line); }
.rate-table input { max-width: 120px; }

/* ===== พิมพ์บิล/สัญญา ===== */
@media print {
    .app-navbar, .sidebar, footer, .no-print { display: none !important; }
    .content { padding: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none !important; border: 1px solid #ddd; }
}
