/* assets/css/app.css */
/* Modern Hospital Design System - Nurse Shift & Patient Escort */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

.brand-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; background: white; }
.brand-text { min-width: 0; overflow-wrap: anywhere; }
.settings-wrapper { width: 100%; max-width: none; margin: 0; }
.catalog-list { margin-top: 1.25rem; }
.catalog-table-scroll { overflow-x: auto; }
.catalog-table-scroll table { width: 100%; border-collapse: collapse; }
.catalog-table-scroll th, .catalog-table-scroll td { padding: .75rem; text-align: left; border-bottom: 1px solid var(--card-border); }
.catalog-table-scroll td { overflow-wrap: anywhere; }
/* ทุกหน้าในหมวดตั้งค่าระบบใช้ระยะห่างแบบกระชับและสีประจำหมวด */
.catalog-panel,
.settings-panel { --section-accent: #0284c7; --section-soft: #e0f2fe; }
.catalog-panel[data-type="positions"] { --section-accent: #7c3aed; --section-soft: #f3e8ff; }
.catalog-panel[data-type="groups"] { --section-accent: #059669; --section-soft: #d1fae5; }
.catalog-panel[data-type="destinations"] { --section-accent: #ea580c; --section-soft: #ffedd5; }
.catalog-panel[data-type="staff"] { --section-accent: #2563eb; --section-soft: #dbeafe; }
.settings-section-title { display: flex; align-items: center; gap: .55rem; color: var(--section-accent); }
.settings-section-icon {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    border: 1px solid color-mix(in srgb, var(--section-accent) 28%, transparent);
    border-radius: 10px;
    background: var(--section-soft);
    font-size: 1.05rem;
}
.catalog-panel .settings-card,
.settings-panel .settings-card {
    padding: .65rem;
    border-top: 3px solid var(--section-accent);
    box-shadow: 0 3px 10px rgb(15 23 42 / 5%);
}
.catalog-panel .catalog-table-scroll th,
.catalog-panel .catalog-table-scroll td { padding: .3rem .5rem; }
.catalog-panel .catalog-table-scroll th { color: var(--section-accent); background: var(--section-soft); }
.catalog-panel .catalog-search { margin-bottom: .4rem; }
.catalog-panel .catalog-pagination { margin-top: .4rem; }
.catalog-panel .settings-card .btn,
.settings-panel .settings-card .btn {
    padding: .38rem .7rem;
    border-radius: 9px;
    font-size: .85rem;
}
.catalog-panel .settings-card .form-control,
.settings-panel .settings-card .form-control {
    padding: .42rem .7rem;
    border-radius: 9px;
    font-size: .85rem;
}
.catalog-panel .catalog-row-actions button { margin: .08rem; }
.catalog-panel { font-size: .9rem; }
.catalog-panel .settings-section-title { font-size: 1.25rem; line-height: 1.25; }
.catalog-panel .settings-description { font-size: .84rem; line-height: 1.4; }
.catalog-panel .catalog-search,
.catalog-panel .catalog-pagination { font-size: .85rem; line-height: 1.25; }
.catalog-panel .catalog-table-scroll table { font-size: .88rem; line-height: 1.3; }
.catalog-panel .catalog-table-scroll th { font-size: .84rem; font-weight: 700; }
.catalog-panel .catalog-table-scroll td { font-size: .88rem; }
.catalog-line-avatar { width:38px; height:38px; padding:0; border:0; border-radius:50%; display:grid; place-items:center; overflow:hidden; background:#eef2f7; color:#64748b; font-size:1.05rem; }
.catalog-line-avatar img { width:100%; height:100%; object-fit:cover; display:block; }
.catalog-line-avatar.is-clickable { cursor:zoom-in; box-shadow:0 0 0 2px #fff, 0 0 0 3px #bfdbfe; transition:transform .15s ease, box-shadow .15s ease; }
.catalog-line-avatar.is-clickable:hover { transform:scale(1.08); box-shadow:0 0 0 2px #fff, 0 0 0 4px #7dd3fc; }
.catalog-profile-modal { position:fixed; inset:0; z-index:2000; display:none; place-items:center; padding:1rem; }
.catalog-profile-modal.active { display:grid; }
.catalog-profile-backdrop { position:absolute; inset:0; background:rgba(15,23,42,.72); backdrop-filter:blur(3px); }
.catalog-profile-dialog { position:relative; width:min(460px,92vw); padding:1rem; border-radius:20px; background:#fff; box-shadow:0 24px 70px rgba(15,23,42,.35); text-align:center; animation:modalIn .2s ease; }
.catalog-profile-dialog h3 { margin:.15rem 2rem .85rem; font-size:1rem; }
.catalog-profile-dialog img { display:block; width:min(380px,100%); max-height:70vh; margin:auto; border-radius:16px; object-fit:contain; background:#f1f5f9; }
.catalog-profile-close { position:absolute; top:.65rem; right:.65rem; width:34px; height:34px; border:0; border-radius:50%; background:#f1f5f9; cursor:pointer; font-size:1rem; }
.staff-control-modal { position:fixed; inset:0; z-index:2100; display:none; place-items:center; padding:1rem; }
.staff-control-modal.active { display:grid; }
.staff-control-backdrop { position:absolute; inset:0; background:rgba(15,23,42,.7); backdrop-filter:blur(3px); }
.staff-control-dialog { position:relative; width:min(920px,96vw); max-height:92vh; overflow:auto; border-radius:20px; background:#fff; box-shadow:0 24px 70px rgba(15,23,42,.38); animation:modalIn .2s ease; }
.staff-control-dialog > header { position:sticky; top:0; z-index:1; display:flex; justify-content:space-between; align-items:flex-start; padding:1rem 1.25rem; background:#eff6ff; border-bottom:1px solid #bfdbfe; }
.staff-control-dialog h3 { margin:.15rem 0; font-size:1.25rem; color:#1e3a8a; }
.staff-control-dialog header p { margin:0; color:#64748b; font-size:.82rem; }
.staff-control-kicker { color:#2563eb; font-size:.78rem; font-weight:700; }
.staff-control-close { width:36px; height:36px; border:0; border-radius:50%; background:#fff; cursor:pointer; }
.staff-control-body { padding:1rem 1.25rem 1.25rem; }
.staff-control-loading { padding:3rem; text-align:center; color:#64748b; }
.staff-control-summary { display:grid; grid-template-columns:repeat(3,1fr); gap:.65rem; margin-bottom:.75rem; }
.staff-control-summary > div { padding:.7rem; border:1px solid #dbeafe; border-radius:12px; background:#f8fbff; }
.staff-control-summary span,.staff-control-summary b { display:block; }
.staff-control-summary span { color:#64748b; font-size:.75rem; }
.staff-control-summary b { margin-top:.2rem; font-size:.9rem; }
.staff-control-actions { display:flex; flex-wrap:wrap; gap:.45rem; padding:.65rem 0 1rem; }
.staff-control-grid { display:grid; grid-template-columns:1fr 1fr; gap:.75rem; }
.staff-control-grid section { border:1px solid #e2e8f0; border-radius:14px; padding:.75rem; }
.staff-control-grid h4 { margin:0 0 .5rem; }
.staff-control-list { max-height:280px; overflow:auto; }
.staff-control-list > div { display:flex; justify-content:space-between; gap:.75rem; padding:.45rem .25rem; border-bottom:1px solid #f1f5f9; font-size:.8rem; }
.staff-control-list span { color:#64748b; text-align:right; }
@media(max-width:700px){.staff-control-summary,.staff-control-grid{grid-template-columns:1fr}.staff-control-dialog{max-height:96vh}.staff-control-list{max-height:200px}}
.staff-history-all-btn { width:100%; margin-top:.65rem; }
.staff-history-modal { position:fixed; inset:0; z-index:2200; display:none; place-items:center; padding:1rem; }
.staff-history-modal.active { display:grid; }
.staff-history-backdrop { position:absolute; inset:0; background:rgba(15,23,42,.78); }
.staff-history-dialog { position:relative; width:min(1120px,97vw); max-height:94vh; overflow:auto; border-radius:18px; background:#fff; box-shadow:0 24px 70px rgba(15,23,42,.4); }
.staff-history-dialog > header { display:flex; justify-content:space-between; padding:1rem 1.25rem; background:#eff6ff; border-bottom:1px solid #bfdbfe; }
.staff-history-dialog h3 { margin:.2rem 0 0; color:#1e3a8a; }
.staff-history-filters { display:flex; align-items:end; flex-wrap:wrap; gap:.65rem; padding:.85rem 1.25rem; }
.staff-history-filters label { font-size:.8rem; color:#475569; }
.staff-history-filters input { margin-top:.2rem; }
.staff-history-table-wrap { margin:0 1.25rem; overflow:auto; border:1px solid #e2e8f0; border-radius:12px; }
.staff-history-count { padding:.75rem 1.25rem 1rem; color:#64748b; font-size:.82rem; }
.catalog-panel .settings-card .btn {
    min-height: 2rem;
    gap: .3rem;
    line-height: 1.15;
    white-space: nowrap;
}
.catalog-btn-icon,
.catalog-panel .btn > span[aria-hidden="true"] {
    display: inline-flex;
    width: 1.05rem;
    height: 1.05rem;
    align-items: center;
    justify-content: center;
    flex: 0 0 1.05rem;
    font-size: .82rem;
    line-height: 1;
}
.catalog-btn-add { background: linear-gradient(135deg, var(--section-accent), color-mix(in srgb, var(--section-accent) 72%, #000)); }
.catalog-btn-search { background: #e0f2fe; border: 1px solid #7dd3fc; color: #075985; }
.catalog-btn-search:hover { background: #bae6fd; }
.catalog-btn-go { background: #ede9fe; border: 1px solid #c4b5fd; color: #5b21b6; }
.catalog-btn-go:hover { background: #ddd6fe; }
.catalog-action-view { background: #e0f2fe; border: 1px solid #7dd3fc; color: #075985; }
.catalog-action-view:hover { background: #bae6fd; }
.catalog-action-edit { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.catalog-action-edit:hover { background: #fde68a; }
.catalog-action-delete { background: #fee2e2; border: 1px solid #fca5a5; color: #b91c1c; }
.catalog-action-delete:hover { background: #ef4444; color: #fff; }
.catalog-action-unlink { background:#ede9fe; border:1px solid #c4b5fd; color:#5b21b6; }
.catalog-action-unlink:hover { background:#ddd6fe; }
.catalog-line-linked { display:inline-block; background:#dcfce7; color:#166534; }
.catalog-line-unlinked { display:inline-block; background:#f1f5f9; color:#64748b; }
.catalog-line-detail { display:block; margin-top:.2rem; color:var(--text-muted); font-size:.7rem; white-space:nowrap; }
.catalog-btn-page:disabled { opacity: .45; cursor: not-allowed; }
.settings-panel .form-group { margin-bottom: .7rem; }
.settings-panel .settings-description { margin-bottom: .65rem; }
.settings-panel .settings-icon-preview { margin-bottom: .4rem; font-size: 2.25rem; }
.settings-panel .settings-icon-preview img { width: 60px; height: 60px; }
.line-settings-card { margin-top: 1rem; --section-accent:#06c755; border-top-color:#06c755 !important; }
.line-settings-card h3 { color:#047a35; }
.line-log-panel { margin-top:1rem; padding-top:.75rem; border-top:1px solid var(--card-border); }
.line-log-panel small { color:var(--text-muted); overflow-wrap:anywhere; }
.line-log-panel pre { max-height:260px; overflow:auto; margin-top:.5rem; padding:.75rem; border-radius:10px; background:#0f172a; color:#d1fae5; font:11px/1.45 Consolas,monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
.line-admin-page { --section-accent:#06c755; --section-soft:#dcfce7; }
.line-admin-page .settings-section-icon { width:2.5rem; flex-basis:2.5rem; font-size:.7rem; font-weight:800; color:#047a35; }
.line-file-path { margin:.75rem 0 0 !important; overflow-wrap:anywhere; }
.line-log-toggle-form { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; margin-top:.75rem; }
.line-log-switch { display:inline-flex; align-items:center; gap:.6rem; font-weight:600; color:var(--text-main); cursor:pointer; }
.line-log-switch input { width:1.15rem; height:1.15rem; accent-color:#06c755; }
.settings-card h3 { margin-bottom: 1rem; font-size: 1rem; }
.settings-wrapper h2 { font-size: 1.35rem; }
.settings-description { color: var(--text-muted); font-size: .85rem; margin: .5rem 0 1.25rem; }
.settings-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 1.5rem; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.settings-full { grid-column: 1 / -1; }
.settings-icon-preview { margin-bottom: .75rem; font-size: 3rem; }
.settings-icon-preview img { object-fit: contain; border: 1px solid var(--card-border); border-radius: var(--radius-md); }
.settings-message { padding: 1rem; border-radius: var(--radius-md); margin: 1rem 0; }
.settings-error { background: var(--danger-light); color: #991b1b; }
.settings-success { background: var(--success-light); color: #065f46; }
@media (max-width: 640px) { .settings-grid { grid-template-columns: 1fr; } .settings-card { padding: 1rem; } }

:root {
    --primary: #0284c7;
    --primary-dark: #0369a1;
    --primary-light: #e0f2fe;
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;

    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --input-text: #123f8c;
    --input-placeholder: #7aa6c2;

    --shift-morning: #0284c7;
    --shift-afternoon: #ea580c;
    --shift-night: #7c3aed;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', Tahoma, 'Leelawadee UI', 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* App Shell: Sidebar (ซ้าย) + Main Wrapper (ขวา) */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
    width: 100%;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: width 0.22s ease, padding 0.22s ease;
}

.sidebar-toggle {
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 34px;
    margin-bottom: .5rem;
    padding: .35rem .6rem;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--primary-dark);
    font-family: inherit;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}
.sidebar-toggle:hover { background: var(--primary-light); }
.sidebar-toggle-icon { font-size: 1.2rem; line-height: 1; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem 1.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--card-border);
}

.brand-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.4rem;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

.brand-text h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
}

.brand-text span {
    font-size: 0.74rem;
    color: var(--text-muted);
}

/* เมนูนำทางแนวตั้ง — เพิ่มปุ่ม .nav-btn ใหม่ที่นี่ได้เรื่อยๆ เมื่อมีระบบ/โมดูลเพิ่มในอนาคต โดยไม่ต้องแก้ layout */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-group {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--card-border);
}

.nav-group-heading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-submenu {
    margin-left: 1.35rem;
    padding-left: 0.4rem;
    border-left: 1px solid var(--card-border);
}

.nav-btn {
    border: none;
    background: transparent;
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-align: left;
}

.nav-btn-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.nav-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.nav-btn.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 700;
}

.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.top-bar {
    background: #ffffff;
    border-bottom: 1px solid var(--card-border);
    padding: 0.65rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid var(--card-border);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-md);
}

.user-selector-wrapper label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.user-select {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    outline: none;
}

/* Layout container */
.main-content {
    max-width: none;
    width: 100%;
    margin: 1.5rem 0;
    padding: 0 1.25rem;
    flex: 1;
}

/* Tab Views */
.view-section {
    display: none;
    animation: fadeIn 0.25s ease;
}

.view-section.active {
    display: block;
    width: 100%;
}

@media (min-width: 769px) {
    .app-shell.sidebar-collapsed .sidebar {
        width: 76px;
        padding-left: .55rem;
        padding-right: .55rem;
    }
    .app-shell.sidebar-collapsed .sidebar-toggle {
        align-self: center;
        width: 44px;
        padding-left: 0;
        padding-right: 0;
    }
    .app-shell.sidebar-collapsed .sidebar-toggle-label,
    .app-shell.sidebar-collapsed .brand-text,
    .app-shell.sidebar-collapsed .nav-btn > span:last-child,
    .app-shell.sidebar-collapsed .nav-group-heading > span:last-child {
        display: none;
    }
    .app-shell.sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
    .app-shell.sidebar-collapsed .nav-btn,
    .app-shell.sidebar-collapsed .nav-group-heading {
        justify-content: center;
        padding-left: .5rem;
        padding-right: .5rem;
    }
    .app-shell.sidebar-collapsed .nav-submenu {
        margin-left: 0;
        padding-left: 0;
        border-left: 0;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Utility Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-vehicle {
    display: inline-block;
    font-size: 30px;
    line-height: 1;
}

.status-vehicle-return {
    transform: scaleX(-1);
}

.badge-morning { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-afternoon { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.badge-night { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }

.badge-idle { background: #dcfce7; color: #15803d; }
.badge-busy { background: #fef3c7; color: #b45309; }
.badge-off { background: #f1f5f9; color: #64748b; }

.badge-urgent { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.badge-emergency { background: #ef4444; color: #ffffff; animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

/* Nurse View Mobile-First Experience */
.nurse-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.duty-header-card {
    background: linear-gradient(135deg, #0284c7 0%, #0f766e 100%);
    color: #ffffff;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(2, 132, 199, 0.25);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.duty-header-card::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.nurse-profile-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.nurse-avatar {
    width: 54px;
    height: 54px;
    background: #ffffff;
    color: #0284c7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.nurse-info h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.nurse-info p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.shift-info-box {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(5px);
    margin-top: 0.75rem;
}

/* Action Buttons - 3 Step Mission Flow */
.btn {
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #ef4444;
    color: #ffffff;
}

.btn-outline {
    background: #ffffff;
    border: 1px solid var(--card-border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
}

.btn-password-change {
    padding: .3rem .65rem;
    border: 1px solid #c4b5fd;
    background: #ede9fe;
    color: #5b21b6;
    font-size: .78rem;
}
.btn-password-change:hover { background: #ddd6fe; }
.password-dialog { width: min(480px, calc(100vw - 2rem)); }
.password-dialog h3 { color: #5b21b6; }

.btn-block {
    width: 100%;
}

.btn-xl {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border-radius: var(--radius-lg);
}

/* 3 Checkpoint Step Timeline Box */
.step-container {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.step-indicator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.step-node {
    text-align: center;
    padding: 0.75rem 0.5rem;
    border-radius: var(--radius-md);
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.step-node.completed {
    background: var(--success-light);
    border: 1px solid #86efac;
    color: #15803d;
    font-weight: 600;
}

.step-node.current {
    background: #e0f2fe;
    border: 2px solid #0284c7;
    color: #0369a1;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.15);
}

.step-node .time-tag {
    display: block;
    font-size: 0.72rem;
    margin-top: 0.25rem;
    opacity: 0.85;
}

/* Destination Highlight Card */
.destination-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.dest-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dest-icon {
    font-size: 2rem;
}

.dest-details h3 {
    font-size: 1.05rem;
    color: #166534;
}

.dest-details p {
    font-size: 0.85rem;
    color: #15803d;
}

/* Live Matrix Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
    background: #ffffff;
}

.custom-table th {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.custom-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    vertical-align: middle;
}

.custom-table tr:hover td {
    background-color: #fbfdff;
}

/* Compact live-duty page: keep more staff rows visible without affecting other tables. */
.nurse-status-page .nurse-status-header {
    margin-bottom: .7rem;
}

.nurse-status-page .nurse-status-header h2,
.nurse-status-page .nurse-status-header p {
    margin-top: 0;
    margin-bottom: .2rem;
}

.nurse-status-page .card {
    padding: .75rem;
    margin-bottom: .75rem;
}

.nurse-status-page .card-title {
    margin-bottom: .55rem;
}

.nurse-status-page .custom-table th {
    padding: .48rem .75rem;
}

.nurse-status-page .custom-table td {
    padding: .42rem .75rem;
}

.nurse-status-page .badge {
    padding: .18rem .55rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text-main);
    background: #ffffff;
    transition: border-color 0.2s;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.roster-user-searchbox {
    position: relative;
}

.roster-user-results {
    position: absolute;
    z-index: 1200;
    top: calc(100% + 0.3rem);
    left: 0;
    right: 0;
    max-height: min(280px, 42vh);
    overflow-y: auto;
    padding: 0.35rem;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
}

.roster-user-results[hidden] {
    display: none;
}

.roster-user-result {
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.65rem 0.75rem;
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.roster-user-result:hover,
.roster-user-result:focus-visible {
    outline: none;
    background: #e0f2fe;
}

.roster-user-result small {
    color: var(--primary-dark);
    font-weight: 700;
}

.roster-user-result-meta,
.roster-user-empty {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.roster-user-empty {
    padding: 0.75rem;
    text-align: center;
}

/* ข้อมูลที่ผู้ใช้ป้อนในช่องกรอก แสดงเป็นสีน้ำเงินทั้งระบบ */
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
textarea,
select,
.form-control,
.form-select,
.user-select {
    color: var(--input-text);
    font-weight: 700;
}

input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder);
    opacity: 1;
}

select option {
    color: var(--input-text);
    font-weight: 700;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--input-text);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-card.modal-lg {
    max-width: 920px;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastSlide 0.3s ease;
}

@keyframes toastSlide {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-details h4 {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-details .stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

/* ปฏิทินรายเดือน (Roster Calendar) */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    gap: 6px;
    min-width: 760px;
}

.calendar-weekday {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.4rem 0;
}

.calendar-day {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    min-height: 96px;
    cursor: pointer;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.calendar-day:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.calendar-day.empty-cell {
    background: transparent;
    border: none;
    cursor: default;
}

.calendar-day.empty-cell:hover {
    transform: none;
    box-shadow: none;
}

.calendar-day.today {
    border-color: var(--primary);
    background: var(--primary-light);
}

.calendar-day.selected {
    border: 2px solid var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.calendar-day-num {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.calendar-day-shifts {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cal-chip {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    text-align: center;
}

.cal-chip.empty { background: #f1f5f9; color: var(--text-light); }
.cal-chip.partial { background: #fef3c7; color: #b45309; }
.cal-chip.full { background: #dcfce7; color: #15803d; }

.cal-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 4px;
    vertical-align: middle;
}
.cal-legend-dot.full { background: #dcfce7; border: 1px solid #86efac; }
.cal-legend-dot.partial { background: #fef3c7; border: 1px solid #fcd34d; }
.cal-legend-dot.empty { background: #f1f5f9; border: 1px solid var(--card-border); }

/* แถวสรุปจำนวนพยาบาล/ผู้ช่วยผู้ป่วยต่อกะ ใน modal รายละเอียดวัน */
.shift-summary-row {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.shift-summary-row:first-child {
    margin-top: 0;
}

/* ตารางสรุปการขึ้นเวรรายบุคคล: สีเซลล์ตามรอบเวร */
.shift-cell {
    display: inline-block;
    min-width: 22px;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.8rem;
}
.shift-cell-morning { background: #e0f2fe; color: #0369a1; }
.shift-cell-afternoon { background: #ffedd5; color: #c2410c; }
.shift-cell-night { background: #f3e8ff; color: #6b21a8; }
.shift-cell-off { color: var(--text-light); }

/* พิมพ์ตารางเวรรายเดือน: แสดงเฉพาะ #month-roster-print-area เมื่อสั่งพิมพ์ */
@page {
    size: A4 portrait;
    margin: 5mm;
}
@media print {
    body * {
        visibility: hidden;
    }
    #month-roster-print-area,
    #month-roster-print-area * {
        visibility: visible;
    }
    #month-roster-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 200mm;
        overflow: visible;
        border: 0;
        border-radius: 0;
        color: #000;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    #month-roster-print-area .monthly-roster-heading {
        margin-bottom: 2mm !important;
    }
    #month-roster-print-area .monthly-roster-heading h3 {
        margin: 0;
        font-size: 10pt !important;
        line-height: 1.1;
    }
    #month-roster-print-area .monthly-roster-heading p {
        margin: 0.5mm 0 0;
        font-size: 7pt !important;
        line-height: 1;
        color: #000 !important;
    }
    #month-roster-print-area .monthly-roster-table {
        width: 100%;
        table-layout: fixed;
        font-size: 6.5pt;
        line-height: 1.05;
        page-break-inside: avoid;
    }
    #month-roster-print-area .monthly-roster-table th,
    #month-roster-print-area .monthly-roster-table td {
        padding: 0.45mm 0.8mm;
        border: 0.2mm solid #555;
        color: #000;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    #month-roster-print-area .monthly-roster-table th:first-child,
    #month-roster-print-area .monthly-roster-table td:first-child {
        width: 22mm;
    }
    #month-roster-print-area .monthly-roster-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    #month-roster-print-area .monthly-roster-date,
    #month-roster-print-area .monthly-roster-role {
        font-weight: 700;
    }
    #month-roster-print-area .monthly-roster-signatures {
        margin-top: 2mm !important;
        font-size: 6.5pt !important;
        line-height: 1.05;
    }
    .no-print {
        display: none !important;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    /* จอเล็ก: ย้าย sidebar มาเป็นแถบเมนูแนวนอนด้านบนแทน เพื่อไม่ให้กินพื้นที่แนวนอนของหน้าจอมือถือ */
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        overflow: visible;
        padding: 0.5rem 0.75rem;
    }
    .sidebar-toggle { display: none; }
    .sidebar-brand {
        border-bottom: none;
        border-right: 1px solid var(--card-border);
        margin-bottom: 0;
        padding: 0 0.75rem 0 0;
        margin-right: 0.6rem;
        flex-shrink: 0;
    }
    /* หน้าจอมือถือแคบ: ซ่อนข้อความชื่อระบบ เหลือแค่ไอคอน เพื่อเปิดที่ให้เมนูเลื่อนดูได้เต็มที่ */
    .sidebar-brand .brand-text {
        display: none;
    }
    .sidebar-nav {
        flex-direction: row;
        flex: 1;
        min-width: 0;
        overflow-x: auto;
    }
    .nav-group {
        flex-shrink: 0;
        margin-top: 0;
        padding: 0 0 0 0.5rem;
        border-top: 0;
        border-left: 1px solid var(--card-border);
    }
    .nav-group-heading {
        padding: 0.15rem 0.85rem;
        font-size: 0.75rem;
    }
    .nav-btn {
        white-space: nowrap;
        width: auto;
        flex-shrink: 0;
    }
    .top-bar {
        justify-content: space-between;
        padding: 0.65rem 1rem;
    }
    .header-right {
        justify-content: space-between;
        width: 100%;
    }
}

/* Catalog lists and native modal dialogs */
.catalog-toolbar { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.catalog-toolbar h2, .catalog-toolbar h3 { margin: 0 auto 0 0; }
.catalog-search { margin-bottom: 1rem; }
.catalog-search input { flex: 1; min-width: 160px; width: auto; }
.catalog-search select { width: auto; }
.catalog-pagination { margin-top: 1rem; }
.catalog-pagination > span { margin-right: auto; }
.catalog-page-form { display: flex; align-items: center; gap: .4rem; }
.catalog-page-form input { width: 5rem; }
.catalog-row-actions { min-width: 235px; }
.catalog-row-actions button { margin: .15rem; }
.catalog-dialog { margin: auto; padding: 1.5rem; width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow-y: auto; border: 1px solid var(--card-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); color: var(--text-main); }
.catalog-dialog::backdrop { background: rgb(15 23 42 / 55%); }
.catalog-dialog .catalog-toolbar { margin-bottom: 1rem; }
.catalog-dialog-footer { justify-content: flex-end; margin-top: 1rem; }
.catalog-danger { color: #b91c1c; background: #fff; border: 1px solid #fca5a5; }
.catalog-danger:hover { background: #fee2e2; }
.catalog-notice:empty { display: none; }
.catalog-dialog [hidden] { display: none !important; }
.catalog-color-field { display: flex; align-items: center; gap: .75rem; }
.catalog-color-field input[type="color"] { width: 64px; height: 42px; padding: 3px; border: 1px solid var(--card-border); border-radius: var(--radius-sm); background: #fff; cursor: pointer; }
.catalog-color-field output { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 600; }
.catalog-color-swatch { display: inline-block; width: 1.25rem; height: 1.25rem; margin-right: .5rem; border: 1px solid rgb(15 23 42 / 18%); border-radius: 50%; vertical-align: middle; }
@media (max-width: 640px) { .catalog-search input { flex-basis: 100%; } .catalog-pagination > span { flex-basis: 100%; } }
