/* COLOR VARIABLES */
:root { 
    --primary: #005b7f; 
    --primary-bg: #e0f2f7; 
    --surface: #ffffff; 
    --card: #ffffff;
    --bg: #f2f2f7; 
    --text: #1c1c1e; 
    --text-sec: #8e8e93; 
    --border: #d1d1d6; 
    --divider: #e5e5ea; 
    --success: #34c759; 
    --success-bg: #e8f9ed; 
    --danger: #ff3b30; 
    --danger-bg: #fff5f5; 
    --warning: #ffcc00; 
    --warning-bg: #fffcf0; 
    --info: #5ac8fa; 
    --info-bg: #eaf7ff; 
    --bg-case: #ff9500; 
    --psych: #af52de; 
    --icu: #ff3b30; 
    --pedi: #ff2d55;
    --neuro: #5856d6;
    --logo-cross: #005b7f;
    --radius-l: 16px; 
    --radius-m: 12px; 
    --shadow: 0 2px 8px rgba(0,0,0,0.08); 
    --safe-bottom: env(safe-area-inset-bottom, 20px); 
}

[data-theme="dark"] { 
    --primary: #40a7e3; 
    --primary-bg: #102a38; 
    --surface: #242426; 
    --card: #242426;
    --bg: #000000; 
    --text: #ffffff; 
    --text-sec: #98989d; 
    --border: #444446; 
    --divider: #2c2c2e; 
    --logo-cross: #ffffff; 
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* FIX: Use dvh for mobile browsers, safe-area for notches */
html { min-height: 100%; min-height: 100dvh; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); height: 100%; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
input, select, textarea { font-size: 16px !important; }

header { min-height: 60px; height: calc(60px + env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 16px; padding-top: env(safe-area-inset-top); display: flex; align-items: center; justify-content: space-between; z-index: 50; transition: background 0.3s, border-color 0.3s; flex-shrink: 0; }

.app-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }

/* ACTION BAR STYLES */
.action-bar { display: flex; gap: 8px; padding: 12px 16px; align-items: center; background: var(--bg); position: sticky; top: 0; z-index: 40; flex-shrink: 0; }
.ward-select { flex: 0 1 35%; max-width: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 14px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0; }
.search-container { flex: 1; position: relative; }
.search-container input { width: 100%; padding: 10px 10px 10px 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 0; transition: border-color 0.2s; }
.search-container input:focus { border-color: var(--primary); outline: none; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-sec); font-size: 20px; pointer-events: none; }
.sort-btn { flex: 0 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-sec); transition: color 0.2s, background 0.2s; }
.sort-btn:active { background: var(--divider); color: var(--primary); }

main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 16px 16px 16px; padding-bottom: 140px; -webkit-overflow-scrolling: touch; min-height: 0; display: flex; flex-direction: column; }

.card-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.card { background: var(--surface); border-radius: var(--radius-l); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; border: 1px solid var(--border); position: relative; transition: background 0.3s, border-color 0.3s; }
.card-header { display: flex; justify-content: space-between; margin-bottom: 8px; align-items: center; }
.card-room { background: var(--primary-bg); color: var(--primary); font-weight: 800; padding: 4px 8px; border-radius: 8px; font-size: 13px; }
.card-name { font-size: 17px; font-weight: 600; }
.card-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; min-height: 20px; align-items: center; }

