/* =====================================================================
   Room Management System — Design System (single stylesheet for all pages)
   ---------------------------------------------------------------------
   1. Tokens (light + dark)        6. Tables (responsive → cards on phone)
   2. Base / typography            7. Badges, alerts, stats, progress
   3. App shell (sidebar, topbar,  8. Page-specific: entry, capacity matrix,
      bottom nav, more sheet)         dashboard, reports, login
   4. Layout: page, cards, grids   9. Modal / bottom sheet
   5. Forms & buttons             10. Motion + breakpoints
   Breakpoints: phone < 768 | tablet 768–1023 (icon rail) | desktop ≥ 1024
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
/* Accent palette: 3 registered colours (so changes fade smoothly). js/accent.js sets
   <html data-accent="indigo|orange|emerald|rose|ocean|grape"> — fixed choice or auto (changes every minute).
   Every brand colour below is derived from --c1/--c2/--c3. */
@property --c1 { syntax: "<color>"; inherits: true; initial-value: #4f46e5; }
@property --c2 { syntax: "<color>"; inherits: true; initial-value: #7c3aed; }
@property --c3 { syntax: "<color>"; inherits: true; initial-value: #06b6d4; }

:root[data-accent="orange"]  { --c1: #ea580c; --c2: #f43f5e; --c3: #f59e0b; }
:root[data-accent="emerald"] { --c1: #059669; --c2: #0d9488; --c3: #22d3ee; }
:root[data-accent="rose"]    { --c1: #e11d48; --c2: #c026d3; --c3: #f97316; }
:root[data-accent="ocean"]   { --c1: #2563eb; --c2: #0284c7; --c3: #06b6d4; }
:root[data-accent="grape"]   { --c1: #7c3aed; --c2: #c026d3; --c3: #ec4899; }

:root {
    --c1: #4f46e5;
    --c2: #7c3aed;
    --c3: #06b6d4;
    transition: --c1 1.2s ease, --c2 1.2s ease, --c3 1.2s ease;

    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e5e7eb;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-2: #475569;
    --muted: #94a3b8;

    --primary: var(--c1);
    --primary-hover: color-mix(in srgb, var(--c1) 85%, #000);
    --primary-soft: color-mix(in srgb, var(--c1) 8%, #fff);
    --primary-text: color-mix(in srgb, var(--c1) 85%, #000);
    --primary-glow: color-mix(in srgb, var(--c1) 60%, transparent);
    --accent: var(--c3);
    --brand-gradient: linear-gradient(135deg, var(--c1) 0%, var(--c2) 55%, var(--c3) 100%);

    --success: #10b981;
    --success-soft: #ecfdf5;
    --success-text: #047857;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --danger-text: #b91c1c;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --warning-text: #b45309;

    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: color-mix(in srgb, var(--c1) 22%, transparent);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 20px 50px -20px rgba(15, 23, 42, 0.35);
    --ring: 0 0 0 4px color-mix(in srgb, var(--c1) 16%, transparent);

    --sidebar-w: 256px;
    --rail-w: 76px;
    --topbar-h: 64px;
    --bottomnav-h: 68px;
    --gutter: 16px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --surface-3: #1e293b;
    --border: #1f2937;
    --border-strong: #334155;
    --text: #e5e7eb;
    --text-2: #9ca3af;
    --muted: #64748b;
    --primary: color-mix(in srgb, var(--c1) 88%, #fff);
    --primary-hover: color-mix(in srgb, var(--c1) 70%, #fff);
    --primary-soft: color-mix(in srgb, var(--c1) 14%, transparent);
    --primary-text: color-mix(in srgb, var(--c1) 50%, #fff);
    --success-soft: rgba(16, 185, 129, 0.12);
    --success-text: #34d399;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --danger-text: #f87171;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --warning-text: #fbbf24;
    --sidebar-bg: #070b16;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --ring: 0 0 0 4px color-mix(in srgb, var(--c1) 28%, transparent);
    color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: opacity 0.25s var(--ease);
}

/* Hidden until common.js has built the shell (prevents layout flash) */
body.app:not(.shell-ready) { opacity: 0; }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
small { font-size: 12px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.hidden, [hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Role visibility (body gets role-admin / role-user from common.js) */
body.role-user .admin-only,
body.role-admin .user-only { display: none !important; }

/* ---------- 3. App shell ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 22px;
    color: #fff;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--brand-gradient);
    display: grid;
    place-items: center;
    box-shadow: 0 8px 20px -6px var(--primary-glow);
    flex: none;
}

.brand-logo svg.icon { width: 22px; height: 22px; color: #fff; }
.brand-name { font-weight: 750; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 11px; color: var(--sidebar-text); letter-spacing: 0.06em; text-transform: uppercase; }

.nav-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 14px 12px 6px;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.side-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 550;
    font-size: 14px;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.side-nav a:hover { background: rgba(255, 255, 255, 0.05); color: #e2e8f0; }

.side-nav a.active { background: var(--sidebar-active); color: #fff; }

.side-nav a.active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--brand-gradient);
}

.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-top: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    background: var(--brand-gradient);
    flex: none;
}

.side-user-info { min-width: 0; flex: 1; }
.side-user-name { color: #f1f5f9; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: 11px; color: var(--sidebar-text); }

.icon-button {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s;
    flex: none;
}

.icon-button:hover { color: var(--text); background: var(--surface-3); }
.icon-button:active { transform: scale(0.96); }
.sidebar .icon-button { background: transparent; border-color: rgba(255, 255, 255, 0.08); color: var(--sidebar-text); }
.sidebar .icon-button:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.shell-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 28px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-title { font-weight: 650; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-brand { display: none; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar-brand .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
.topbar-brand .brand-name { color: var(--text); font-size: 15px; }

.clock-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 550;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.clock-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    animation: pulse 2s infinite;
}

.clock-chip .clock-time { color: var(--text); font-weight: 700; }

.bottom-nav { display: none; }
.more-sheet { display: none; }

/* ---------- 4. Layout ---------- */
.page {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 28px 48px;
    animation: rise 0.45s var(--ease) both;
}

.page.narrow { max-width: 880px; }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.eyebrow {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-text);
    margin-bottom: 6px;
}

.subtitle { color: var(--text-2); margin-top: 6px; font-size: 14px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    animation: rise 0.5s var(--ease) both;
}

.card + .card { animation-delay: 0.05s; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.card-header .card-title { display: flex; align-items: center; gap: 10px; }

.card-header .card-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.card-header .card-icon svg.icon { width: 18px; height: 18px; }
.card-header p { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card-body { padding: 22px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- 5. Forms & buttons ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label, .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }

.form-grid { display: grid; gap: 16px; align-items: end; }
.form-grid.cols-3 { grid-template-columns: 2fr 1fr auto; }
.form-grid.cols-5 { grid-template-columns: 1.2fr 1.2fr 0.8fr 1.2fr auto; }
.form-grid.cols-2 { grid-template-columns: 1fr auto; }
.form-grid.filters { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="month"], select, .input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

select {
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

input:hover, select:hover { border-color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input:disabled, select:disabled { opacity: 0.6; cursor: not-allowed; }
input[readonly] { background: var(--surface-3); }
input::placeholder { color: var(--muted); }
input[type="number"] { font-variant-numeric: tabular-nums; }

.btn, .save-button, .primary-button, .secondary-button, .report-download-btn, .report-preview-btn,
.action-button, .action-btn, #addPersonButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s var(--ease), border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.08s;
    user-select: none;
}

.btn:active:not(:disabled), .save-button:active:not(:disabled), .primary-button:active:not(:disabled),
.action-button:active:not(:disabled), .action-btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }

.btn-primary, .save-button, .primary-button, .report-download-btn, #addPersonButton {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 6px 16px -8px var(--primary-glow);
}

.btn-primary:hover:not(:disabled), .save-button:hover:not(:disabled), .primary-button:hover:not(:disabled),
.report-download-btn:hover:not(:disabled), #addPersonButton:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary, .secondary-button, .report-preview-btn {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled), .secondary-button:hover:not(:disabled), .report-preview-btn:hover:not(:disabled) {
    background: var(--surface-3);
}

.btn-block, .save-button { width: 100%; }
.btn:disabled, .save-button:disabled, .primary-button:disabled, .secondary-button:disabled,
.report-download-btn:disabled, .report-preview-btn:disabled, .action-button:disabled, .action-btn:disabled, #addPersonButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Small table action buttons (created by JS) */
.action-button, .action-btn {
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
    margin: 2px 6px 2px 0;
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

.action-button:hover:not(:disabled), .action-btn:hover:not(:disabled) { background: var(--surface-3); }
.action-button.edit, .action-btn:not(.danger):not(.enable) { color: var(--primary-text); }
.action-button.disable, .action-btn.danger { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.action-button.disable:hover:not(:disabled), .action-btn.danger:hover:not(:disabled) { background: var(--danger-soft); }
.action-button.enable, .action-btn.enable { color: var(--success-text); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.action-button.enable:hover:not(:disabled), .action-btn.enable:hover:not(:disabled) { background: var(--success-soft); }

.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }

/* Stepper ( − [ n ] + ) used on Daily Entry */
.stepper {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stepper:focus-within { border-color: var(--primary); box-shadow: var(--ring); }

.stepper button {
    width: 44px;
    border: 0;
    background: var(--surface-3);
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.stepper button:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary-text); }
.stepper button:disabled { color: var(--muted); cursor: not-allowed; }

.stepper input {
    width: 64px;
    height: 46px;
    border: 0;
    border-radius: 0;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    padding: 0 4px;
    -moz-appearance: textfield;
}

.stepper input:focus { box-shadow: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- 6. Tables ---------- */
.table-wrap, .table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-2);
    background: var(--surface-2);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td[colspan] { text-align: center; color: var(--text-2); padding: 36px 16px; }
.table .num, .table td.right, .table th.right { text-align: right; font-variant-numeric: tabular-nums; }

.room-price { display: block; color: var(--muted); font-size: 12px; font-weight: 500; margin-top: 2px; }

/* ---------- 7. Badges, alerts, stats ---------- */
.badge, .status-label, .status, .role-badge, .count-label, .readonly-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--text-2);
}

.status-label::before, .status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-label.active, .status.active, .badge.success { background: var(--success-soft); color: var(--success-text); }
.status-label.inactive, .status.inactive, .badge.danger { background: var(--danger-soft); color: var(--danger-text); }
.badge.warning, .readonly-label { background: var(--warning-soft); color: var(--warning-text); }
.role-badge.admin, .badge.primary { background: var(--primary-soft); color: var(--primary-text); }
.role-badge.user { background: color-mix(in srgb, var(--accent) 14%, transparent); color: #0e7490; }
:root[data-theme="dark"] .role-badge.user { color: #67e8f9; }

.message {
    display: none;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 12px;
    margin-top: 16px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
}

.message.success, .message.error { display: flex; animation: slideIn 0.35s var(--ease) both; }
.message.success { background: var(--success-soft); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.message.error { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

.stat {
    position: relative;
    padding: 16px 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: rise 0.45s var(--ease) both;
}

.stat-label { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.stat-value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

.stat.kpi { box-shadow: var(--shadow); }
.stat.kpi .kpi-icon {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.stat.kpi.success .kpi-icon { background: var(--success-soft); color: var(--success-text); }
.stat.kpi.warning .kpi-icon { background: var(--warning-soft); color: var(--warning-text); }
.stat.kpi.accent .kpi-icon { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand-gradient); transition: width 0.6s var(--ease); }
.progress.full > span { background: var(--danger); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-2);
}

.empty-state .empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--surface-3);
    color: var(--muted);
}

.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }

.total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary-text);
    font-weight: 600;
}

.total-bar strong { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- 8a. Daily Entry ---------- */
.header-stat {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px 8px;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-text);
    border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}
.header-stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary); color: #fff; }
.header-stat-icon svg.icon { width: 19px; height: 19px; }
.header-stat strong { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.header-stat span:not(.header-stat-icon) { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }

.room-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.room-chip {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.room-chip::before { content: "#"; color: var(--muted); margin-right: 2px; font-weight: 600; }

.entry-list { display: flex; flex-direction: column; }

.entry-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) auto auto auto;
    align-items: center;
    gap: 18px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    animation: rise 0.4s var(--ease) both;
}

.entry-row:last-child { border-bottom: 0; }
.entry-row:hover { background: var(--surface-2); }
.entry-row.changed { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.entry-room strong { font-size: 15px; }

.entry-figure { text-align: center; min-width: 72px; }
.entry-figure .label { display: block; font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.entry-figure .value { font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; }
.allocated-quantity .value { color: var(--primary-text); }

.entry-head {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) auto auto auto;
    gap: 18px;
    padding: 10px 22px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-2);
}

.entry-head span:not(:first-child) { text-align: center; min-width: 72px; }
.entry-head span:last-child { min-width: 156px; }

.room-stat .stat-value { font-size: 26px; }
.room-stat .remaining-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.room-stat.sold-out .stat-value { color: var(--danger-text); }

.save-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.save-bar .save-total { flex: 1; }
.save-bar .save-total span { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; }
.save-bar .save-total strong { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.save-bar .save-button { width: auto; min-width: 220px; }

.own-person {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 14px;
    border-radius: 10px;
    background: var(--surface-3);
    font-weight: 650;
}

/* ---------- 8b. Capacity matrix ---------- */
.allocation-matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }

.allocation-matrix th, .allocation-matrix td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.allocation-matrix tr > :last-child { border-right: 0; }

.allocation-matrix thead th {
    background: var(--surface-2);
    font-size: 14px;
    min-width: 120px;
    position: sticky;
    top: 0;
    z-index: 2;
}

.allocation-matrix thead th strong { display: block; }

/* Sticky first column so names stay visible while scrolling sideways */
.allocation-matrix tr > :first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
    min-width: 150px;
    box-shadow: 1px 0 0 var(--border);
}

.allocation-matrix thead tr > :first-child { z-index: 3; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); }
.allocation-matrix tbody th { background: var(--surface); }
.allocation-matrix .used-row td, .allocation-matrix .used-row th { color: var(--text-2); background: var(--surface-2); }
.allocation-matrix .capacity-row th, .allocation-matrix .capacity-row td { background: var(--primary-soft); }
.allocation-matrix .capacity-row th { color: var(--primary-text); }

.allocation-matrix .matrix-label td {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: var(--surface);
    padding-top: 16px;
}

.allocation-matrix input {
    width: 84px;
    height: 40px;
    text-align: center;
    font-weight: 700;
    padding: 0 6px;
}

.allocation-matrix .capacity-input { border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.allocation-matrix .person-used { display: block; margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--warning-text); }

.allocation-matrix tfoot th, .allocation-matrix tfoot td { border-bottom: 0; background: var(--surface-2); }
.allocation-status { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; transition: background 0.25s, color 0.25s; }
.allocation-status.ok { background: var(--success-soft) !important; color: var(--success-text); }
.allocation-status.bad { background: var(--danger-soft) !important; color: var(--danger-text); }
.allocation-status.idle { color: var(--muted); }

/* ---------- 8c. Dashboard ---------- */
.hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    padding: 28px;
    color: #fff;
    background: var(--brand-gradient);
    box-shadow: var(--shadow-lg);
    margin-bottom: 22px;
    animation: rise 0.45s var(--ease) both;
}

.hero::after {
    content: "";
    position: absolute;
    right: -80px;
    top: -80px;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.hero::before {
    content: "";
    position: absolute;
    right: 120px;
    bottom: -120px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.hero-inner { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.hero h1 { font-size: 26px; }
.hero p { color: rgba(255, 255, 255, 0.82); margin-top: 6px; }
.hero-clock { text-align: right; }
.hero-clock .time { font-size: 44px; font-weight: 800; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; line-height: 1; }
.hero-clock .date { font-size: 14px; color: rgba(255, 255, 255, 0.85); margin-top: 8px; font-weight: 550; }
.hero .hero-note { font-size: 12px; color: rgba(255, 255, 255, 0.75); margin-top: 10px; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

.module {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s;
    animation: rise 0.5s var(--ease) both;
}

.module:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }

.module-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #fff;
}

.module-icon svg.icon { width: 22px; height: 22px; }
.module p { color: var(--text-2); font-size: 13px; flex: 1; }
.module .go { font-size: 13px; font-weight: 650; color: var(--primary-text); display: inline-flex; align-items: center; gap: 4px; }
.module:hover .go svg { transform: translateX(3px); }
.module .go svg { width: 16px; height: 16px; transition: transform 0.2s var(--ease); }

.tone-indigo { background: linear-gradient(135deg, color-mix(in srgb, var(--c1) 75%, #fff), var(--c1)); }
.tone-violet { background: linear-gradient(135deg, color-mix(in srgb, var(--c2) 65%, #fff), var(--c2)); }
.tone-cyan { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.tone-emerald { background: linear-gradient(135deg, #34d399, #059669); }
.tone-amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.tone-rose { background: linear-gradient(135deg, #fb7185, #e11d48); }
.tone-slate { background: linear-gradient(135deg, #94a3b8, #475569); }

/* ---------- 8d. Reports ---------- */
.report-card { display: flex; flex-direction: column; gap: 14px; }
.report-card .card-body { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.report-card .card-body > p { color: var(--text-2); font-size: 14px; }
.report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }

.preview-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }

.preview-table th, .preview-table td {
    padding: 9px 14px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.preview-table tr > :first-child { text-align: left; position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--border); font-weight: 600; }
.preview-table thead th { background: var(--surface-2); color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; z-index: 2; }
.preview-table thead tr > :first-child { z-index: 3; }
.preview-table tbody tr:hover td { background: var(--surface-2); }
.preview-table tfoot th { background: var(--primary-soft); color: var(--primary-text); font-weight: 800; border-bottom: 0; }
.preview-table tr.empty-row td { color: var(--muted); opacity: 0.45; font-weight: 400; }
.preview-table tr.empty-row:hover td { opacity: 0.8; }
.preview-table tr.used-row td { color: var(--text); font-weight: 700; background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.preview-table tr.used-row > td:first-child { box-shadow: inset 4px 0 0 var(--primary), 1px 0 0 var(--border); color: var(--primary-text); font-weight: 800; }
.preview-table tr.used-row td:last-child { color: var(--success-text); font-weight: 800; }
.preview-table tbody tr.used-row:hover td { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.preview-table td.has-value { color: var(--primary-text); font-weight: 800; }
.preview-scroll { max-height: 70vh; overflow: auto; border-top: 1px solid var(--border); }

/* ---------- 8e. Room types clock / live card ---------- */
.live-clock-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------- 8f. Login ---------- */
body.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }

.login-art {
    position: relative;
    overflow: hidden;
    background: var(--brand-gradient);
    color: #fff;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-art::before, .login-art::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: float 9s ease-in-out infinite;
}

.login-art::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.login-art::after { width: 300px; height: 300px; left: -100px; bottom: -90px; animation-delay: -4s; }
.login-art > * { position: relative; z-index: 1; }
.login-art .brand { padding: 0; }
.login-art .brand-logo { background: rgba(255, 255, 255, 0.18); box-shadow: none; }
.login-art .brand-sub { color: rgba(255, 255, 255, 0.75); }
.login-art h2 { font-size: 38px; font-weight: 800; line-height: 1.1; max-width: 420px; letter-spacing: -0.02em; }
.login-art p { color: rgba(255, 255, 255, 0.85); margin-top: 14px; max-width: 420px; font-size: 16px; }
.login-time { font-size: 56px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.login-date { color: rgba(255, 255, 255, 0.85); margin-top: 8px; font-weight: 550; }

.login-panel { display: grid; place-items: center; padding: 40px 24px; }
.login-form { width: 100%; max-width: 380px; animation: rise 0.5s var(--ease) both; }
.login-form h1 { font-size: 28px; }
.login-form .subtitle { margin-bottom: 28px; }
.login-form .field { margin-bottom: 16px; }
.login-form .btn { width: 100%; height: 48px; margin-top: 8px; font-size: 15px; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.password-wrap button {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.password-wrap button:hover { color: var(--text); background: var(--surface-3); }
.login-mobile-brand { display: none; }

/* ---------- 9. Modal / sheet ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    animation: fade 0.2s ease both;
}

.modal-card {
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    animation: pop 0.28s var(--ease) both;
}

.modal-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }

.close-button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 0;
    background: var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
    font-size: 16px;
}

.close-button:hover { color: var(--text); }
.modal-card .field { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Confirm dialog (common.js confirmDialog) */
.confirm-overlay { z-index: 120; }
.confirm-overlay.closing { animation: fade 0.16s ease reverse both; }
.confirm-card { max-width: 420px; text-align: center; padding: 28px 26px 22px; }
.confirm-card h2 { font-size: 19px; }
.confirm-message { color: var(--text-2); font-size: 14px; margin-top: 8px; line-height: 1.6; white-space: pre-line; }
.confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary-text);
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 7%, transparent);
}
.confirm-icon svg.icon { width: 26px; height: 26px; }
.confirm-card.tone-danger .confirm-icon { background: var(--danger-soft); color: var(--danger-text); box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 7%, transparent); }
.confirm-card.tone-success .confirm-icon { background: var(--success-soft); color: var(--success-text); box-shadow: 0 0 0 8px color-mix(in srgb, var(--success) 7%, transparent); }
.confirm-card .modal-actions { justify-content: stretch; }
.confirm-card .dialog-field { text-align: left; margin: 18px 0 0; }
.confirm-card .dialog-error { display: block; min-height: 16px; margin-top: 4px; color: var(--danger-text); font-weight: 600; }
.confirm-card .modal-actions > .btn { flex: 1; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; box-shadow: 0 6px 16px -8px var(--danger); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; border-color: transparent; box-shadow: 0 6px 16px -8px var(--success); }
.btn-success:hover:not(:disabled) { background: #059669; }

.more-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

/* ---------- 10. Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-20px, 18px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Breakpoints ---------- */

/* Large desktop: more air */
@media (min-width: 1440px) {
    .page { padding: 36px 40px 56px; }
}

/* Tablet (iPad portrait/landscape small): sidebar collapses to an icon rail */
@media (max-width: 1023px) {
    .sidebar { width: var(--rail-w); padding: 18px 10px; align-items: center; }
    .brand { padding: 4px 0 18px; }
    .brand-text, .nav-group-label, .side-nav a span, .side-user-info { display: none; }
    .side-nav { align-items: center; width: 100%; }
    .side-nav a { justify-content: center; width: 52px; height: 48px; padding: 0; }
    .side-nav a.active::before { left: -10px; }
    .side-user { flex-direction: column; padding: 10px 6px; background: transparent; border: 0; }
    .shell-main { margin-left: var(--rail-w); }
    .topbar { padding: 0 22px; }
    .page { padding: 24px 22px 40px; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.cols-5 { grid-template-columns: 1fr 1fr; }
    .form-grid.cols-5 > :last-child { grid-column: 1 / -1; }
    body.login-page { grid-template-columns: 1fr 1fr; }
    .login-art { padding: 36px; }
    .login-art h2 { font-size: 30px; }

    /* Native tooltip-like label for icon rail */
    .side-nav a::after {
        content: attr(data-label);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%) translateX(-4px);
        background: #0f172a;
        color: #fff;
        font-size: 12px;
        padding: 6px 10px;
        border-radius: 8px;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s, transform 0.15s;
        box-shadow: var(--shadow);
    }

    .side-nav a:hover::after { opacity: 1; transform: translateY(-50%); }
}

/* Phone: top app bar + bottom tab bar, cards stack, tables become cards */
@media (max-width: 767px) {
    body { font-size: 15px; }
    h1 { font-size: 22px; }

    .sidebar { display: none; }
    .shell-main { margin-left: 0; padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
    .topbar { padding: 0 var(--gutter); height: 58px; }
    .topbar-title { display: none; }
    .topbar-brand { display: flex; }
    .topbar .clock-chip .clock-date { display: none; }
    .page { padding: 18px var(--gutter) 28px; }
    .page-header { margin-bottom: 16px; align-items: flex-start; }
    .page-header .back-link { display: none; }

    .card { border-radius: 16px; margin-bottom: 16px; }
    .card-header { padding: 16px; }
    .card-body { padding: 16px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { padding: 14px; }
    .stat-value { font-size: 22px; }
    .form-grid.cols-3, .form-grid.cols-5, .form-grid.cols-2 { grid-template-columns: 1fr; }
    .form-grid.cols-5 > :last-child { grid-column: auto; }
    .form-grid .btn, .form-grid .primary-button, .form-grid #addPersonButton { width: 100%; }

    /* Bottom tab bar */
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: color-mix(in srgb, var(--surface) 92%, transparent);
        backdrop-filter: saturate(160%) blur(14px);
        -webkit-backdrop-filter: saturate(160%) blur(14px);
        border-top: 1px solid var(--border);
    }

    .bottom-nav a, .bottom-nav button {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        font: inherit;
        font-size: 11px;
        font-weight: 600;
        color: var(--muted);
        background: none;
        border: 0;
        cursor: pointer;
        position: relative;
    }

    .bottom-nav svg.icon { width: 22px; height: 22px; transition: transform 0.2s var(--ease); }
    .bottom-nav .active { color: var(--primary-text); }
    .bottom-nav .active svg.icon { transform: translateY(-1px) scale(1.08); }

    .bottom-nav .active::before {
        content: "";
        position: absolute;
        top: 0;
        width: 28px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--brand-gradient);
    }

    /* "More" bottom sheet */
    .more-sheet {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 70;
        background: var(--surface);
        border-radius: 22px 22px 0 0;
        padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
        box-shadow: var(--shadow-lg);
        transform: translateY(105%);
        transition: transform 0.32s var(--ease);
    }

    .more-sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 4px auto 14px; }
    .more-sheet .sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 4px 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
    .more-sheet .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

    .more-sheet .sheet-grid a, .more-sheet .sheet-grid button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 14px 6px;
        border-radius: 14px;
        background: var(--surface-2);
        border: 1px solid var(--border);
        color: var(--text);
        font: inherit;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
    }

    .more-sheet .sheet-grid .danger { color: var(--danger-text); }
    body.sheet-open .more-sheet { transform: none; }
    body.sheet-open .more-sheet-backdrop { opacity: 1; pointer-events: auto; }

    /* Generic tables → stacked cards (labels from <th> via common.js) */
    .table.responsive thead { display: none; }
    .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
    .table.responsive tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .table.responsive tbody tr:hover { background: transparent; }
    .table.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
    .table.responsive td::before { content: attr(data-label); font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; text-align: left; }
    .table.responsive td[colspan] { display: block; text-align: center; }
    .table.responsive td[colspan]::before { content: none; }
    .table.responsive td:last-child:has(button) { justify-content: flex-end; padding-top: 10px; }
    .table.responsive td:last-child:has(button)::before { content: none; }

    /* Daily entry rows become compact cards */
    .entry-head { display: none; }

    .entry-row {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "room room" "alloc saved" "step step";
        gap: 12px;
        padding: 16px;
    }

    .entry-row .entry-room { grid-area: room; }
    .entry-row .allocated-quantity { grid-area: alloc; }
    .entry-row .saved-quantity { grid-area: saved; }
    .entry-row .entry-step { grid-area: step; }
    .entry-figure { background: var(--surface-2); border-radius: 10px; padding: 8px; }
    .entry-row .stepper { width: 100%; }
    .entry-row .stepper button { width: 56px; }
    .entry-row .stepper input { flex: 1; width: auto; }

    /* Sticky save bar above bottom nav */
    .save-bar {
        position: sticky;
        bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
        z-index: 20;
        border-radius: 0 0 16px 16px;
        padding: 12px 16px;
        box-shadow: 0 -10px 24px -18px rgba(15, 23, 42, 0.4);
    }

    .save-bar .save-total strong { font-size: 20px; }
    .save-bar .save-button { min-width: 0; flex: 1.3; padding: 0 12px; }

    .allocation-matrix tr > :first-child { min-width: 112px; max-width: 132px; white-space: normal; }
    .allocation-matrix thead th { min-width: 96px; }
    .allocation-matrix input { width: 64px; }

    .report-actions { grid-template-columns: 1fr 1fr; }

    .hero { padding: 22px 20px; }
    .hero h1 { font-size: 21px; }
    .hero-clock { text-align: left; }
    .hero-clock .time { font-size: 36px; }
    .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .module { padding: 16px; }
    .module p { display: none; }

    .modal-overlay { place-items: end center; padding: 0; }
    .modal-card { max-width: none; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: sheetUp 0.3s var(--ease) both; }
    .modal-actions > * { flex: 1; }

    body.login-page { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .login-mobile-brand { display: block; text-align: center; margin-bottom: 26px; }
    .login-mobile-brand .brand-logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px; }
    .login-mobile-brand .brand-logo svg.icon { width: 28px; height: 28px; }
    .login-mobile-brand .mobile-clock { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 4px; }
    .login-panel { align-items: start; padding-top: 56px; }
}

@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

/* Very small phones (≤ 360px) */
@media (max-width: 360px) {
    .stat-grid { grid-template-columns: 1fr; }
    .module-grid { grid-template-columns: 1fr; }
    .bottom-nav a, .bottom-nav button { font-size: 10px; }
}

/* ---------- Small additions ---------- */
/* Status icon in front of messages (success / error) */
.message::before {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
}
.message.success::before { content: "✓"; background: var(--success); }
.message.error::before { content: "!"; background: var(--danger); }

/* Single-cell status rows inside the capacity matrix (loading / empty) */
.allocation-matrix td:only-child {
    position: static;
    white-space: normal;
    text-align: center;
    color: var(--text-2);
    padding: 40px 16px;
    box-shadow: none;
}

/* Entry history: numeric columns right-aligned */
#historyTableBody td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.status-date { color: var(--text-2); font-size: 13px; }

/* KPI row: 4 across on wide screens, 2×2 on laptop/tablet/phone (never 3+1) */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
@media (max-width: 1279px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .kpi-grid { gap: 10px; } .stat.kpi .kpi-icon { width: 32px; height: 32px; right: 12px; top: 12px; } }
.hero-clock { margin-left: auto; }
@media (max-width: 767px) { .hero-clock { margin-left: 0; } }

[data-theme-icon] { display: contents; }

@media (max-width: 767px) {
    /* Phone cards: hide technical ID, make the name the card title */
    .table.responsive td[data-label="ID"] { display: none; }
    .table.responsive td:nth-child(2) { font-weight: 700; font-size: 16px; }
}

@media (max-width: 1023px) {
    .side-nav { overflow: visible; }
}
.form-grid.filters { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.allocation-matrix .matrix-label td:only-child { padding: 14px 12px 8px; text-align: left; color: var(--muted); }

/* =====================================================================
   v3 additions: buttons, Room Types → Rooms modal, Daily Capacity cards
   ===================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn svg.icon { width: 17px; height: 17px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.icon-button.danger { color: var(--danger-text); }
.icon-button.danger:hover { background: var(--danger-soft); color: var(--danger-text); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 22px 18px;
    padding: 11px 14px;
    border-radius: 12px;
    background: var(--warning-soft);
    color: var(--warning-text);
    font-size: 13px;
    font-weight: 600;
}
.notice svg.icon { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice.inline { margin: 0 0 14px; }

/* ---- Room Types: rooms column + modal ---- */
.rooms-count-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
}
.rooms-count-button svg.icon { width: 16px; height: 16px; color: var(--primary-text); }
.rooms-count-button:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.rooms-count-button.empty { border-style: dashed; color: var(--text-2); }
.rooms-count-button:disabled { opacity: 0.5; cursor: not-allowed; }

.rooms-modal { max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.rooms-add { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.rooms-add .btn { margin-top: 27px; }
.rooms-legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 14px 0 10px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.rooms-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.rooms-legend .dot.in { background: var(--success); }
.rooms-legend .dot.out { background: var(--muted); }
.room-number-list { overflow-y: auto; min-height: 120px; max-height: 46vh; border: 1px solid var(--border); border-radius: 12px; }
.room-number-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.room-number-item:last-child { border-bottom: 0; }
.room-number-tag { min-width: 64px; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.room-number-state { flex: 1; font-size: 12px; font-weight: 650; color: var(--success-text); }
.room-number-item.out .room-number-tag { color: var(--muted); text-decoration: line-through; }
.room-number-item.out .room-number-state { color: var(--muted); }
.room-number-actions { display: flex; align-items: center; gap: 6px; }
.room-number-actions .action-button { height: 34px; padding: 0 10px; font-size: 12px; }
.room-number-actions .icon-button { width: 34px; height: 34px; }
.room-number-actions .icon-spacer { width: 34px; height: 34px; }

/* ---- Daily Capacity ---- */
.capacity-toolbar { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 18px; align-items: end; }
.cap-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.cap-stat { padding: 10px 14px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-text); }
.cap-stat span { display: block; font-size: 12px; font-weight: 650; }
.cap-stat strong { display: block; font-size: 24px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cap-stat:nth-child(4) { background: var(--surface-3); color: var(--text); }

.room-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 0 20px; }
.room-card h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.room-card h2 .badge { font-size: 12px; }
.room-card-body { padding: 18px 22px 6px; }
.room-card-status { font-size: 13px; font-weight: 750; padding: 6px 12px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.room-card-status.ok { background: var(--success-soft); color: var(--success-text); }
.room-card-status.bad { background: var(--danger-soft); color: var(--danger-text); }
.room-card-status.idle { background: var(--surface-3); color: var(--text-2); }
.room-card-problems { margin: 6px 22px 0; padding: 10px 14px 10px 30px; border-radius: 10px; background: var(--danger-soft); color: var(--danger-text); font-size: 13px; font-weight: 600; }
.room-card-people { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 22px 18px; }

.room-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.room-tools .fill-select { flex: 1 1 180px; height: 36px; min-width: 0; font-size: 13px; }

.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.room-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    border: 1.5px dashed var(--border-strong);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.room-tile:hover { border-color: var(--primary); }
.room-tile.taken { border-style: solid; border-color: color-mix(in srgb, var(--primary) 55%, transparent); background: var(--primary-soft); box-shadow: 0 6px 16px -12px var(--primary); }
.room-tile.out { background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface-3) 8px 16px); border-color: var(--border); }
.room-tile-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.room-tile-no { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.room-tile-flag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.room-tile.taken .room-tile-flag { color: var(--primary-text); }
.room-tile.taken .room-tile-no { color: var(--primary-text); }
.room-tile.out .room-tile-flag { color: var(--warning-text); }
.room-tile select { height: 36px; font-size: 13px; padding-left: 10px; background-color: var(--surface); }

.count-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.count-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.count-row:last-child { border-bottom: 0; }
.count-row.capacity { background: var(--primary-soft); color: var(--primary-text); font-weight: 700; }
.count-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.count-name .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-name small { color: var(--warning-text); font-weight: 650; }
.count-row input { width: 96px; height: 38px; text-align: center; font-weight: 700; }
.count-hint { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 12px 0 6px; font-size: 13px; color: var(--text-2); }

.person-chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 4px; border-radius: 999px; background: var(--surface-3); font-size: 13px; }
.person-chip .name { font-weight: 600; }
.person-chip strong { color: var(--primary-text); font-variant-numeric: tabular-nums; }
.person-chip.bad { background: var(--danger-soft); }
.person-chip.bad strong { color: var(--danger-text); }

.person-summary { display: flex; flex-direction: column; }
.person-summary-row { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--border); }
.person-summary-main { flex: 1; min-width: 0; }
.person-summary-name { display: block; margin-bottom: 6px; }
.person-summary-rooms { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.type-group { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.type-group:last-child { border-bottom: 0; }
.type-group:nth-child(even) { background: var(--surface-2); }
.type-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); min-width: 0; }
.type-name small { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); font-size: 11px; font-weight: 800; text-align: center; }
.type-rooms { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.count-chip { font-size: 12px; font-weight: 750; padding: 2px 8px; border-radius: 7px; background: var(--surface-3); }
.person-summary-total { text-align: center; min-width: 56px; }
.person-summary-total strong { display: block; font-size: 22px; font-weight: 800; color: var(--primary-text); line-height: 1.1; }
.person-summary-total span { font-size: 11px; color: var(--text-2); font-weight: 600; }
.person-summary-note { padding: 12px 22px 16px; font-size: 13px; color: var(--muted); }

.capacity-save { position: sticky; bottom: 14px; z-index: 30; box-shadow: var(--shadow-lg); }
.capacity-save .save-bar { border-top: 0; border-radius: var(--radius-lg); }
.save-status { font-size: 16px !important; font-weight: 750 !important; color: var(--success-text); }
.save-status.pending { color: var(--warning-text); }
.save-status.bad { color: var(--danger-text); }

@media (max-width: 1023px) {
    .capacity-toolbar { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
    .cap-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cap-stat strong { font-size: 20px; }
    .room-card-body { padding: 14px 14px 4px; }
    .room-card-problems { margin: 6px 14px 0; }
    .room-card-people { padding: 10px 14px 14px; }
    .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .room-tile-no { font-size: 18px; }
    .person-summary-row { padding: 12px 14px; align-items: flex-start; }
    .type-group { grid-template-columns: 1fr; gap: 6px; }
    .type-name { justify-content: flex-start; }
    .person-summary-note { padding: 10px 14px 14px; }
    .notice { margin: 0 14px 14px; }
    .capacity-save { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 8px); }
    .capacity-save .save-bar { position: static; box-shadow: none; }
    .save-status { font-size: 14px !important; }
    .header-actions { width: 100%; justify-content: space-between; }
    .rooms-add { grid-template-columns: 1fr; }
    .rooms-add .btn { margin-top: 0; width: 100%; }
    .rooms-modal { max-height: 88vh; }
    .room-number-item { flex-wrap: wrap; }
    .header-stat { width: 100%; }
}


/* =====================================================================
   v5 additions: delete buttons, switch, Salary Sheets page
   ===================================================================== */
/* Delete (soft delete) in table action cells: quiet until hovered */
.action-button.delete, .action-btn.delete:not(.danger) {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    border-color: var(--border-strong);
}
.action-button.delete svg.icon, .action-btn.delete svg.icon { width: 14px; height: 14px; }
.action-button.delete:hover:not(:disabled), .action-btn.delete:not(.danger):hover:not(:disabled) {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}
td .action-button + .action-button, td .action-btn + .action-btn { margin-left: 6px; }

/* Switch (checkbox) */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; user-select: none; font-weight: 650; font-size: 14px; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background 0.2s, border-color 0.2s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3); transition: transform 0.2s var(--ease); }
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 2px; }
input.invalid { border-color: var(--danger) !important; }
.field .hint:empty { display: none; }
#taxRateError { color: var(--danger-text); font-weight: 600; }

/* Salary toolbar */
.salary-toolbar { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-start; }
.salary-toolbar > .field { flex: 1 1 150px; max-width: 280px; min-width: 0; }
.salary-toolbar > .field:nth-child(3) { flex: 0 1 140px; }
.salary-default { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.salary-default small { font-size: 13px; color: var(--text-2); font-weight: 600; }

/* Report-style cards: gross / tax / net strip */
.salary-stats { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.salary-stats > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.salary-stats > div:last-child { border-bottom: 0; }
.salary-stats span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.salary-stats strong { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.salary-stats .tax strong { color: var(--danger-text); }
.salary-stats .net { background: var(--primary-soft); }
.salary-stats .net span { color: var(--primary-text); font-weight: 800; }
.salary-stats .net strong { color: var(--primary-text); font-size: 17px; font-weight: 800; }
.salary-stats:has(.salary-stats-empty) { border: 0; }
.salary-stats-empty { min-height: 104px; display: flex; align-items: center; justify-content: center; margin: 0; padding: 14px; text-align: center; font-size: 13px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius-sm, 10px); }
.report-actions.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Preview: statement paper or payroll table */
.salary-preview { margin-top: 20px; }
.salary-preview .salary-sheet-wrap { padding: 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.salary-sheet-wrap { min-width: 0; container-type: inline-size; }
.salary-sheet-wrap .salary-paper { max-width: 860px; margin: 0 auto; }
.payroll-table tr.clickable { cursor: pointer; }
.payroll-table td:not(:first-child), .payroll-table th:not(:first-child) { text-align: right; }
.payroll-status { font-weight: 600; color: var(--muted); }

/* The statement "paper": always light, like a printed document */
.salary-paper {
    --paper-ink: #0f172a; --paper-muted: #64748b; --paper-line: #e2e8f0; --paper-soft: #f8fafc; --paper-brand: #4f46e5; --paper-brand-soft: #eef2ff;
    background: #fff; color: var(--paper-ink);
    border-radius: 18px; border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 34px 38px 28px;
    transition: opacity 0.2s;
}
.salary-paper.loading { opacity: 0.55; }
.salary-paper .empty-state { color: var(--paper-muted); }
.salary-paper .empty-state strong { color: var(--paper-ink); }
.paper-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 20px; border-bottom: 3px solid var(--paper-brand); }
.paper-kicker { font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--paper-brand); margin: 0 0 4px; }
.paper-head h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 0; color: var(--paper-ink); }
.paper-period { margin: 6px 0 0; color: var(--paper-muted); font-size: 13px; font-weight: 600; }
.paper-net { text-align: right; background: var(--paper-brand-soft); border-radius: 14px; padding: 12px 18px; }
.paper-net span { display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--paper-brand); }
.paper-net strong { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--paper-ink); white-space: nowrap; }

.paper-info { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; margin: 22px 0 26px; }
.paper-info div { min-width: 0; }
.paper-info dt { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--paper-muted); }
.paper-info dd { margin: 3px 0 0; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }

.paper-section { font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--paper-brand); margin: 0 0 10px; }
.paper-table-wrap { overflow-x: auto; }
.paper-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.paper-table th { background: var(--paper-brand); color: #fff; font-size: 12px; font-weight: 700; text-align: left; padding: 10px 12px; white-space: nowrap; }
.paper-table th:first-child { border-radius: 8px 0 0 8px; }
.paper-table th:last-child { border-radius: 0 8px 8px 0; }
.paper-table td { padding: 10px 12px; border-bottom: 1px solid var(--paper-line); color: var(--paper-ink); }
.paper-table tbody tr:nth-child(even) td { background: var(--paper-soft); }
.paper-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.paper-table .no { width: 48px; }
.paper-table td.no { color: var(--paper-muted); }
.paper-table .strong { font-weight: 700; }
.paper-table tfoot td { font-weight: 800; background: var(--paper-brand-soft); border-bottom: 0; }
.paper-table .rate-sub { display: none; font-size: 11px; color: var(--paper-muted); font-weight: 600; }
.paper-empty { text-align: center; color: var(--paper-muted); padding: 18px !important; }

.paper-summary { margin: 22px 0 0 auto; max-width: 360px; display: flex; flex-direction: column; gap: 2px; }
.paper-summary .row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 4px; border-bottom: 1px solid var(--paper-line); font-size: 14px; }
.paper-summary .row span { color: var(--paper-muted); font-weight: 600; }
.paper-summary .row strong { font-variant-numeric: tabular-nums; }
.paper-summary .row.tax strong { color: #be123c; }
.paper-summary .row.net { margin-top: 6px; border: 0; border-radius: 12px; background: var(--paper-brand); padding: 12px 16px; }
.paper-summary .row.net span, .paper-summary .row.net strong { color: #fff; font-size: 17px; font-weight: 800; }

.paper-sign { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; margin-top: 44px; }
.paper-sign div { font-size: 12px; font-weight: 700; color: var(--paper-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.paper-sign span { display: block; border-bottom: 1px solid var(--paper-ink); height: 34px; margin-bottom: 6px; }
.paper-note { margin: 22px 0 0; font-size: 11px; color: var(--paper-muted); font-style: italic; }

@container (max-width: 620px) {
    .salary-paper { padding: 20px 16px; border-radius: 14px; }
    .paper-head { flex-direction: column; gap: 14px; }
    .paper-head h2 { font-size: 22px; }
    .paper-net { width: 100%; text-align: left; box-sizing: border-box; }
    .paper-info { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .paper-table { font-size: 13px; }
    .paper-table th, .paper-table td { padding: 8px; }
    .paper-table .no { width: 30px; }
    .paper-summary { max-width: none; }
    .paper-sign { gap: 20px; }
}

@container (max-width: 460px) {
    .paper-table .no, .paper-table .rate { display: none; }
    .paper-table .rate-sub { display: block; }
    .paper-table th, .paper-table td { padding: 8px 6px; }
    .paper-table th:nth-child(2) { border-radius: 8px 0 0 8px; }
    .paper-info dd { font-size: 14px; }
}

@media (max-width: 767px) {
    .salary-toolbar { gap: 12px; }
    .salary-toolbar > .field { max-width: none; flex-basis: 140px; }
    .salary-toolbar > .field:first-child { flex-basis: 100%; }
    .salary-default { padding: 10px 14px; }
    .salary-preview .salary-sheet-wrap { padding: 10px; }
    .salary-stats > div { padding: 8px 12px; }
    td .action-button + .action-button, td .action-btn + .action-btn { margin-left: 0; }
}

/* Print only the statement */
@media print {
    body * { visibility: hidden !important; }
    .salary-paper, .salary-paper * { visibility: visible !important; }
    .salary-paper { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: 0; padding: 0; }
    .paper-table th, .paper-summary .row.net, .paper-net, .paper-table tfoot td, .paper-table tbody tr:nth-child(even) td {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
}

td .action-button, td .action-btn { vertical-align: middle; }
td:has(> .action-button.delete), td:has(> .action-btn.delete) { white-space: nowrap; }
@media (max-width: 1279px) {
    .action-button.delete span, .action-btn.delete span { display: none; }
    .action-button.delete, .action-btn.delete:not(.danger) { padding-left: 9px; padding-right: 9px; }
}
@media (max-width: 767px) {
    .action-button.delete span, .action-btn.delete span { display: inline; }
    td:has(> .action-button.delete), td:has(> .action-btn.delete) { white-space: normal; }
}
@media (min-width: 768px) and (max-width: 1279px) {
    table:has(.action-button.delete) th, table:has(.action-button.delete) td,
    table:has(.action-btn.delete) th, table:has(.action-btn.delete) td { padding-left: 10px; padding-right: 10px; }
}

/* =====================================================================
   v6: compact controls on phones
   ===================================================================== */
@media (max-width: 767px) {
    .btn, .save-button, .primary-button, .secondary-button, .report-download-btn, .report-preview-btn, #addPersonButton {
        height: 40px; padding: 0 14px; font-size: 13.5px; gap: 6px; border-radius: 9px;
    }
    .btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
    .btn-sm svg.icon { width: 15px; height: 15px; }
    .action-button, .action-btn { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
    .action-button svg.icon, .action-btn svg.icon { width: 14px; height: 14px; }
    .login-form .btn { height: 44px; }
    .report-actions { gap: 8px; }
    .report-actions.three { grid-template-columns: 1fr 1fr; }
    .report-actions.three > :last-child { grid-column: 1 / -1; }
    .salary-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .salary-toolbar > .field, .salary-toolbar > .field:first-child { max-width: none; min-width: 0; }
    .switch { min-height: 42px; font-size: 13px; gap: 8px; }
}
@media (max-width: 767px) {
    .topbar-brand { gap: 8px; }
    .topbar-brand .brand-logo { width: 32px; height: 32px; }
    .topbar-brand .brand-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .topbar .clock-chip { padding: 6px 10px; gap: 6px; font-size: 12.5px; }
    .topbar .icon-button { width: 36px; height: 36px; }
}
@media (max-width: 1279px) {
    .report-actions.three { grid-template-columns: 1fr 1fr; }
    .report-actions.three > :last-child { grid-column: 1 / -1; }
}
/* Tablet tables: drop the technical ID column and tighten action buttons so nothing is cut off */
@media (min-width: 768px) and (max-width: 1023px) {
    .table.responsive:has(td[data-label="ID"]) tr > :first-child { display: none; }
    .table.responsive:has(td[data-label]) th, .table.responsive:has(td[data-label]) td { padding-left: 8px; padding-right: 8px; }
    .rooms-count-button { padding-left: 8px; padding-right: 8px; gap: 5px; font-size: 12.5px; }
    td .action-button, td .action-btn { height: 30px; padding: 0 9px; font-size: 12px; margin-right: 4px; }
    td .action-button + .action-button, td .action-btn + .action-btn { margin-left: 2px; }
}

/* ---------- Colour (accent) picker: topbar button + dialog ---------- */
.accent-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--brand-gradient); box-shadow: 0 0 0 2px var(--surface); display: inline-block; }
.accent-card { max-width: 460px; text-align: left; }
.accent-card h2 { font-size: 18px; }
.accent-card .confirm-message { margin: 4px 0 16px; }
.accent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.accent-option {
    display: flex; flex-direction: column; gap: 8px; align-items: stretch; text-align: left;
    padding: 10px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface-2);
    color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}
.accent-option:hover { border-color: var(--border-strong); }
.accent-option.selected { border-color: var(--primary); box-shadow: var(--ring); }
.accent-swatch { height: 34px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.accent-swatch svg.icon { width: 18px; height: 18px; }
.accent-option small { color: var(--text-2); font-weight: 500; font-size: 11px; }
.accent-auto .accent-swatch { background: conic-gradient(from 90deg, #4f46e5, #ea580c, #059669, #e11d48, #2563eb, #7c3aed, #4f46e5); }

/* ---------- Change password page ---------- */
.password-form { display: flex; flex-direction: column; gap: 16px; max-width: 440px; }
.password-form .btn { align-self: flex-start; }