/* ULTRA COMPACT BADGE STYLE FOR MAIN VIEW */
.badge { 
    font-size: 12px; 
    padding: 2px 4px; 
    border-radius: 5px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    border: 1px solid var(--border); 
    color: var(--text); 
    background: var(--bg);
    height: 22px;
    min-width: 22px;
}
.badge.active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.badge.danger { background: #fff5f5; color: var(--danger); border-color: var(--danger); }
[data-theme="dark"] .badge.danger { background: #3d1212; }
.badge.warn { background: #fffcf0; color: var(--bg-case); border-color: var(--bg-case); }
[data-theme="dark"] .badge.warn { background: #3d2a00; }

.badge-icon { font-size: 16px; }

/* Main view: einheitliche Badges (dezenter, monochrom), Bluttropfen gleich groß */
.main-badge { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    width: 24px; 
    height: 24px; 
    border-radius: 6px; 
    color: var(--primary); 
    background: var(--primary-bg); 
    border: 1px solid var(--primary); 
    vertical-align: middle;
}
.main-badge .material-symbols-rounded { font-size: 16px; }
.main-badge.fix-badge { background: var(--bg); color: var(--danger); border-color: var(--danger); }
.main-badge.urgent-badge { background: var(--danger); color: white; border-color: var(--danger); }
.main-badge.comm-badge { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.main-badge.danger-badge { background: #fff5f5; color: var(--danger); border-color: var(--danger); }
.main-badge.blink-icon { font-size: 16px; color: var(--danger); display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; }
.card-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; min-height: 24px; align-items: center; }
.card-badges .main-badge { flex-shrink: 0; }

/* Table view: Badges immer unter dem Patientennamen */
.table-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.table-badges .main-badge { flex-shrink: 0; }

/* Patient bearbeiten: Icon-only Toggle (Privat, Iso, BG, Monitor) */
.icon-only-btn { padding: 10px !important; min-width: 44px !important; justify-content: center !important; }
.icon-only-btn span { font-size: 22px !important; }
.chips-icon-only .toggle-btn { color: var(--text-sec); }
.chips-icon-only .hidden-chk:checked + .toggle-btn { 
    background: var(--primary); 
    color: white !important; 
    border-color: var(--primary); 
}
.chips-icon-only .hidden-chk:checked + .toggle-btn span { 
    color: white !important; 
}
.chips-icon-only .hidden-chk:checked + .danger-toggle { 
    background: var(--danger); 
    color: white !important; 
    border-color: var(--danger); 
}
.chips-icon-only .hidden-chk:checked + .danger-toggle span { 
    color: white !important; 
}
.chips-icon-only .hidden-chk:checked + .warn-toggle { 
    background: var(--warning); 
    color: white !important; 
    border-color: var(--warning); 
}
.chips-icon-only .hidden-chk:checked + .warn-toggle span { 
    color: white !important; 
}

/* MAP inline neben RR */
.rr-with-map { flex-wrap: wrap; gap: 8px; }
.map-inline { font-size: 12px; font-weight: bold; color: var(--primary); white-space: nowrap; align-self: center; }

.card-info { font-size: 13px; color: var(--text-sec); display: grid; grid-template-columns: 1fr auto; gap: 4px; margin-top: 8px; align-items: center; }
.card-section { font-size: 12px; color: var(--text-sec); margin: 4px 0; padding: 2px 0; border-bottom: 1px solid var(--divider); }
.card-section:last-child { border-bottom: none; }
.card-section b { color: var(--text); font-weight: 600; }
.card-actions { border-top: 1px solid var(--divider); margin-top: 12px; padding-top: 8px; display: flex; justify-content: space-around; }
.icon-btn { background: none; border: none; color: var(--text-sec); display: flex; flex-direction: column; align-items: center; font-size: 10px; cursor: pointer; padding: 10px; }
.icon-btn span { font-size: 24px; margin-bottom: 2px; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 200; display: none; backdrop-filter: blur(3px); }
.modal-overlay.open { display: flex; align-items: flex-end; }

.sheet { 
    background: var(--surface); 
    width: 100%; 
    height: 95vh;
    max-height: 100dvh; /* Mobile Browser Fix */
    border-radius: 20px 20px 0 0; 
    display: flex; 
    flex-direction: column; 
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.2);
    transition: background 0.3s, border-color 0.3s;
}

/* FIX FOR INFO MODAL SCROLLING */
#aboutModal .sheet, #archiveModal .sheet { max-height: 90vh; display: flex; flex-direction: column; }
#aboutModal .sheet-content, #archiveModal .sheet-content { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

/* Settings Modal specific structure */
#settingsModal .sheet { max-height: 95vh; display: flex; flex-direction: column; }
#settingsModal .settings-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#settingsModal .settings-content { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-header { padding: 16px; border-bottom: 1px solid var(--divider); display: flex; justify-content: space-between; align-items: center; min-height: 60px; flex-shrink: 0; }
.tab-bar { display: flex; overflow-x: auto; border-bottom: 1px solid var(--divider); background: var(--surface); -webkit-overflow-scrolling: touch; flex-shrink: 0; }
.tab-btn { flex: 1; padding: 14px 16px; background: none; border: none; border-bottom: 3px solid transparent; color: var(--text-sec); font-weight: 500; font-size: 13px; white-space: nowrap; cursor: pointer; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.sheet-content { flex: 1; overflow-y: auto; padding: 16px; background: var(--bg); -webkit-overflow-scrolling: touch; padding-bottom: 80px; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.form-section { background: var(--surface); padding: 16px; border-radius: var(--radius-m); margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); border: 1px solid var(--border); }
.lbl { font-size: 11px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; margin-bottom: 6px; display: block; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); margin-bottom: 4px; }
.field-alert { border: 2px solid var(--danger) !important; background: #fff5f5; }
[data-theme="dark"] .field-alert { background: #3d1212; }
.row { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; }
.col { flex: 1; min-width: 0; }

.hidden-chk { display: none; }
/* STAMMDATEN TOGGLE STYLE - MONOCHROME ICONS */
.toggle-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; background: var(--bg); border: 1px solid var(--border); color: var(--text); cursor: pointer; transition: all 0.2s; user-select: none; flex: 1; min-width: 80px; }
.hidden-chk:checked + .toggle-btn { background: var(--primary); color: white; border-color: var(--primary); }

.hidden-chk:checked + .toggle-btn.danger-toggle { background: var(--danger); border-color: var(--danger); }
.hidden-chk:checked + .toggle-btn.warn-toggle { background: var(--bg-case); border-color: var(--bg-case); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 8px 12px; font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 18px; cursor: pointer; color: var(--text); font-weight: 500; transition: background 0.2s; }
.chip:active, .chip.active { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }

/* DATE SHORTCUTS & INPUT GROUP */
.input-group-row { display: flex; align-items: stretch; width: 100%; gap: 0; }
.input-group-row input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; margin-bottom: 0; }
.input-group-row button { border-radius: 0; border: 1px solid var(--border); border-left: none; background: var(--surface); color: var(--primary); font-weight: 600; padding: 0 12px; font-size: 12px; cursor: pointer; }
.input-group-row button:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }

.date-btns { display: flex; gap: 4px; margin-bottom: 4px; }
.date-btn { font-size: 12px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--primary); font-weight: 500; }

.list-item { background: var(--bg); padding: 12px; border-radius: 8px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; border: 1px solid var(--divider); cursor: pointer; transition: background 0.2s; min-height: 48px; }
.list-item:active { background: #e0e0e0; }
.list-item-content { flex: 1; }
.list-item.stopped { text-decoration: line-through; opacity: 0.6; }
.op-actions { display: flex; gap: 12px; margin-right: 12px; }
.op-icon { font-size: 20px; cursor: pointer; color: var(--text-sec); padding: 4px; transition: color 0.2s; }
.op-icon.active { color: var(--primary); font-variation-settings: 'FILL' 1; }

.btn { padding: 14px 24px; border-radius: 10px; border: none; font-weight: 600; cursor: pointer; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 120px; }
.btn-primary { background: var(--primary); color: white; }
.btn-sec { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; }
.sheet-footer { padding: 24px 16px; border-top: 1px solid var(--divider); background: var(--surface); display: flex; justify-content: center; gap: 20px; padding-bottom: calc(40px + var(--safe-bottom)); flex-shrink: 0; }

.dose-widget { display: flex; gap: 4px; }
.dose-btn { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-weight: 700; font-size: 14px; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.dose-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.app-btn { padding: 8px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; font-weight: 600; font-size: 12px; cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--text); }
.app-btn:active { background: var(--primary-bg); color: var(--primary); }

/* QUICK TIME BUTTON (J for Jetzt) */
.quick-btn { padding: 6px 10px !important; min-width: 32px !important; font-size: 12px !important; border-radius: 6px !important; }

/* INPUT GROUP ROW - Used for date/time with attached buttons */
.input-group-row { display: flex; align-items: stretch; width: 100%; gap: 0; }
.input-group-row input { flex: 1; margin-bottom: 0; }
.input-group-row button { border: 1px solid var(--border); border-left: none; background: var(--primary); color: white; font-weight: 600; padding: 0 12px; font-size: 12px; cursor: pointer; }
.input-group-row button:active { background: var(--primary-dark); }
.input-group-row button:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }

/* FIX TIME ENTRY STYLES */
.fix-time-item { background: var(--surface); padding: 8px; border-radius: 8px; margin-bottom: 6px; font-size: 12px; border: 1px solid var(--divider); }
.fix-time-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fix-date { width: 110px !important; font-size: 12px !important; padding: 4px 6px !important; }
.fix-time { width: 80px !important; font-size: 12px !important; padding: 4px 6px !important; }
.fix-duration { color: var(--text-sec); font-size: 11px; white-space: nowrap; }
.fix-delete { font-size: 18px !important; }
.rr-group { display: flex; align-items: center; gap: 6px; width: 100%; }
.rr-group input { text-align: center; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }
.blink-icon { animation: blink 1.5s infinite; color: var(--danger); font-weight: bold; }
/* Flash animation for Rea Timer */
@keyframes flashRed { 0% { background: var(--bg); } 50% { background: rgba(255, 59, 48, 0.3); } 100% { background: var(--bg); } }
.flash-active { animation: flashRed 1s infinite; }

/* INTELLIGENT BLOOD DROP STYLING */
.blood-icon { 
    font-size: 18px; 
    margin-right: 4px; 
    transition: all 0.3s; 
    color: var(--danger);
}
/* Blinking animation for blood icon */
@keyframes bloodBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
}
@keyframes bloodBlinkActive {
    0%, 100% { opacity: 1; color: #fff; text-shadow: 0 0 8px rgba(255,255,255,0.8); }
    50% { opacity: 0.7; color: #ffcccc; text-shadow: 0 0 12px rgba(255,255,255,1); }
}
/* Blink when not checked */
.blood-icon {
    animation: bloodBlink 2s infinite;
}
/* When checked - button is red, icon blinks differently */
#chkTransfusion:checked + .toggle-btn {
    background: var(--danger) !important;
    color: #fff !important;
    border-color: var(--danger) !important;
}
#chkTransfusion:checked + .toggle-btn .blood-icon {
    animation: bloodBlinkActive 1s infinite;
    color: #fff;
}

/* HIDE MODULES via CSS */
body.hide-diag .sec-diag, body.hide-vital .sec-vital, body.hide-o2 .sec-o2, body.hide-lines .sec-lines,
body.hide-med .sec-med, body.hide-labReq .sec-labReq, body.hide-lab .sec-lab, body.hide-micro .sec-micro,
body.hide-ops .sec-ops, body.hide-img .sec-img, body.hide-drain .sec-drain, body.hide-wound .sec-wound,
body.hide-dis .sec-dis, body.hide-physio .sec-physio, body.hide-social .sec-social, body.hide-docs .sec-docs,
body.hide-todo .sec-todo, body.hide-comm .sec-comm, body.hide-status .sec-status, body.hide-noxen .sec-noxen,
body.hide-pathology .sec-pathology, body.hide-ep .sec-ep { display: none !important; }

/* NEW FINE GRAINED MODULES */
body.hide-psychStatus .sec-psych-status,
body.hide-psychLegal .sec-psych-legal,
body.hide-vent .sec-vent,
body.hide-perf .sec-perf,
body.hide-nutri .sec-icu-nutri,
body.hide-rass .sec-rass,
body.hide-fixierung .sec-fixierung { display: none !important; }

/* HIDE TABLE COLUMNS */
body.hide-diag .col-diag, body.hide-vital .col-vital, body.hide-med .col-med, body.hide-todo .col-orga, body.hide-ops .col-interv { display: none !important; }

/* HIDE TABS via CSS */
body.hide-tab-status #btnTabStatus,
body.hide-tab-vital #btnTabVital,
body.hide-tab-therapy #btnTabTherapy,
body.hide-tab-verlauf #btnTabVerlauf,
body.hide-tab-orga #btnTabOrga,
body.hide-tab-psych #btnTabPsych,
body.hide-tab-intensiv #btnTabIntensiv,
body.hide-tab-pediatrie #btnTabPediatrie,
body.hide-tab-images #btnEditImages,
body.hide-tab-images #btnEditImagesV,
body.hide-tab-kurve #btnEditKurve,
body.hide-tab-kurve #btnEditKurveV { display: none !important; }

/* PROFILES (Ward specific logic handles applying these classes) */
.only-psych, .only-icu { display: none; }

/* HANDOVER MODE STYLES */
#handoverOverlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: var(--bg); z-index: 500; overflow-y: auto; padding: 20px; 
    display: none; 
}
#handoverOverlay.open { display: block; }
.handover-card {
    background: var(--surface); border-radius: 12px; padding: 16px; margin-bottom: 12px; border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer; /* Clickable */
    transition: transform 0.2s, box-shadow 0.2s;
}
.handover-card:active { transform: scale(0.98); background: var(--bg); }
.handover-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.handover-sub { font-size: 14px; color: var(--text-sec); margin-bottom: 8px; }
.handover-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; margin-bottom: 8px; }
.handover-section { font-size: 13px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--divider); line-height: 1.4; }
.handover-section b { color: var(--primary); font-weight: 600; }

/* CAVE Warning Box */
.handover-cave {
    animation: pulse-cave 2s ease-in-out infinite;
}
@keyframes pulse-cave {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(244, 67, 54, 0.1); }
}

/* Compact section layout for handover */
.handover-card .handover-section:last-child {
    border-bottom: none;
}

/* Visual indicators for urgent items */
.handover-section.urgent {
    background: rgba(244, 67, 54, 0.1);
    padding: 6px 8px;
    border-radius: 6px;
    border-left: 3px solid var(--danger);
}

/* Success/Discharge styling */
.handover-section.success {
    color: var(--success);
}

/* Grid layout for multiple sections */
.handover-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.handover-grid .handover-section {
    margin: 0;
    padding: 8px;
    background: var(--bg);
    border-radius: 8px;
    border-top: none;
}

/* Dashboard Styles */
.dash-card { background: var(--bg); border-radius: 8px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--border); }
.dash-header { font-weight: bold; color: var(--primary); margin-bottom: 4px; display: flex; justify-content: space-between; }
.dash-item { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; font-size: 13px; cursor: pointer; user-select: none; }
.dash-item.done { text-decoration: line-through; opacity: 0.5; }
.dash-item.done::before { content: 'check_circle'; font-family: 'Material Symbols Rounded'; font-weight: bold; color: var(--success); }
.dash-item::before { content: 'radio_button_unchecked'; font-family: 'Material Symbols Rounded'; font-weight: bold; color: var(--text-sec); }
.dash-group-header { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-sec); margin-top: 12px; margin-bottom: 6px; border-bottom: 1px solid var(--divider); padding-bottom: 2px; }

.dash-controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; background: var(--bg); padding: 8px; border-radius: 12px; border: 1px solid var(--border); }
.dash-date-btn { background: none; border: none; padding: 8px; cursor: pointer; color: var(--primary); display: flex; align-items: center; border-radius: 8px; }
.dash-date-btn:active { background: var(--divider); }

.dash-today-btn { border: 2px solid var(--primary); color: var(--primary); background: transparent; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.dash-today-btn:active { background: var(--primary-bg); }

.dash-date-display { 
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    min-width: 160px;
}
.dash-date-text {
    font-weight: 700;
    color: var(--text);
    font-size: 15px;
    text-align: center;
    pointer-events: none;
}
.dash-date-hidden-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

/* Dashboard Notes Styles */
.dash-notes-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dash-notes-input-area {
    background: var(--bg);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.dash-note-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
    background: var(--surface);
    color: var(--text);
}
.dash-note-textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.dash-notes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dash-note-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.dash-note-item.done {
    opacity: 0.6;
}
.dash-note-item.done .dash-note-text {
    text-decoration: line-through;
}
.dash-note-content {
    flex: 1;
    min-width: 0;
}
.dash-note-text {
    font-size: 14px;
    color: var(--text);
    word-break: break-word;
    cursor: pointer;
}
.dash-note-text:hover {
    color: var(--primary);
}
.dash-note-meta {
    font-size: 11px;
    color: var(--text-sec);
    margin-top: 4px;
}
.dash-note-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.icon-btn-small {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-sec);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn-small:hover {
    background: var(--divider);
    color: var(--primary);
}
.icon-btn-small.danger:hover {
    color: var(--danger);
}
.icon-btn-small .material-symbols-rounded {
    font-size: 20px;
}

/* ROOM SEPARATOR STYLES */
.room-divider { 
    height: 1px; 
    margin: 24px 16px; 
    background-color: var(--border); 
    border: none; 
    position: relative;
    opacity: 0.6;
}

.table-room-divider td {
    background-color: var(--bg);
    height: 12px;
    padding: 0;
    border: none;
    border-bottom: 1px solid var(--divider);
}

/* Legal Details */
details {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    background: var(--bg);
}
details summary {
    font-weight: 600;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
}
details div {
    padding: 8px;
    font-size: 12px;
    line-height: 1.4;
    border-top: 1px solid var(--divider);
    margin-top: 8px;
    color: var(--text);
}

/* SORTABLE LIST STYLES */
.sort-list-item {
    display: flex;
    align-items: center;
    background: var(--bg);
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
}
.sort-list-item .toggle-btn {
    margin: 0;
    flex: 1;
    justify-content: flex-start;
    padding: 6px 12px;
    height: auto;
    min-width: auto;
}
.sort-controls {
    display: flex;
    flex-direction: row; /* UPDATED: SIDE BY SIDE */
    gap: 8px;
    margin-left: 8px;
    min-width: 80px; /* Ensure space for visibility hidden buttons */
    justify-content: flex-end;
}
.sort-arrow {
    background: var(--surface); border: 1px solid var(--border); padding: 4px; color: var(--text-sec); cursor: pointer;
    line-height: 0; border-radius: 6px;
}
.sort-arrow:hover { color: var(--primary); background: var(--primary-bg); }

/* SLIDER STYLE FOR RASS */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    margin-bottom: 12px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--border);
    border-radius: 2px;
}

/* NEW EMPTY STATE STYLE */
.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-sec);
    display: none;
}
.empty-illustration {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    opacity: 0.8;
}
.empty-state-container h3 {
    margin: 0 0 8px 0;
    color: var(--text);
    font-size: 18px;
}
.empty-state-container p {
    margin: 0 0 24px 0;
    font-size: 14px;
    max-width: 300px;
}

/* TOOL ITEM STYLE (MATCHING TOGGLES) */
.tool-item {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: 10px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.tool-item label,
.tool-item .gcs-label,
.tool-item .sofa-label {
    margin: 0;
    border: none;
    background: transparent;
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: bold;
    color: var(--primary);
    padding: 8px 10px;
    text-align: center;
}
.tool-item select {
    flex: 1;
    min-width: 0;
}
.hidden-chk:checked + label {
    background: var(--primary-bg);
    color: var(--primary);
}
.check-mark {
    opacity: 0;
    transition: opacity 0.2s;
}
.hidden-chk:checked + label .check-mark {
    opacity: 1;
}


@media (min-width: 1024px) {
    .card-view { display: none; }
    .sheet { width: 800px; height: 90vh; margin: auto; position: relative; top: 5vh; border-radius: 20px; }
    .modal-overlay.open { align-items: flex-start; }
    main { padding-bottom: 20px; }
}
.table-view { display: none; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); overflow-y: auto; max-height: calc(100vh - 180px); }
@media (min-width: 1024px) { .table-view { display: block; } }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--divider); vertical-align: top; font-size: 14px; }
th { background: var(--bg); font-weight: 600; color: var(--text-sec); white-space: nowrap; }

.sm-icon-btn { padding: 8px; border: none; background: var(--surface); border-radius: 8px; cursor: pointer; color: var(--text-sec); display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; }
.sm-icon-btn:hover { background: var(--divider); color: var(--primary); }

/* UNSAVED CHANGES MODAL */
.confirm-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.confirm-actions button { width: 100%; }

/* DISCLAIMER BOX */
.disclaimer-box { background: #fff3e0; border: 1px solid #ffb74d; padding: 16px; border-radius: 12px; margin-bottom: 16px; color: #e65100; }
.disclaimer-box .lbl { color: #e65100; }
.disclaimer-box p { color: #333; }

[data-theme="dark"] .disclaimer-box { background: #3d2200; border-color: #8a5a00; color: #ffcc80; }
[data-theme="dark"] .disclaimer-box .lbl { color: #ffcc80; }
[data-theme="dark"] .disclaimer-box p { color: #e0e0e0; }

/* UPDATE CHECK RESULT */
.update-result { margin-top: 8px; }
.update-result.update-success { background: var(--primary-bg); border-color: var(--success) !important; color: var(--text); }
.update-result.update-error { background: rgba(255,59,48,0.1); border-color: var(--danger) !important; color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

/* QR SCANNER PREVIEW */
#qr-reader {
    width: 100%;
    max-width: 400px;
    border-radius: 12px;
    overflow: hidden;
    margin: 0 auto;
    background: #000;
}

/* --- PRINT STYLES V2 (OPTIMIZED HANDOVER LIST) --- */
@media print {
    @page { size: landscape; margin: 10mm; }
    body { background: white; color: black; font-family: 'Helvetica Neue', Arial, sans-serif; height: auto; overflow: visible; }
    header, .sheet, .modal-overlay, .fab, button, div[style*="fixed"], .search-wrapper, #emptyState, .app-logo, .chips, #handoverOverlay, #toolModal, #archiveModal, #shareModal, .action-bar { display: none !important; }
    
    main { padding: 0; overflow: visible; }
    .card-view { display: none !important; }
    .table-view { display: block !important; box-shadow: none; border-radius: 0; overflow: visible; }
    
    table { width: 100%; border-collapse: collapse; font-size: 10pt; }
    th, td { border: 1px solid #000; padding: 4px; vertical-align: top; text-align: left; background: white !important; color: black !important; }
    th { font-weight: bold; background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    
    th[data-i18n="room"] { width: 40px; }
    th[data-i18n="pat"] { width: 150px; }
    th[data-i18n="todo"] { width: 100px; }
    
    .badge, .chip { border: 1px solid #000; color: #000 !important; background: transparent !important; padding: 1px 3px; font-size: 9pt; border-radius: 3px; }
    .list-item { border: none; padding: 0; margin: 0; background: transparent; }
    .blink-icon { animation: none; color: black; font-weight: bold; }
    
    * { color: #000 !important; }
}

/* === SETTINGS MODAL NAVIGATION STYLES === */

/* Settings Container with flexible layout */
.settings-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    min-height: 0;
}

/* ===== EDIT MODAL NAVIGATION (Similar to Settings) ===== */

/* Edit Modal specific structure */
#editModal .sheet { max-height: 95vh; display: flex; flex-direction: column; }
#editModal .edit-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#editModal .edit-content { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

/* Horizontal Tab Navigation (default for portrait/mobile) */
.edit-nav-horizontal {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--divider);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.edit-nav-horizontal .edit-nav-btn {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    transition: all 0.2s;
}

.edit-nav-horizontal .edit-nav-btn .material-symbols-rounded {
    font-size: 22px;
}

.edit-nav-horizontal .edit-nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
    background: var(--primary-bg);
}

.edit-nav-horizontal .edit-nav-btn:active {
    background: var(--divider);
}

/* Vertical Sidebar Navigation (for landscape/tablet) */
.edit-nav-vertical {
    display: none;
    flex-direction: column;
    width: 80px;
    background: var(--surface);
    border-right: 1px solid var(--divider);
    flex-shrink: 0;
    overflow-y: auto;
    padding: 8px 0;
}

.edit-nav-vertical .edit-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
    cursor: pointer;
    gap: 6px;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
}

.edit-nav-vertical .edit-nav-btn .material-symbols-rounded {
    font-size: 26px;
}

.edit-nav-vertical .edit-nav-btn.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-bg);
    font-weight: 700;
}

.edit-nav-vertical .edit-nav-btn:active {
    background: var(--divider);
}

/* Edit Content Area */
.edit-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 80px;
    background: var(--bg);
}

/* Edit Body with Sidebar Layout */
.edit-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
}

.edit-body.with-sidebar {
    flex-direction: row;
}

.edit-body.with-sidebar .edit-content {
    flex: 1;
    border-left: 1px solid var(--divider);
    min-width: 0;
}

/* ===== SETTINGS MODAL NAVIGATION ===== */

/* Horizontal Tab Navigation (default for portrait/mobile) */
.settings-nav-horizontal {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--divider);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.settings-nav-horizontal .settings-nav-btn {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    transition: all 0.2s;
}

.settings-nav-horizontal .settings-nav-btn .material-symbols-rounded {
    font-size: 22px;
}

.settings-nav-horizontal .settings-nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
    background: var(--primary-bg);
}

.settings-nav-horizontal .settings-nav-btn:active {
    background: var(--divider);
}

/* Vertical Sidebar Navigation (for landscape/tablet) */
.settings-nav-vertical {
    display: none;
    flex-direction: column;
    width: 80px;
    background: var(--surface);
    border-right: 1px solid var(--divider);
    flex-shrink: 0;
    overflow-y: auto;
    padding: 8px 0;
}

.settings-nav-vertical .settings-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
    cursor: pointer;
    gap: 6px;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
}

.settings-nav-vertical .settings-nav-btn .material-symbols-rounded {
    font-size: 26px;
}

.settings-nav-vertical .settings-nav-btn.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-bg);
    font-weight: 700;
}

.settings-nav-vertical .settings-nav-btn:active {
    background: var(--divider);
}

/* Settings Content Area */
.settings-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 80px;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

/* Settings Body with Sidebar Layout */
.settings-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
}

.settings-body.with-sidebar {
    flex-direction: row;
}

.settings-body.with-sidebar .settings-content {
    flex: 1;
    border-left: 1px solid var(--divider);
    min-width: 0;
}

/* Layout Mode Switcher in Settings */
.settings-layout-switcher {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
    padding: 8px;
    background: var(--bg);
    border-radius: 12px;
}

.settings-layout-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-sec);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-layout-option.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.settings-layout-option .material-symbols-rounded {
    font-size: 18px;
}

/* Auto Layout Indicator */
.settings-auto-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-sec);
    padding: 6px 10px;
    background: var(--primary-bg);
    border-radius: 6px;
    margin-bottom: 12px;
}

.settings-auto-indicator .material-symbols-rounded {
    font-size: 16px;
    color: var(--primary);
}

/* Theme Toggle Button in Settings */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--surface) 100%);
    border: 2px solid var(--primary);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}

.theme-toggle-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 91, 127, 0.3);
}

.theme-toggle-btn:active {
    transform: translateY(0);
}

.theme-toggle-btn .material-symbols-rounded {
    font-size: 24px;
    transition: transform 0.3s ease;
}

.theme-toggle-btn:hover .material-symbols-rounded {
    transform: rotate(15deg);
}

/* Dark mode variant styling */
[data-theme="dark"] .theme-toggle-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, var(--surface) 100%);
    border-color: var(--primary);
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background: var(--primary);
    color: white;
}

/* Settings Action Buttons - New Design Language */
.settings-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--surface) 100%);
    border: 2px solid var(--primary);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.settings-action-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 91, 127, 0.3);
}

.settings-action-btn:active {
    transform: translateY(0);
}

.settings-action-btn .material-symbols-rounded {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.settings-action-btn:hover .material-symbols-rounded {
    transform: scale(1.1);
}

/* Danger variant */
.settings-action-btn.danger {
    background: linear-gradient(135deg, var(--danger-bg) 0%, var(--surface) 100%);
    border-color: var(--danger);
    color: var(--danger);
}

.settings-action-btn.danger:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* Success variant */
.settings-action-btn.success {
    background: linear-gradient(135deg, var(--success-bg) 0%, var(--surface) 100%);
    border-color: var(--success);
    color: var(--success);
}

.settings-action-btn.success:hover {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Secondary variant */
.settings-action-btn.secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.settings-action-btn.secondary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 91, 127, 0.3);
}

/* Dark mode adjustments */
[data-theme="dark"] .settings-action-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, var(--surface) 100%);
}

[data-theme="dark"] .settings-action-btn:hover {
    background: var(--primary);
    color: white;
}

[data-theme="dark"] .settings-action-btn.danger {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1) 0%, var(--surface) 100%);
}

[data-theme="dark"] .settings-action-btn.danger:hover {
    background: var(--danger);
}

/* Small inline action buttons */
.settings-inline-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-inline-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.settings-inline-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.settings-inline-btn.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.settings-inline-btn .material-symbols-rounded {
    font-size: 18px;
}

/* Print Section Styling */
.settings-print-section {
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--surface) 100%);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.settings-print-section .print-icon {
    font-size: 48px;
    color: var(--primary);
    display: block;
    text-align: center;
    margin-bottom: 12px;
}

/* Admission Quick Actions */
.admit-quick-actions {
    display: flex;
    gap: 8px;
}

/* Collapsible Finding Item */
.finding-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
}

.finding-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.finding-item-header:hover {
    background: var(--bg);
}

.finding-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.finding-item-title .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}

.finding-item-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.finding-item-toggle .material-symbols-rounded {
    font-size: 20px;
    transition: transform 0.2s ease;
}

.finding-item.expanded .finding-item-toggle .material-symbols-rounded {
    transform: rotate(180deg);
}

.finding-item-content {
    display: none;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.finding-item.expanded .finding-item-content {
    display: block;
}

.finding-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* Lab History Table */
.lab-history-container {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.lab-table-wrapper {
    max-width: 100%;
}

.lab-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.lab-table th {
    background: var(--primary-bg);
    padding: 8px;
    text-align: center;
    border: 1px solid var(--border);
    font-weight: 600;
    color: var(--primary);
}

.lab-table td {
    padding: 6px 8px;
    border: 1px solid var(--border);
}

.lab-table td:first-child {
    background: var(--bg);
    font-weight: 500;
}

.lab-table input {
    width: 100%;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
}

.lab-table input:focus {
    outline: 2px solid var(--primary);
    border-radius: 4px;
    background: var(--bg);
}

.lab-table input::placeholder {
    color: var(--text-sec);
    opacity: 0.5;
}

/* Responsive Layout Switching */
@media (min-width: 768px) and (orientation: landscape) {
    /* Settings Modal */
    .settings-nav-vertical {
        display: flex;
    }
    
    .settings-nav-horizontal {
        display: none;
    }
    
    .settings-body {
        flex-direction: row !important;
    }
    
    .settings-content {
        padding: 20px;
        flex: 1;
        min-width: 0;
        display: block;
    }
    
    /* Edit Modal */
    .edit-nav-vertical {
        display: flex;
    }
    
    .edit-nav-horizontal {
        display: none;
    }
    
    .edit-body {
        flex-direction: row !important;
    }
    
    .edit-content {
        padding: 20px;
        flex: 1;
        min-width: 0;
        display: block;
    }
    
    /* Tools Modal */
    .tools-nav-vertical {
        display: flex;
    }
    
    .tools-nav-horizontal {
        display: none;
    }
    
    .tools-body {
        flex-direction: row !important;
    }
    
    .tools-content {
        padding: 20px;
        flex: 1;
        min-width: 0;
        display: block;
    }
    
    /* Dashboard Modal */
    .dash-nav-vertical {
        display: flex;
    }
    
    .dash-nav-horizontal {
        display: none;
    }
    
    .dash-body {
        flex-direction: row !important;
    }
    
    .dash-content {
        padding: 20px;
        flex: 1;
        min-width: 0;
        display: block;
    }
}

/* Force Horizontal Layout - Settings */
.settings-force-horizontal .settings-nav-horizontal {
    display: flex;
}

.settings-force-horizontal .settings-nav-vertical {
    display: none;
}

.settings-force-horizontal .settings-body {
    flex-direction: column;
}

/* Force Vertical Layout - Settings */
.settings-force-vertical .settings-nav-horizontal {
    display: none;
}

.settings-force-vertical .settings-nav-vertical {
    display: flex;
}

.settings-force-vertical .settings-body,
.settings-body.force-row {
    flex-direction: row !important;
}

.settings-force-vertical .settings-content,
.settings-body.force-row .settings-content {
    flex: 1;
    min-width: 0;
    display: block;
}

/* Force Horizontal Layout - Edit */
.edit-force-horizontal .edit-nav-horizontal {
    display: flex;
}

.edit-force-horizontal .edit-nav-vertical {
    display: none;
}

.edit-force-horizontal .edit-body {
    flex-direction: column;
}

/* Force Vertical Layout - Edit */
.edit-force-vertical .edit-nav-horizontal {
    display: none;
}

.edit-force-vertical .edit-nav-vertical {
    display: flex;
}

.edit-force-vertical .edit-body,
.edit-body.force-row {
    flex-direction: row !important;
}

.edit-force-vertical .edit-content,
.edit-body.force-row .edit-content {
    flex: 1;
    min-width: 0;
    display: block;
}

/* ===== TOOLS MODAL NAVIGATION (Similar to Settings) ===== */

/* Tools Modal specific structure */
#toolModal .sheet { max-height: 95vh; display: flex; flex-direction: column; }
#toolModal .tools-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#toolModal .tools-content { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

/* Horizontal Tab Navigation (default for portrait/mobile) */
.tools-nav-horizontal {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--divider);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.tools-nav-horizontal .tools-nav-btn {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    transition: all 0.2s;
}

.tools-nav-horizontal .tools-nav-btn .material-symbols-rounded {
    font-size: 22px;
}

.tools-nav-horizontal .tools-nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
    background: var(--primary-bg);
}

.tools-nav-horizontal .tools-nav-btn:active {
    background: var(--divider);
}

/* Vertical Sidebar Navigation (for landscape/tablet) */
.tools-nav-vertical {
    display: none;
    flex-direction: column;
    width: 80px;
    background: var(--surface);
    border-right: 1px solid var(--divider);
    flex-shrink: 0;
    overflow-y: auto;
    padding: 8px 0;
}

.tools-nav-vertical .tools-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
    cursor: pointer;
    gap: 6px;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
}

.tools-nav-vertical .tools-nav-btn .material-symbols-rounded {
    font-size: 26px;
}

.tools-nav-vertical .tools-nav-btn.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-bg);
    font-weight: 700;
}

.tools-nav-vertical .tools-nav-btn:active {
    background: var(--divider);
}

/* ============================================
   AI INTEGRATION STYLES
   ============================================ */

/* AI Trigger Button in Edit Modal Header */
.sheet-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-trigger-btn {
    position: relative;
    color: var(--primary);
    transition: all 0.2s ease;
}

.ai-trigger-btn:hover {
    background: var(--primary-bg);
}

.ai-trigger-btn.loading {
    animation: pulse 1.5s infinite;
}

.ai-trigger-btn .material-symbols-rounded {
    font-size: 24px;
}

/* AI Action Menu */
.ai-action-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--surface);
    border-radius: var(--radius-m);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    border: 1px solid var(--border);
}

.ai-action-menu-header {
    padding: 12px 16px;
    background: var(--primary-bg);
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-action-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: background 0.2s;
}

.ai-action-menu-item:hover {
    background: var(--bg);
}

.ai-action-menu-item:active {
    background: var(--divider);
}

.ai-action-menu-item .material-symbols-rounded {
    font-size: 20px;
    color: var(--text-sec);
}

.ai-action-menu-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* AI Warning Banners */
.ai-warning-banner {
    padding: 12px 16px;
    border-radius: var(--radius-m);
    margin: 12px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.4;
}

.ai-warning-banner.critical {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.ai-warning-banner.warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    color: #8a6914;
}

.ai-warning-banner.info {
    background: var(--info-bg);
    border: 1px solid var(--info);
    color: #0077a3;
}

.ai-warning-banner .material-symbols-rounded {
    font-size: 24px;
    flex-shrink: 0;
}

.ai-warning-content {
    flex: 1;
}

.ai-warning-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.ai-warning-reason {
    font-size: 13px;
    opacity: 0.9;
}

.ai-warning-dismiss {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.ai-warning-dismiss:hover {
    opacity: 1;
}

/* AI Model Download Dialog */
.ai-download-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.ai-download-content {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.ai-download-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--primary-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-download-icon .material-symbols-rounded {
    font-size: 32px;
    color: var(--primary);
}

.ai-download-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.ai-download-desc {
    font-size: 14px;
    color: var(--text-sec);
    margin-bottom: 20px;
    line-height: 1.5;
}

.ai-download-progress {
    height: 8px;
    background: var(--divider);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.ai-download-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.ai-download-status {
    font-size: 13px;
    color: var(--text-sec);
    margin-bottom: 20px;
}

.ai-download-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ai-download-actions button {
    padding: 10px 24px;
    border-radius: var(--radius-m);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-download-actions .btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.ai-download-actions .btn-primary:hover {
    opacity: 0.9;
}

.ai-download-actions .btn-secondary {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
}

.ai-download-actions .btn-secondary:hover {
    background: var(--bg);
}

/* AI Settings Panel */
.ai-settings-section {
    padding: 16px;
}

.ai-settings-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-settings-header .material-symbols-rounded {
    font-size: 28px;
    color: var(--primary);
}

.ai-settings-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.ai-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
}

.ai-toggle-label {
    font-size: 15px;
    font-weight: 500;
}

.ai-toggle-switch {
    position: relative;
    width: 51px;
    height: 31px;
}

.ai-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 31px;
}

.ai-toggle-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.ai-toggle-switch input:checked + .ai-toggle-slider {
    background-color: var(--success);
}

.ai-toggle-switch input:checked + .ai-toggle-slider:before {
    transform: translateX(20px);
}

.ai-model-status {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-m);
    margin-top: 16px;
}

.ai-model-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin-bottom: 8px;
}

.ai-model-status-row:last-child {
    margin-bottom: 0;
}

.ai-model-status-label {
    color: var(--text-sec);
}

.ai-model-status-value {
    font-weight: 500;
}

.ai-model-status-value.ready {
    color: var(--success);
}

.ai-model-status-value.not-ready {
    color: var(--warning);
}

.ai-model-status-value.error {
    color: var(--danger);
}

.ai-functions-list {
    margin-top: 16px;
}

.ai-functions-list h4 {
    font-size: 14px;
    color: var(--text-sec);
    margin-bottom: 12px;
}

.ai-function-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-m);
    margin-bottom: 8px;
    font-size: 14px;
}

.ai-function-item .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}

.ai-privacy-notice {
    margin-top: 20px;
    padding: 12px;
    background: var(--success-bg);
    border-radius: var(--radius-m);
    font-size: 13px;
    color: #1a7f3c;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.4;
}

.ai-privacy-notice .material-symbols-rounded {
    font-size: 20px;
    flex-shrink: 0;
}

/* AI Processing Overlay */
.ai-processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.ai-processing-content {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 24px 32px;
    text-align: center;
}

.ai-processing-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--divider);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ai-processing-text {
    font-size: 15px;
    color: var(--text);
}

/* AI Result Panel */
.ai-result-panel {
    background: var(--surface);
    border-radius: var(--radius-m);
    border: 1px solid var(--border);
    margin: 12px 0;
    overflow: hidden;
}

.ai-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.ai-result-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.ai-result-title .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}

.ai-result-actions {
    display: flex;
    gap: 8px;
}

.ai-result-actions button {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-sec);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-result-actions button:hover {
    color: var(--primary);
}

.ai-result-body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.ai-result-body pre {
    white-space: pre-wrap;
    font-family: inherit;
    margin: 0;
}

/* Tools Content Area */
.tools-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 80px;
    background: var(--bg);
}

/* Tools Body with Sidebar Layout */
.tools-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
}

.tools-body.with-sidebar {
    flex-direction: row;
}

.tools-body.with-sidebar .tools-content {
    flex: 1;
    border-left: 1px solid var(--divider);
    min-width: 0;
}

/* ===== DASHBOARD MODAL NAVIGATION (Similar to Settings) ===== */

/* Dashboard Modal specific structure */
#dashModal .sheet { max-height: 95vh; display: flex; flex-direction: column; position: relative; overflow: hidden; }
#dashModal .dash-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#dashModal .dash-content { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; padding-bottom: 80px; }

/* Dashboard Quick Action Buttons */
.dash-quick-actions {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.dash-quick-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background 0.2s;
}

.dash-quick-btn:hover {
    transform: scale(1.1);
    background: var(--primary-dark, #1565c0);
}

.dash-quick-btn:active {
    transform: scale(0.95);
}

.dash-quick-btn .material-symbols-rounded {
    font-size: 24px;
}

/* Desktop: Quick actions within sheet */
@media (min-width: 1024px) {
    .dash-quick-actions {
        position: absolute;
        right: 16px;
        bottom: 16px;
    }
}

/* Horizontal Tab Navigation (default for portrait/mobile) */
.dash-nav-horizontal {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--divider);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.dash-nav-horizontal .dash-nav-btn {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    transition: all 0.2s;
}

.dash-nav-horizontal .dash-nav-btn .material-symbols-rounded {
    font-size: 22px;
}

.dash-nav-horizontal .dash-nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
    background: var(--primary-bg);
}

.dash-nav-horizontal .dash-nav-btn:active {
    background: var(--divider);
}

/* Vertical Sidebar Navigation (for landscape/tablet) */
.dash-nav-vertical {
    display: none;
    flex-direction: column;
    width: 80px;
    background: var(--surface);
    border-right: 1px solid var(--divider);
    flex-shrink: 0;
    overflow-y: auto;
    padding: 8px 0;
}

.dash-nav-vertical .dash-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
    cursor: pointer;
    gap: 6px;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
}

.dash-nav-vertical .dash-nav-btn .material-symbols-rounded {
    font-size: 26px;
}

.dash-nav-vertical .dash-nav-btn.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-bg);
    font-weight: 700;
}

.dash-nav-vertical .dash-nav-btn:active {
    background: var(--divider);
}

/* Dashboard Content Area */
.dash-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 80px;
    background: var(--bg);
}

/* Dashboard Body with Sidebar Layout */
.dash-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
}

.dash-body.with-sidebar {
    flex-direction: row;
}

.dash-body.with-sidebar .dash-content {
    flex: 1;
    border-left: 1px solid var(--divider);
    min-width: 0;
}

/* Compact Section Headers */
.settings-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--divider);
}

.settings-section-header .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}

.settings-section-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

/* ============================================
   AI INTEGRATION EXTENSION STYLES
   ============================================ */

/* AI Scan Button */
.ai-scan-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.ai-scan-btn:hover {
    background: var(--primary);
    color: white;
}

.ai-scan-btn .material-symbols-rounded {
    font-size: 18px;
}

/* Voice Input Button */
.voice-input-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-sec);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 5;
}

.voice-input-btn:hover {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary);
}

.voice-input-btn.active {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    animation: voice-pulse 1.5s infinite;
}

@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255, 59, 48, 0); }
}

.voice-input-btn .material-symbols-rounded {
    font-size: 18px;
}

/* AI Lab Warnings Container */
.ai-lab-warnings {
    background: var(--surface);
    border-radius: var(--radius-m);
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-lab-warnings-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
}

.ai-lab-warnings-header .material-symbols-rounded {
    font-size: 18px;
}

.ai-lab-warnings-header .settings-inline-btn {
    margin-left: auto;
    padding: 4px;
    background: transparent;
    border: none;
}

.ai-lab-warnings-content {
    padding: 8px;
}

.ai-lab-warning {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.ai-lab-warning:last-child {
    margin-bottom: 0;
}

.ai-lab-warning.critical {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.ai-lab-warning.warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    color: #8a6914;
}

.ai-lab-warning .material-symbols-rounded {
    font-size: 20px;
    flex-shrink: 0;
}

.ai-lab-warning .warning-content strong {
    display: block;
    margin-bottom: 4px;
}

.ai-lab-warning .warning-content p {
    margin: 0;
}

.ai-lab-warning .recommendation {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed currentColor;
    font-style: italic;
    opacity: 0.8;
}

/* AI Analyze Button */
.ai-analyze-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--primary-bg), var(--info-bg));
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.ai-analyze-btn:hover {
    background: var(--primary);
    color: white;
}

.ai-analyze-btn .material-symbols-rounded {
    font-size: 16px;
}

/* Camera Container */
.camera-container {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.camera-container video {
    width: 100%;
    display: block;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 80%;
    height: 60%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    position: relative;
}

.scan-frame::before,
.scan-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: var(--primary);
    border-style: solid;
}

.scan-frame::before {
    top: -2px;
    left: -2px;
    border-width: 3px 0 0 3px;
    border-radius: 12px 0 0 0;
}

.scan-frame::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 3px 3px 0;
    border-radius: 0 0 12px 0;
}

.camera-tips {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--info-bg);
    border-radius: 8px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-sec);
}

.camera-tips .material-symbols-rounded {
    font-size: 18px;
    color: var(--info);
}

/* Recording Indicator */
.ai-recording-indicator {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: white;
    padding: 10px 20px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    box-shadow: 0 4px 16px rgba(255, 59, 48, 0.3);
    animation: slideDown 0.3s ease;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.recording-text {
    font-weight: 500;
    font-size: 14px;
}

.recording-interim {
    font-size: 13px;
    opacity: 0.8;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recording-stop {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.recording-stop:hover {
    background: rgba(255, 255, 255, 0.3);
}

.recording-stop .material-symbols-rounded {
    font-size: 20px;
}

/* Analysis Summary */
.analysis-summary {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Lab Entry Row */
.lab-entry-row {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
}

.lab-entry-row input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

.lab-entry-row input:first-child {
    flex: 1.5;
}

/* AI Action Button in Edit Modal */
.ai-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.ai-action-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.ai-action-btn .material-symbols-rounded {
    font-size: 20px;
}

/* Dark Mode Adjustments */
[data-theme="dark"] .ai-lab-warning.critical {
    background: rgba(255, 59, 48, 0.15);
}

[data-theme="dark"] .ai-lab-warning.warning {
    background: rgba(255, 204, 0, 0.15);
}

[data-theme="dark"] .camera-tips {
    background: rgba(90, 200, 250, 0.1);
}

[data-theme="dark"] .analysis-summary {
    background: var(--surface);
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .ai-recording-indicator {
        left: 10px;
        right: 10px;
        transform: none;
        justify-content: space-between;
    }

    .recording-interim {
        max-width: 100px;
    }

    .ai-lab-warnings-header {
        font-size: 12px;
        padding: 8px 10px;
    }

    .ai-lab-warning {
        padding: 8px;
        font-size: 12px;
    }

    .voice-input-btn {
        width: 28px;
        height: 28px;
    }

    .voice-input-btn .material-symbols-rounded {
        font-size: 16px;
    }
}

/* AI Dialog Overlay and Dialog Styles */
.ai-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.ai-dialog {
    background: var(--surface);
    border-radius: var(--radius-l);
    max-width: 420px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.ai-dialog-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--primary-bg);
}

.ai-dialog-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.ai-dialog-icon .material-symbols-rounded {
    font-size: 24px;
}

.ai-dialog-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.ai-dialog-subtitle {
    font-size: 13px;
    color: var(--text-sec);
    margin-top: 2px;
}

.ai-dialog-body {
    padding: 20px;
}

.ai-dialog-body p {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: var(--text-sec);
    line-height: 1.5;
}

.ai-model-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-m);
}

.ai-model-item-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.ai-model-item-icon .material-symbols-rounded {
    font-size: 20px;
}

.ai-model-item-info {
    flex: 1;
}

.ai-model-item-name {
    font-weight: 600;
    font-size: 14px;
}

.ai-model-item-size {
    font-size: 12px;
    color: var(--text-sec);
    margin-top: 2px;
}

.ai-progress-container {
    margin-top: 16px;
}

.ai-progress-bar {
    height: 8px;
    background: var(--divider);
    border-radius: 4px;
    overflow: hidden;
}

.ai-progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.ai-progress-text {
    text-align: center;
    font-size: 13px;
    color: var(--text-sec);
    margin-top: 8px;
}

.ai-dialog-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg);
    justify-content: flex-end;
}

.ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.ai-btn .material-symbols-rounded {
    font-size: 18px;
}

.ai-btn-primary {
    background: var(--primary);
    color: white;
}

.ai-btn-primary:hover {
    opacity: 0.9;
}

.ai-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-btn-secondary {
    background: transparent;
    color: var(--text-sec);
    border: 1px solid var(--border);
}

.ai-btn-secondary:hover {
    background: var(--surface);
}

.ai-btn-success {
    background: var(--success);
    color: white;
}

/* Dark mode for dialog */
[data-theme="dark"] .ai-dialog-header {
    background: rgba(64, 167, 227, 0.15);
}

[data-theme="dark"] .ai-dialog-footer {
    background: rgba(0, 0, 0, 0.2);
}