/* =============================================================
   HOS10 Modern Theme
   Apple-inspired clean UI for the HOS10 management system.
   ============================================================= */

/* --- CSS Variables --- */
:root {
    --hos-primary: #0071e3;
    --hos-primary-dark: #0058b0;
    --hos-surface: #f5f5f7;
    --hos-card: #ffffff;
    --hos-text: #1d1d1f;
    --hos-text-secondary: #86868b;
    --hos-text-tertiary: #6e6e73;
    --hos-border: #d2d2d7;
    --hos-border-light: #e8e8ed;
    --hos-nav-height: 56px;
    --hos-nav-bg: rgba(255, 255, 255, 0.82);
    --hos-radius: 12px;
    --hos-radius-lg: 14px;
    --hos-radius-sm: 8px;
    --hos-danger: #ff3b30;
    --hos-success: #34c759;
    --hos-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --hos-font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}


/* =============================================================
   1. Base & Old-Style Overrides
   ============================================================= */

body, html {
    background-color: var(--hos-surface) !important;
    font-family: var(--hos-font);
    color: var(--hos-text);
}

/* Override old SiteV2 h2 global rule */
h2 {
    font-size: inherit;
    color: inherit;
    margin: 0;
    padding: 0;
    border: none;
}

/* Override old SiteV2 h3 global rule */
h3 {
    font-size: inherit;
    color: inherit;
    background-color: transparent;
    margin: 0;
    padding: 0;
    display: block;
}

/* Override old SiteV2 input/select margin */
.hos-navbar input,
.hos-navbar select,
.ci-filter-card input,
.ci-filter-card select,
.hos-dashboard input,
.hos-dashboard select {
    margin-left: 0;
    margin-right: 0;
}

/* Override warpper */
.warpper {
    padding-top: 0 !important;
    background-color: transparent !important;
}

/* Hide old top bar */
.top_bar {
    display: none !important;
}

/* Override old main_content constraints */
.hos-main .main_content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 40px;
    min-width: auto;
    display: block;
    text-align: left;
}

/* Override old .page > * for pagination children */
.ci-pagination .page > * {
    padding: 0;
}

/* Override case_row bg from SiteV2 */
.ci-case-card.case_row:nth-child(even) {
    background-color: #fff;
}
.ci-case-card.case_row:hover,
.ci-case-card.case_row.hover {
    background-color: #fff;
}


/* =============================================================
   2. Top Navbar
   ============================================================= */

.hos-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--hos-nav-height);
    background: var(--hos-nav-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--hos-border);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 24px;
}

.hos-navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--hos-text);
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.hos-navbar-brand:hover { text-decoration: none; color: var(--hos-text); }

.hos-brand-logo {
    width: 32px; height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.hos-brand-logo img { width: 100%; height: 100%; object-fit: cover; }

.hos-nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 32px;
    list-style: none;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
}
.hos-nav-links li {
    display: inline-flex;
    align-items: center;
    height: auto;
    line-height: normal;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    color: inherit;
    vertical-align: middle;
    flex-shrink: 0;
}
.hos-nav-links li a,
.hos-nav-links li span {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: var(--hos-radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--hos-text-secondary);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.hos-nav-links li a:hover {
    background: rgba(0,0,0,0.05);
    color: var(--hos-text);
    text-decoration: none;
}
.hos-nav-links li.active,
.hos-nav-links li.active:hover {
    background: none;
    border: none;
    border-bottom: none;
}
.hos-nav-links li.active a,
.hos-nav-links li.active span {
    background: rgba(0,113,227,0.1);
    color: var(--hos-primary);
    font-weight: 600;
}

/* Divider between page-local and global nav items */
.hos-nav-divider {
    width: 1px;
    height: 20px;
    background: var(--hos-border);
    margin: 0 8px;
    flex-shrink: 0;
}

.hos-nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.hos-nav-right-link {
    color: var(--hos-text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.hos-nav-right-link:hover {
    background: var(--hos-surface);
    color: var(--hos-text);
    text-decoration: none;
}

/* Hamburger button (mobile only) */
.hos-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--hos-text);
    font-size: 18px;
    cursor: pointer;
    border-radius: var(--hos-radius-sm);
}
.hos-hamburger:hover {
    background: rgba(0,0,0,0.05);
}

/* Mobile dropdown menu */
.hos-mobile-menu {
    display: none;
    position: absolute;
    top: var(--hos-nav-height);
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--hos-border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    z-index: 999;
    padding: 8px 0;
}
.hos-mobile-menu.open {
    display: block;
}
.hos-mobile-menu-section {
    padding: 8px 0;
}
.hos-mobile-menu-section a {
    display: block;
    padding: 10px 24px;
    color: var(--hos-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}
.hos-mobile-menu-section a:hover {
    background: var(--hos-surface);
}

/* Calendar responsive */
#calendar { max-width: 100%; overflow-x: auto; }
.ui-dialog { max-width: calc(100vw - 20px) !important; }
.ui-dialog .ui-dialog-content { max-height: 80vh; overflow-y: auto; }

.hos-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 6px;
    border-radius: 20px;
    background: rgba(0,0,0,0.04);
    font-size: 0.82rem;
    color: var(--hos-text);
    text-decoration: none;
    font-weight: 500;
}
.hos-user-chip:hover { background: rgba(0,0,0,0.08); text-decoration: none; color: var(--hos-text); }

.hos-user-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--hos-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
}

.hos-btn-logout {
    font-size: 0.8rem;
    color: var(--hos-text-secondary);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}
.hos-btn-logout:hover { background: rgba(0,0,0,0.05); color: var(--hos-text); text-decoration: none; }


/* --- Main content area --- */
.hos-main {
    padding-top: calc(var(--hos-nav-height) + 24px);
    min-height: 100vh;
}

/* For _Layoutfile (no main_content wrapper) */
.hos-main-file {
    padding-top: calc(var(--hos-nav-height) + 16px);
    min-height: 100vh;
}


/* =============================================================
   3. Home Dashboard
   ============================================================= */

.hos-dashboard {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 0 60px;
}

.hos-welcome { margin-bottom: 32px; }
.hos-welcome h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--hos-text);
    margin: 0 0 4px;
    background: none;
    border: none;
    padding: 0;
}
.hos-welcome p {
    font-size: 1rem;
    color: var(--hos-text-secondary);
    margin: 0;
}

.hos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.hos-module-card {
    background: var(--hos-card);
    border-radius: 16px;
    border: 1px solid var(--hos-border-light);
    overflow: hidden;
    transition: box-shadow 0.25s, transform 0.25s;
}
.hos-module-card:hover {
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.hos-module-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--hos-border-light);
}
.hos-module-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
}
.hos-module-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--hos-text);
    margin: 0; padding: 0;
    background: none;
    display: block;
}

.hos-module-body { padding: 8px 12px 12px; }

.hos-module-link {
    display: flex;
    align-items: center;
    padding: 9px 10px;
    border-radius: var(--hos-radius-sm);
    color: var(--hos-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 400;
    transition: background 0.15s;
}
.hos-module-link:hover {
    background: var(--hos-surface);
    color: var(--hos-primary);
    text-decoration: none;
}
.hos-module-link i {
    margin-right: 10px;
    width: 16px;
    text-align: center;
    color: var(--hos-text-secondary);
    font-size: 0.85rem;
}
.hos-module-link:hover i { color: var(--hos-primary); }

/* Icon background variants */
.hos-icon-blue   { background: linear-gradient(135deg, #0071e3, #3b9cff); }
.hos-icon-teal   { background: linear-gradient(135deg, #30b0c7, #34d399); }
.hos-icon-purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.hos-icon-orange { background: linear-gradient(135deg, #f59e0b, #fb923c); }
.hos-icon-pink   { background: linear-gradient(135deg, #ec4899, #f472b6); }
.hos-icon-green  { background: linear-gradient(135deg, #059669, #34d399); }
.hos-icon-red    { background: linear-gradient(135deg, #dc2626, #f87171); }
.hos-icon-indigo { background: linear-gradient(135deg, #4f46e5, #818cf8); }


/* =============================================================
   4. Case Index Page
   ============================================================= */

.ci-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 60px;
}

/* Page header */
.ci-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.ci-page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--hos-text);
    margin: 0; padding: 0;
    border: none; background: none;
}
.ci-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 10px;
    background: var(--hos-primary);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    transition: background 0.2s;
}
.ci-btn-primary:hover { background: var(--hos-primary-dark); color: #fff; text-decoration: none; }

/* Filter card */
.ci-filter-card {
    background: var(--hos-card);
    border-radius: var(--hos-radius-lg);
    border: 1px solid var(--hos-border-light);
    padding: 20px;
    margin-bottom: 20px;
}
.ci-filter-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--hos-text-secondary);
    margin-bottom: 12px;
}
.ci-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.ci-filter-card .form-control,
.ci-filter-card .custom-select {
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-border);
    font-size: 0.88rem;
    padding: 6px 12px;
    transition: border-color 0.2s;
}
.ci-filter-card .form-control:focus,
.ci-filter-card .custom-select:focus {
    border-color: var(--hos-primary);
    box-shadow: 0 0 0 3px rgba(0,113,227,0.12);
}

.ci-date-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--hos-border);
    border-radius: var(--hos-radius-sm);
    overflow: hidden;
}
.ci-date-group .btn {
    border: none;
    border-radius: 0;
    padding: 6px 10px;
    background: var(--hos-surface);
    color: var(--hos-text);
}
.ci-date-group .btn:hover { background: var(--hos-border-light); }
.ci-date-group .form-control {
    border: none;
    border-radius: 0;
    text-align: center;
    width: 110px;
}

.ci-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.ci-search-wrap input { padding-right: 36px; }
.ci-search-wrap .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hos-text-secondary);
    pointer-events: none;
}

.ci-checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--hos-text-tertiary);
}
.ci-checkbox-row label {
    cursor: pointer;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ci-checkbox-row input[type=checkbox] { width: 16px; height: 16px; margin: 0; }

.ci-btn-clear {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 16px;
    background: rgba(255,59,48,0.08);
    color: var(--hos-danger);
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
}
.ci-btn-clear:hover { background: rgba(255,59,48,0.15); color: var(--hos-danger); text-decoration: none; }

/* Empty state */
.ci-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--hos-text-secondary);
}
.ci-empty i { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.ci-empty p { font-size: 1rem; margin: 0; }

/* Case card */
.ci-case-card {
    background: var(--hos-card);
    border-radius: var(--hos-radius-lg);
    border: 1px solid var(--hos-border-light);
    padding: 20px;
    margin-bottom: 12px;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.ci-case-card:hover,
.ci-case-card.hover {
    border-color: #bde0fe;
    box-shadow: 0 2px 16px rgba(0,113,227,0.08);
}

.ci-case-top {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.ci-status-col {
    flex-shrink: 0;
    text-align: center;
    min-width: 60px;
}
.ci-status-col img { height: 48px; margin-bottom: 4px; }
.hc-case-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--hos-surface, #f5f5f7);
    margin-bottom: 4px;
    transition: all 0.15s ease;
}
.hc-case-status-icon svg {
    width: 28px;
    height: 28px;
}
.ci-status-col .status-text {
    display: block;
    font-size: 0.72rem;
    color: var(--hos-text-secondary);
    font-weight: 500;
}
.ci-case-card .badge-success { font-size: 0.6rem; }

.ci-info-col { flex: 1; min-width: 0; }

.ci-patient-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}
.ci-patient-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--hos-text);
    text-decoration: none;
}
.ci-patient-name:hover { color: var(--hos-primary); text-decoration: none; }

.ci-clinic-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: #f0f0f5;
    font-size: 0.78rem;
    color: var(--hos-text-tertiary);
    font-weight: 500;
}

.ci-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.82rem;
    color: var(--hos-text-tertiary);
}
.ci-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--hos-surface);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--hos-text-tertiary);
}

.ci-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    font-size: 0.82rem;
    color: var(--hos-text-tertiary);
}
.ci-detail-row .text-dark { color: var(--hos-text); }

.ci-right-col {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    min-width: 200px;
}

.ci-appointment { text-align: right; }
.ci-appointment-label {
    font-size: 0.75rem;
    color: var(--hos-text-secondary);
    margin-bottom: 2px;
}
.ci-appointment-value {
    font-family: var(--hos-font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--hos-text);
}
.ci-btn-edit-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-border-light);
    background: var(--hos-card);
    color: var(--hos-primary);
    cursor: pointer;
    transition: background 0.15s;
    margin-left: 8px;
}
.ci-btn-edit-date:hover { background: #f0f0f5; }

/* Action buttons */
.ci-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--hos-border-light);
}
.ci-actions .btn {
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: var(--hos-radius-sm);
    font-weight: 500;
    border: 1px solid var(--hos-border-light);
    background: var(--hos-card);
    color: var(--hos-text);
    transition: all 0.15s;
}
.ci-actions .btn:hover {
    background: var(--hos-surface);
    border-color: var(--hos-border);
}
.ci-actions .btn i { margin-right: 4px; }
.ci-actions .btn-danger-ghost {
    color: var(--hos-danger);
    border-color: rgba(255,59,48,0.2);
}
.ci-actions .btn-danger-ghost:hover { background: rgba(255,59,48,0.06); }
.ci-actions .btn-primary-ghost {
    color: var(--hos-primary);
    border-color: rgba(0,113,227,0.2);
}
.ci-actions .btn-primary-ghost:hover { background: rgba(0,113,227,0.06); }

/* File panel inside card */
.ci-file-panel {
    margin-top: 12px;
    padding: 16px;
    background: #f9f9fb;
    border-radius: 10px;
    border: 1px solid var(--hos-border-light);
}


/* =============================================================
   5. Pagination (Modern)
   ============================================================= */

/* New Pager: ul.pagination */
.ci-pagination {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.ci-pagination .pagination,
.hos-pagination .pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
    align-items: center;
}

.ci-pagination .pagination li,
.hos-pagination .pagination li {
    display: inline-flex;
}

.ci-pagination .pagination li a,
.hos-pagination .pagination li a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-border-light);
    background: var(--hos-card);
    color: var(--hos-text);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}
.ci-pagination .pagination li a:hover,
.hos-pagination .pagination li a:hover {
    background: var(--hos-surface);
    border-color: var(--hos-primary);
    color: var(--hos-primary);
    text-decoration: none;
}

.ci-pagination .pagination li.active span,
.hos-pagination .pagination li.active span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-primary);
    background: var(--hos-primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Old Pager: .page wrapper with flat <a>/<span> */
.page.pagesbottom,
.hos-pagination-legacy {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page.pagesbottom > a,
.hos-pagination-legacy > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-border-light);
    background: var(--hos-card);
    color: var(--hos-text);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}
.page.pagesbottom > a:hover,
.hos-pagination-legacy > a:hover {
    background: var(--hos-surface);
    border-color: var(--hos-primary);
    color: var(--hos-primary);
    text-decoration: none;
}

.page.pagesbottom > span.current,
.hos-pagination-legacy > span.current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-primary);
    background: var(--hos-primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.page.pagesbottom > span.disabled,
.hos-pagination-legacy > span.disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-border-light);
    background: var(--hos-surface);
    color: var(--hos-border);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: default;
}


/* =============================================================
   6. Apple-style Modal (shared)
   ============================================================= */

.apple-modal-font {
    font-family: var(--hos-font);
    color: var(--hos-text);
    background-color: var(--hos-surface, #f2f2f7);
    border-radius: var(--hos-radius);
    overflow: hidden;
}
.apple-modal-body {
    background-color: var(--hos-surface, #f2f2f7);
}
.apple-list-tag {
    background-color: var(--hos-primary, #007aff);
    color: #fff;
    font-weight: normal;
}
.apple-header {
    border-bottom: 1px solid var(--hos-border-light, #e5e5ea);
    padding: 16px 24px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}
.apple-title { font-size: 1.1rem; font-weight: 600; margin: 0; color: var(--hos-text); }
.apple-close { background: none; border: none; font-size: 1.5rem; color: var(--hos-text-secondary); outline: none; cursor: pointer; line-height: 1; }

.apple-list-group {
    background-color: var(--hos-card, #fff);
    border-radius: 10px;
    margin: 20px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.apple-list-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--hos-border-light, #e5e5ea);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
    color: var(--hos-text);
}
.apple-list-item:last-child { border-bottom: none; }
.apple-list-item:hover { background-color: var(--hos-surface); text-decoration: none; color: var(--hos-primary, #007aff); }
.apple-list-item:active { background-color: var(--hos-border-light, #e5e5ea); }
.apple-list-text { font-size: 1rem; font-weight: 500; }
.apple-list-arrow { color: var(--hos-text-secondary, #c7c7cc); font-size: 0.9rem; }

.apple-footer {
    padding: 16px 24px;
    background-color: var(--hos-surface, #f2f2f7);
    display: flex;
    justify-content: center;
}
.btn-apple-cancel {
    background-color: #fff;
    color: #007aff;
    border: 1px solid #e5e5ea;
    padding: 8px 40px;
    border-radius: 20px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}


/* =============================================================
   7. Case Details Page (cd- prefix)
   ============================================================= */

.cd-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 60px;
}

/* Upload box for ear photos */
.cd-upload-box {
    border: 2px dashed var(--hos-border);
    border-radius: var(--hos-radius);
    background: var(--hos-surface);
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
}
.cd-upload-box:hover {
    border-color: var(--hos-primary);
    background: rgba(0,113,227,0.03);
}
.cd-upload-preview {
    margin-bottom: 8px;
}
.cd-upload-preview img {
    max-height: 280px;
    max-width: 100%;
    object-fit: contain;
    border-radius: var(--hos-radius-sm);
}
.cd-upload-hint {
    font-size: 0.82rem;
    color: var(--hos-text-secondary);
    font-weight: 500;
}

/* Tooth legend (replaces old .menu) */
.cd-tooth-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    justify-content: center;
}
.cd-tooth-legend > div {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--hos-surface);
    font-size: 0.78rem;
    color: var(--hos-text-tertiary);
    font-weight: 500;
}
.cd-legend-sym {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--hos-primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}

/* Apple-style image lightbox */
.cd-lightbox .modal-dialog.cd-lightbox-dialog {
    max-width: 100%;
    height: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cd-lightbox .cd-lightbox-content {
    background: rgba(0,0,0,0.92);
    border: none;
    border-radius: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
}
.cd-lightbox .cd-lightbox-body {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    text-align: center;
}
.cd-lightbox .imagepreview {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}
.cd-lightbox .imagepreview.widthlimit {
    max-width: 90vw;
}
.cd-lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1060;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.cd-lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

.cd-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1060;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.cd-lightbox-nav:hover {
    background: rgba(255,255,255,0.3);
}
.cd-lightbox-prev { left: 16px; }
.cd-lightbox-next { right: 16px; }

.cd-lightbox-toolbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 4px;
}
.cd-lightbox-tool {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.cd-lightbox-tool:hover {
    background: rgba(255,255,255,0.2);
}


/* =============================================================
   8. Paper / Sedation Record (pp- prefix)
   ============================================================= */

.pp-section {
    padding: 16px 0;
    border-bottom: 1px solid var(--hos-border-light);
}
.pp-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.pp-section-title {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--hos-text-secondary);
    margin-bottom: 12px;
}

/* Checkbox row */
.pp-check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.pp-check-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--hos-radius-sm);
    background: var(--hos-surface);
    font-size: 0.85rem;
    color: var(--hos-text-tertiary);
    font-weight: 500;
    margin: 0;
    cursor: default;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.pp-check-item.pp-checked {
    background: rgba(0,113,227,0.08);
    color: var(--hos-primary);
    border-color: rgba(0,113,227,0.15);
}
.pp-checkbox {
    font-size: 0.95rem;
    line-height: 1;
}

/* Data table */
.pp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}
.pp-table thead th {
    background: var(--hos-surface);
    color: var(--hos-text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    border-bottom: 1px solid var(--hos-border-light);
    text-align: left;
}
.pp-table thead th:first-child {
    border-radius: var(--hos-radius-sm) 0 0 0;
}
.pp-table thead th:last-child {
    border-radius: 0 var(--hos-radius-sm) 0 0;
}
.pp-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--hos-border-light);
    color: var(--hos-text);
}
.pp-table tbody tr:last-child td {
    border-bottom: none;
}
.pp-table tbody tr:hover {
    background: rgba(0,113,227,0.02);
}

/* Value chip */
.pp-val {
    font-family: var(--hos-font-mono);
    font-weight: 600;
    color: var(--hos-text);
}
.pp-val-inline {
    font-family: var(--hos-font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--hos-text);
}

/* Inline group (pustule / suction / nasal) */
.pp-inline-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}
.pp-inline-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pp-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--hos-text-secondary);
}

/* Drug grid */
.pp-drug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}
.pp-drug-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-radius: var(--hos-radius-sm);
    background: var(--hos-surface);
    border: 1px solid var(--hos-border-light);
}
.pp-drug-name {
    font-size: 0.82rem;
    color: var(--hos-text-secondary);
    font-weight: 500;
}
.pp-drug-val {
    font-family: var(--hos-font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--hos-text);
}
.pp-drug-val small {
    font-weight: 400;
    color: var(--hos-text-tertiary);
    font-size: 0.75rem;
}

/* Other med box */
.pp-other-box {
    padding: 10px 14px;
    border-radius: var(--hos-radius-sm);
    background: var(--hos-surface);
    border: 1px solid var(--hos-border-light);
}
.pp-other-text {
    margin-top: 4px;
    font-size: 0.88rem;
    color: var(--hos-text);
    word-break: break-all;
    white-space: normal;
}

/* Temperature row */
.pp-temp-row {
    display: flex;
    gap: 12px;
}
.pp-temp-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    border-radius: var(--hos-radius-sm);
    background: var(--hos-surface);
    border: 1px solid var(--hos-border-light);
}
.pp-temp-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--hos-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.pp-temp-val {
    font-family: var(--hos-font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--hos-text);
}

/* Special event handoff */
.pp-event-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pp-event-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}
.pp-event-desc {
    flex: 1;
    min-width: 200px;
    padding: 6px 12px;
    background: var(--hos-surface);
    border-radius: var(--hos-radius-sm);
    font-size: 0.85rem;
    color: var(--hos-text);
    word-break: break-all;
    white-space: normal;
}


/* =============================================================
   9. Responsive
   ============================================================= */

@media (max-width: 768px) {
    .hos-navbar { padding: 0 12px; gap: 8px; }
    /* 手機保留 page-level 麵包屑 (nav_bar 區段)，空間不夠就左右滑 */
    .hos-navbar-brand { order: 1; }
    .hos-nav-links {
        order: 2;
        display: flex;
        flex: 1 1 auto;
        min-width: 0;          /* 允許 flex child 收縮到可滑動門檻 */
        margin-left: 8px;       /* 覆蓋桌機的 margin-left:32px */
        -ms-overflow-style: none;
        scrollbar-width: none;  /* Firefox: 隱藏 scrollbar，保留滑動 */
    }
    .hos-nav-links::-webkit-scrollbar { display: none; } /* WebKit */
    .hos-nav-right { display: none; }
    .hos-hamburger {
        display: flex !important;
        order: 3;
        margin-left: 0;         /* 不再用 auto 推，nav-links flex:1 已吃完空間 */
        flex-shrink: 0;
    }
    .hos-main .main_content { padding: 0 12px 24px; }

    .ci-case-top { flex-direction: column; }
    .ci-right-col { align-items: flex-start; min-width: auto; }
    .ci-page-header { flex-direction: column; gap: 12px; align-items: flex-start; }

    .cd-page { padding: 0 12px 24px; }

    .pp-drug-grid { grid-template-columns: 1fr; }
    .pp-temp-row { flex-direction: column; }
    .pp-inline-group { flex-direction: column; align-items: flex-start; }
    .hl-filter-bar { flex-direction: column; align-items: stretch; }
    .hl-filter-sep { width: 100%; height: 1px; }
}


/* =============================================================
   10. Modern List / Table  (.hl- prefix)
   Adapted from HSMainCore ep-* pattern.
   ============================================================= */

/* -- Page wrapper -- */
.hl-page {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* -- Filter bar -- */
.hl-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--hos-radius-lg);
    border: 1px solid var(--hos-border-light);
}
.hl-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.hl-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--hos-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    margin-right: 2px;
}
.hl-filter-sep {
    width: 1px;
    height: 20px;
    background: var(--hos-border-light);
    flex-shrink: 0;
}
.hl-filter-select {
    border: 1px solid var(--hos-border-light);
    border-radius: var(--hos-radius-sm);
    padding: 5px 10px;
    font-size: 12.5px;
    color: var(--hos-text);
    background: var(--hos-surface);
    outline: none;
    cursor: pointer;
    height: 34px;
}
.hl-filter-select:focus {
    border-color: var(--hos-primary);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}
.hl-filter-input {
    border: 1px solid var(--hos-border-light);
    border-radius: var(--hos-radius-sm);
    padding: 5px 12px;
    font-size: 13px;
    color: var(--hos-text);
    background: var(--hos-surface);
    outline: none;
    height: 34px;
    width: 180px;
    transition: width 0.2s ease, border-color 0.15s, box-shadow 0.15s;
}
.hl-filter-input:focus {
    border-color: var(--hos-primary);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
    width: 240px;
}
.hl-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: var(--hos-radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    white-space: nowrap;
    height: 34px;
}
.hl-filter-btn-primary {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
}
.hl-filter-btn-primary:hover {
    background: var(--hos-primary-dark);
    color: #fff;
}
.hl-filter-btn-secondary {
    background: #fff;
    color: var(--hos-text);
    border-color: var(--hos-border-light);
}
.hl-filter-btn-secondary:hover {
    background: var(--hos-surface);
}

/* -- Panel -- */
.hl-panel {
    background: #fff;
    border-radius: var(--hos-radius-lg);
    border: 1px solid var(--hos-border-light);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.hl-panel-toolbar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: var(--hos-surface);
}
.hl-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--hos-text);
}
.hl-count-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: var(--hos-border-light);
    color: var(--hos-text-secondary);
}

/* -- Table -- */
.hl-table-wrap {
    overflow-x: auto;
}
.hl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.hl-table thead th {
    position: sticky;
    top: 0;
    background: var(--hos-surface);
    color: var(--hos-text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    white-space: nowrap;
    z-index: 2;
}
.hl-table tbody tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 0.1s;
}
.hl-table tbody tr:last-child {
    border-bottom: none;
}
.hl-table tbody tr:hover {
    background: var(--hos-surface);
}
.hl-table td {
    padding: 9px 12px;
    vertical-align: middle;
    color: var(--hos-text);
    white-space: nowrap;
}

/* -- Action buttons -- */
.hl-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.hl-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 7px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
    color: var(--hos-text-secondary);
    font-size: 11.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.hl-action-btn:hover {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
    text-decoration: none;
}
.hl-action-btn-danger:hover {
    background: var(--hos-danger);
    color: #fff;
    border-color: var(--hos-danger);
}

/* -- Status badges -- */
.hl-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.hl-badge-active {
    background: #d1fae5;
    color: #065f46;
}
.hl-badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}
.hl-badge-admin {
    background: #ede9fe;
    color: #5b21b6;
}
.hl-badge-user {
    background: #dbeafe;
    color: #1e40af;
}
.hl-badge-clinic {
    background: #fef3c7;
    color: #92400e;
}

/* Clinic type badges */
.hl-badge-ct0 { background: #dbeafe; color: #1e40af; }  /* 兒牙鎮靜 - 藍 */
.hl-badge-ct1 { background: #ede9fe; color: #5b21b6; }  /* 成人鎮靜 - 紫 */
.hl-badge-ct2 { background: #d1fae5; color: #065f46; }  /* 腸胃鏡檢 - 綠 */
.hl-badge-ct3 { background: #fef3c7; color: #92400e; }  /* 人力派遣 - 黃 */
.hl-badge-ct4 { background: #fee2e2; color: #991b1b; }  /* 疼痛科 - 紅 */
.hl-badge-ct5 { background: #fce7f3; color: #9d174d; }  /* 台北凡登 - 粉 */
.hl-badge-ct6 { background: #ccfbf1; color: #115e59; }  /* 新竹凡登 - 青 */
.hl-badge-ct7 { background: #e0e7ff; color: #3730a3; }  /* 小耳症 - 靛 */
.hl-badge-ct8 { background: #f3e8ff; color: #6b21a8; }  /* 全麻 - 深紫 */

/* -- Text helpers -- */
.hl-sub {
    font-size: 12px;
    color: var(--hos-text);
}
.hl-muted {
    font-size: 11px;
    color: var(--hos-text-secondary);
}

/* -- Empty state -- */
.hl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--hos-text-secondary);
    font-size: 14px;
    gap: 8px;
}

/* -- Searchable select -- */
.hl-searchable-select {
    position: relative;
}
.hl-searchable-select select.form-control {
    height: auto !important;
    min-height: 160px;
    max-height: 220px;
    overflow-y: auto;
    border-radius: var(--hos-radius-sm);
    border: 1px solid var(--hos-border-light);
    font-size: 13px;
    padding: 0;
}
.hl-searchable-select select.form-control option {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    cursor: pointer;
}
.hl-searchable-select select.form-control option:hover,
.hl-searchable-select select.form-control option:checked {
    background: var(--hos-primary);
    color: #fff;
}

/* -- Pagination -- */
.hl-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}
.hl-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--hos-border-light);
    background: #fff;
    color: var(--hos-text-secondary);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}
.hl-page-btn:hover {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
    text-decoration: none;
}
.hl-page-active {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
    cursor: default;
}
.hl-page-info {
    margin-left: 12px;
    font-size: 12px;
    color: var(--hos-text-secondary);
}

/* -- .hl-pagination 也支援 @Html.Pager 產出的 <ul class="pagination"><li><a> 標籤 --
   讓 Medicine/Record / Calendar/List 等用 Pager helper 的頁面也能套上同一個樣式 */
.hl-pagination ul.pagination {
    display: inline-flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.hl-pagination ul.pagination li {
    display: inline-flex;
    margin: 0;
    padding: 0;
}
.hl-pagination ul.pagination li a,
.hl-pagination ul.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 11px;
    border-radius: 8px;
    border: 1px solid var(--hos-border-light);
    background: var(--hos-card, #fff);
    color: var(--hos-text);
    text-decoration: none;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    transition: all 0.15s;
    box-sizing: border-box;
    line-height: 1;
}
.hl-pagination ul.pagination li a:hover {
    background: var(--hos-surface);
    border-color: var(--hos-border);
    text-decoration: none;
    color: var(--hos-text);
}
.hl-pagination ul.pagination li.active span {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
    font-weight: 600;
    cursor: default;
}
.hl-pagination ul.pagination li.disabled span {
    background: transparent;
    color: var(--hos-text-tertiary);
    border-color: var(--hos-border-light);
    cursor: not-allowed;
}
.hl-pagination ul.pagination li.ellipsis span {
    background: transparent;
    border-color: transparent;
    color: var(--hos-text-secondary);
    cursor: default;
    min-width: 24px;
    padding: 0 4px;
    letter-spacing: 1px;
}

/* Dark mode */
:root[data-theme="dark"] .hl-pagination ul.pagination li a,
:root[data-theme="dark"] .hl-pagination ul.pagination li span {
    background: var(--hos-card);
    border-color: var(--hos-border);
    color: var(--hos-text);
}
:root[data-theme="dark"] .hl-pagination ul.pagination li a:hover {
    background: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .hl-pagination ul.pagination li.active span {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
}

/* -- Button Toggle Group (radio/checkbox as buttons) -- */
.hl-btn-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}
.hl-btn-group input[type="radio"],
.hl-btn-group input[type="checkbox"] {
    display: none;
}
.hl-btn-group label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--hos-border);
    background: #fff;
    color: var(--hos-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.hl-btn-group label:hover {
    border-color: var(--hos-primary);
    color: var(--hos-primary);
}
.hl-btn-group input[type="radio"]:checked + label,
.hl-btn-group input[type="checkbox"]:checked + label {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
    box-shadow: 0 2px 8px rgba(0,113,227,0.3);
}

/* -- Required field marker -- */
.hl-required::after {
    content: " *";
    color: var(--hos-danger);
    font-weight: 700;
}

/* -- Disabled/greyed-out row -- */
.hl-row-disabled {
    opacity: 0.5;
    background: #f9f9f9 !important;
}

/* -- Responsive -- */
@media (max-width: 1200px) {
    .hl-page { padding: 12px 12px; }
    .hl-filter-bar { padding: 8px 10px; gap: 10px; }
}
@media (max-width: 768px) {
    .hl-filter-input { width: 140px; }
    .hl-filter-input:focus { width: 180px; }
}


/* =============================================================
   11. Calendar Page  (.cal- prefix)
   ============================================================= */

/* -- Page layout -- */
.cal-page {
    display: flex;
    gap: 16px;
    padding: 16px 20px;
    min-height: calc(100vh - var(--hos-nav-height) - 80px);
}

/* -- Sidebar -- */
.cal-sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cal-sidebar-card {
    background: var(--hos-card, #fff);
    border-radius: var(--hos-radius-lg);
    border: 1px solid var(--hos-border-light);
    overflow: hidden;
}

/* 個案篩選 (IndexV2 / myclassV2 左側 sidebar) */
.hc-case-filter {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;     /* flex 子元素縮窄前提：min-width 不要繼承 auto */
}
.hc-cf-row {
    min-width: 0;
}
.hc-cf-row .form-control {
    font-size: 0.85rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-overflow: ellipsis;
}
/* select 的 option (展開後的下拉) 不受 select 寬度限制；
   select 本身要求 100% 才不會被長 option 撐爆容器 */
.hc-cf-row select.form-control {
    width: 100% !important;
}
.hc-cf-row.hc-cf-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
}
.hc-cf-hit {
    font-size: 0.75rem;
    color: var(--hos-text-secondary);
}
.cal-sidebar-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--hos-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 14px 6px;
}
.cal-source-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 8px;
}
.cal-source-item {
    padding: 7px 8px;
    border-radius: var(--hos-radius-sm);
    transition: background 0.12s;
    cursor: pointer;
    position: relative;
}
.cal-source-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
}
.cal-source-item:hover {
    background: var(--hos-surface);
}
.cal-source-item input[type="checkbox"] {
    accent-color: var(--hos-primary);
    width: 15px;
    height: 15px;
    cursor: pointer;
}
.cal-source-name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--hos-text);
    flex: 1;
}
.cal-source-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-source-loading {
    display: none;
    font-size: 10px;
    color: var(--hos-text-secondary);
    position: absolute;
    bottom: -2px;
    left: 32px;
}
.cal-sidebar-actions {
    padding: 8px 14px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}
.cal-sidebar-filter {
    padding: 10px 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}
.cal-sidebar-filter label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--hos-text);
}
.cal-sidebar-filter input[type="checkbox"] {
    accent-color: var(--hos-primary);
    width: 15px;
    height: 15px;
}
.cal-sidebar-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--hos-primary);
    text-decoration: none;
    padding: 4px 0;
    transition: opacity 0.15s;
}
.cal-sidebar-link:hover {
    opacity: 0.7;
    text-decoration: none;
    color: var(--hos-primary);
}

/* -- Calendar main area -- */
.cal-main {
    flex: 1;
    min-width: 0;
    background: #fff;
    border-radius: var(--hos-radius-lg);
    border: 1px solid var(--hos-border-light);
    padding: 16px;
    overflow: hidden;
}

/* -- FullCalendar v2 overrides -- */
.cal-main .fc {
    font-family: var(--hos-font);
}
.cal-main .fc-toolbar {
    margin-bottom: 12px !important;
}
.cal-main .fc-toolbar h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--hos-text);
}

/* Buttons */
.cal-main .fc-button {
    background: var(--hos-surface) !important;
    border: 1px solid var(--hos-border-light) !important;
    color: var(--hos-text) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 5px 12px !important;
    border-radius: var(--hos-radius-sm) !important;
    text-shadow: none !important;
    box-shadow: none !important;
    height: auto !important;
    line-height: 1.4 !important;
    transition: all 0.15s !important;
    text-transform: capitalize;
}
.cal-main .fc-button:hover {
    background: var(--hos-border-light) !important;
    color: var(--hos-text) !important;
}
.cal-main .fc-button.fc-state-active,
.cal-main .fc-state-active {
    background: var(--hos-primary) !important;
    color: #fff !important;
    border-color: var(--hos-primary) !important;
}
.cal-main .fc-button-group .fc-button {
    border-radius: 0 !important;
}
.cal-main .fc-button-group .fc-button:first-child {
    border-radius: var(--hos-radius-sm) 0 0 var(--hos-radius-sm) !important;
}
.cal-main .fc-button-group .fc-button:last-child {
    border-radius: 0 var(--hos-radius-sm) var(--hos-radius-sm) 0 !important;
}
.cal-main .fc-today-button {
    border-radius: var(--hos-radius-sm) !important;
}

/* Table / Grid */
.cal-main .fc-widget-header {
    border-color: var(--hos-border-light) !important;
}
.cal-main .fc-widget-header th {
    background: var(--hos-surface) !important;
    border-color: var(--hos-border-light) !important;
    font-size: 11px;
    font-weight: 600;
    color: var(--hos-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 0 !important;
}
.cal-main .fc-widget-content {
    border-color: var(--hos-border-light) !important;
}
.cal-main .fc-day-header {
    border-color: var(--hos-border-light) !important;
}
.cal-main td.fc-today {
    background: rgba(0, 113, 227, 0.04) !important;
}
.cal-main .fc-day-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--hos-text);
    padding: 4px 8px !important;
}
.cal-main td.fc-today .fc-day-number {
    color: var(--hos-primary);
    font-weight: 700;
}

/* Events */
.cal-main .fc-event {
    border: none !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    font-weight: 500;
    padding: 2px 5px !important;
    margin: 1px 2px !important;
    line-height: 1.4;
    transition: opacity 0.15s, transform 0.1s;
}
.cal-main .fc-event:hover {
    opacity: 0.85;
    transform: scale(1.01);
}
.cal-main .fc-event .fc-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Agenda time grid */
.cal-main .fc-time-grid .fc-slats td {
    border-color: var(--hos-border-light) !important;
    height: 2.5em;
}
.cal-main .fc-axis {
    font-size: 10px;
    color: var(--hos-text-secondary);
}

/* -- Responsive -- */
@media (max-width: 992px) {
    .cal-page { flex-direction: column; }
    .cal-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
    .cal-sidebar-card { flex: 1; min-width: 200px; }
}
@media (max-width: 768px) {
    .cal-page { padding: 12px; }
    .cal-main { padding: 10px; }
    .cal-main .fc-toolbar h2 { font-size: 0.95rem; }
}


/* =============================================================
   12. SMS Tab Menu & Contact List (Modern Override)
   ============================================================= */

/* -- Tab Menu (pill style) -- */
ul.tabmenu {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 16px 0;
    padding: 0;
    list-style: none;
    background: var(--hos-surface);
    border-radius: var(--hos-radius);
    padding: 4px;
}

ul.tabmenu li {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 16px;
    border-radius: var(--hos-radius-sm);
    background: transparent;
    color: var(--hos-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
    border: none;
}

ul.tabmenu li:hover {
    color: var(--hos-text);
    background: rgba(0, 0, 0, 0.04);
}

ul.tabmenu li.active {
    background: var(--hos-card, #fff);
    color: var(--hos-primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* dark：surface 太黑 (=#000)、card 跟周圍同色 → 顯式 elevation + 主色描邊 active */
:root[data-theme="dark"] ul.tabmenu {
    background: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] ul.tabmenu li {
    color: var(--hos-text-secondary);
}
:root[data-theme="dark"] ul.tabmenu li:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--hos-text);
}
:root[data-theme="dark"] ul.tabmenu li.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--hos-primary, #0a84ff);
    box-shadow: none;
}

/* -- Contact list -- */
.prev_content > div {
    display: none;
    border: none;
    padding: 0;
    min-height: 80px;
    max-height: 320px;
    overflow-y: auto;
}

.prev_content > div.active {
    display: block;
}

.prev_content .contact {
    padding: 8px 12px;
    border-radius: var(--hos-radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--hos-text);
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.prev_content .contact:hover {
    background: rgba(0, 113, 227, 0.06);
    color: var(--hos-primary);
}

.prev_content .contact:active {
    background: rgba(0, 113, 227, 0.12);
}

/* -- SMS User Chips (receiver list) -- */
.sms-user {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    margin: 3px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    background: var(--hos-surface);
    border: 1px solid var(--hos-border-light);
    color: var(--hos-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.sms-user:hover {
    border-color: var(--hos-border);
}

.sms-user.checked {
    background: rgba(0, 113, 227, 0.08);
    border-color: rgba(0, 113, 227, 0.3);
    color: var(--hos-primary);
    font-weight: 600;
}

/* × 移除按鈕 */
.sms-user-label { display: inline-block; }
.sms-user-remove {
    margin-left: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    color: var(--hos-text-secondary);
    font-size: 14px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.sms-user-remove:hover {
    background: var(--hos-danger, #ff3b30);
    color: #fff;
}
.sms-user.checked .sms-user-remove {
    background: rgba(0, 113, 227, 0.15);
    color: var(--hos-primary);
}
.sms-user.checked .sms-user-remove:hover {
    background: var(--hos-danger, #ff3b30);
    color: #fff;
}
:root[data-theme="dark"] .sms-user-remove {
    background: rgba(255, 255, 255, 0.10);
    color: var(--hos-text-secondary);
}
:root[data-theme="dark"] .sms-user.checked .sms-user-remove {
    background: rgba(10, 132, 255, 0.25);
    color: #6bb6ff;
}
:root[data-theme="dark"] .sms-user-remove:hover,
:root[data-theme="dark"] .sms-user.checked .sms-user-remove:hover {
    background: #ff453a;
    color: #fff;
}

/* -- Preview content textarea -- */
.prev_content textarea {
    width: 100%;
    border: 1px solid var(--hos-border-light);
    border-radius: var(--hos-radius-sm);
    padding: 12px;
    font-size: 0.88rem;
    color: var(--hos-text);
    resize: vertical;
    transition: border-color 0.2s;
}

.prev_content textarea:focus {
    outline: none;
    border-color: var(--hos-primary);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}


/* =============================================================
   13. Global Loading Overlay & Toast
   ============================================================= */

/* -- Loading Overlay -- */
.hos-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hos-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.hos-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--hos-border-light);
    border-top-color: var(--hos-primary);
    border-radius: 50%;
    animation: hos-spin 0.7s linear infinite;
}
@keyframes hos-spin {
    to { transform: rotate(360deg); }
}
.hos-loading-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--hos-text-secondary);
}

/* -- Toast Notification -- */
#hos-toast-container {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hos-toast {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: var(--hos-card);
    border-radius: var(--hos-radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    font-weight: 500;
    color: var(--hos-text);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 360px;
}
.hos-toast-show {
    transform: translateX(0);
}

/* =============================================================
   Paper (鎮靜手術紀錄單) — Apple Inset Group 風格
   ============================================================= */
.paper-inset-group {
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.8), 0 2px 10px rgba(0,0,0,0.02);
    overflow: hidden;
}
.paper-section-header {
    background: rgba(244,247,249,0.85);
    border-bottom: 1px solid rgba(28,69,125,0.08);
    padding: 0.6rem 1.25rem;
    font-weight: 700;
    color: var(--hos-primary-dark, #0058b0);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}
.paper-section-row {
    border-bottom: 1px solid rgba(28,69,125,0.08);
    padding: 0.85rem 1.25rem;
    background: var(--hos-card, rgba(255,255,255,0.4));
}
.paper-section-row:last-child { border-bottom: none; }
.paper-label-mini {
    font-size: 0.75rem;
    color: #8a96a8;
    font-weight: 600;
    margin-bottom: 0.1rem;
}
.paper-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #54627b;
}
.paper-unit {
    font-size: 0.75rem;
    color: #8a96a8;
    font-weight: 500;
    margin-left: 2px;
}
.paper-status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid transparent;
}
.paper-status-yes {
    background: #e8eff7;
    color: #1c457d;
    border-color: rgba(28,69,125,0.2);
}
.paper-status-no {
    background: rgba(138,150,168,0.1);
    color: #8a96a8;
    border-color: rgba(138,150,168,0.2);
}
.paper-note {
    background: rgba(244,247,249,0.5);
    border: 1px solid rgba(28,69,125,0.08);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}
.paper-med-row {
    display: grid;
    grid-template-columns: 90px 1fr 1fr 1fr 120px;
    gap: 1rem;
    align-items: center;
}
@media (max-width: 991.98px) {
    .paper-med-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px dashed rgba(28,69,125,0.08);
    }
    .paper-med-row:last-child { border-bottom: none; }
    .paper-med-row > div:first-child { grid-column: 1 / -1; }
}
.paper-table-wrap {
    border: 1px solid rgba(28,69,125,0.08);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.6);
}
.paper-table-wrap table {
    width: 100%;
    margin-bottom: 0;
    color: #54627b;
    font-size: 0.9rem;
}
.paper-table-wrap th {
    background: rgba(244,247,249,0.8);
    color: #8a96a8;
    font-weight: 700;
    border-bottom: 1px solid rgba(28,69,125,0.08);
    padding: 0.6rem 1rem;
}
.paper-table-wrap td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(28,69,125,0.08);
    font-weight: 600;
}
.paper-table-wrap tr:last-child td { border-bottom: none; }

/* =============================================================
   Ear (小耳症綜合評估) — Apple Inset Group 左右耳對比
   ============================================================= */
.ear-inset-group {
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.8), 0 2px 10px rgba(0,0,0,0.02);
    overflow: hidden;
}
.ear-list-header {
    background: rgba(255,255,255,0.8);
    border-bottom: 2px solid rgba(28,69,125,0.08);
    padding: 0.75rem 0;
    font-weight: 700;
    color: #1c457d;
}
.ear-list-row {
    border-bottom: 1px solid rgba(28,69,125,0.08);
    transition: background 0.2s;
}
.ear-list-row:last-child { border-bottom: none; }
.ear-list-row:hover { background: rgba(255,255,255,0.9); }
.ear-label {
    background: rgba(244,247,249,0.4);
    font-weight: 700;
    color: #8a96a8;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    text-align: right;
    border-right: 1px solid rgba(28,69,125,0.08);
}
.ear-cell {
    padding: 1rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.ear-tag {
    display: inline-flex;
    align-items: center;
    background: #fff;
    color: #1c457d;
    padding: 0.25rem 0.65rem;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(28,69,125,0.05);
    border: 1px solid #e8eff7;
}
.ear-tag-success {
    background: #e6f4ea;
    color: #1e6c43;
    border-color: #c3e6cb;
}
.ear-tag-warn {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
}
@media (min-width: 768px) {
    .ear-border-mid { border-right: 1px dashed rgba(28,69,125,0.08); }
}
@media (max-width: 767.98px) {
    .ear-label {
        justify-content: flex-start;
        text-align: left;
        padding: 0.75rem 1rem 0.25rem 1rem;
        border-right: none;
        background: transparent;
        color: #1c457d;
    }
    .ear-cell { padding: 0.25rem 1rem 1rem 1rem; }
    .ear-border-mid { border-bottom: 1px dashed rgba(28,69,125,0.08); }
}

/* =============================================================
   Medicine Record table - wider columns for PC readability
   ============================================================= */
@media (min-width: 768px) {
    .medicine-record-table.hl-table td,
    .medicine-record-table.hl-table th {
        padding: 12px 16px;
        font-size: 14px;
    }
    .medicine-record-table.hl-table td:first-child {
        min-width: 200px;
        white-space: normal;
        word-break: break-word;
    }
    .medicine-record-table.hl-table td:nth-child(2) {
        min-width: 100px;
        text-align: center;
    }
    .medicine-record-table.hl-table td:nth-child(3) {
        min-width: 120px;
        white-space: nowrap;
    }
    .medicine-record-table.hl-table td:nth-child(4) {
        min-width: 140px;
        white-space: normal;
        word-break: break-word;
    }
}
.medicine-record-table.hl-table thead th {
    font-size: 12px;
    padding: 11px 16px;
}

/* =============================================================
   File toolbar confirm/unconfirm buttons - mobile responsive
   ============================================================= */
@media (max-width: 575.98px) {
    .btn-toolbar[role="toolbar"] {
        flex-wrap: wrap;
        gap: 4px;
    }
    .btn-toolbar[role="toolbar"] .btn-group {
        flex-wrap: wrap;
    }
    .btn-toolbar[role="toolbar"] .btn-group .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        white-space: nowrap;
    }
    .btn-toolbar[role="toolbar"] .btn-group .btn svg {
        width: 10px;
        height: 10px;
    }
}


/* =============================================================
   User Preferences (Theme + Compact) — 帳號下拉內的偏好設定
   ============================================================= */

/* === 桌面版下拉容器 === */
.hos-user-menu {
    position: relative;
    display: inline-block;
}

/* 把原本的 <a> chip 改成 button：保留視覺，新增 caret */
.hos-user-chip {
    background: rgba(0, 0, 0, 0.04);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    color: var(--hos-text);
}
.hos-user-chip:hover, .hos-user-chip[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.08);
}
.hos-user-caret {
    font-size: 0.7em;
    margin-left: 4px;
    opacity: 0.6;
    transition: transform 0.15s ease;
}
.hos-user-chip[aria-expanded="true"] .hos-user-caret {
    transform: rotate(180deg);
}

/* === 下拉面板 === */
.hos-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--hos-card);
    border: 1px solid var(--hos-border-light);
    border-radius: var(--hos-radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 6px;
    z-index: 1050;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.hos-user-dropdown[hidden] { display: none; }

/* === 單一 row（連結 / toggle） === */
.hos-prefs-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--hos-text);
    font-size: 0.9rem;
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
}
.hos-prefs-item:hover, .hos-prefs-item:focus-visible {
    background: rgba(0, 0, 0, 0.04);
    text-decoration: none;
    color: var(--hos-text);
    outline: none;
}
.hos-prefs-icon {
    width: 18px;
    text-align: center;
    color: var(--hos-text-secondary);
    flex-shrink: 0;
}
.hos-prefs-label {
    flex: 1;
}
.hos-prefs-danger {
    color: var(--hos-danger) !important;
}
.hos-prefs-danger .hos-prefs-icon {
    color: var(--hos-danger);
}
.hos-prefs-divider {
    height: 1px;
    background: var(--hos-border-light);
    margin: 6px 0;
}

/* === iOS-style toggle switch === */
.hos-prefs-toggle {
    width: 38px;
    height: 22px;
    background: var(--hos-border);
    border-radius: 999px;
    position: relative;
    transition: background 0.2s ease;
    flex-shrink: 0;
}
.hos-prefs-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}
[data-pref="compact"].is-on .hos-prefs-toggle,
[data-pref="capturing"].is-on .hos-prefs-toggle {
    background: var(--hos-success);
}
[data-pref="compact"].is-on .hos-prefs-toggle .hos-prefs-toggle-thumb,
[data-pref="capturing"].is-on .hos-prefs-toggle .hos-prefs-toggle-thumb {
    transform: translateX(16px);
}

/* === 主題分段控制（segmented control） === */
.hos-prefs-group {
    padding: 4px 12px 8px;
}
.hos-prefs-group-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--hos-text-secondary);
    margin: 6px 0;
}
.hos-prefs-segment {
    display: flex;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}
.hos-prefs-segment button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px 10px;
    font-size: 0.82rem;
    color: var(--hos-text);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}
.hos-prefs-segment button:hover {
    color: var(--hos-text);
}
.hos-prefs-segment button.is-active {
    background: var(--hos-card);
    color: var(--hos-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* === 手機 menu 內偏好項目（沿用 .hos-mobile-menu-section 的 padding） === */
.hos-prefs-row-m {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 10px 16px;
    color: var(--hos-text);
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    cursor: pointer;
}
.hos-prefs-row-m:hover {
    background: rgba(0, 0, 0, 0.04);
}
.hos-prefs-row-m .hos-prefs-toggle {
    margin-left: auto;
}
.hos-prefs-group-m {
    padding: 8px 16px;
}
.hos-prefs-group-m .hos-prefs-segment {
    margin-top: 6px;
}

/* === 隱藏 desktop dropdown 在手機 (手機改用 .hos-mobile-menu) === */
@media (max-width: 767px) {
    .hos-user-dropdown { display: none !important; }
    .hos-user-caret    { display: none; }
    .hos-user-chip { pointer-events: none; } /* 手機點 chip 不做事，靠漢堡開 mobile menu */
}


/* =============================================================
   Dark Mode — 透過 :root[data-theme="dark"] 切換全域 CSS 變數
   "auto" mode 由 JS 解析後寫入 data-theme=dark
   ============================================================= */

:root[data-theme="dark"] {
    --hos-primary:        #0a84ff;
    --hos-primary-dark:   #0064d2;
    --hos-surface:        #000000;       /* 頁面底色 */
    --hos-card:           #1c1c1e;       /* 卡片底色 */
    --hos-text:           #f5f5f7;
    --hos-text-secondary: #aeaeb2;
    --hos-text-tertiary:  #8e8e93;
    --hos-border:         #38383a;
    --hos-border-light:   #2c2c2e;
    --hos-nav-bg:         rgba(28, 28, 30, 0.82);
    --hos-danger:         #ff453a;
    --hos-success:        #30d158;
}

/* === Dark mode 必要的局部覆寫（針對既有硬編 #fff 等顏色） === */

:root[data-theme="dark"] body,
:root[data-theme="dark"] html {
    background-color: var(--hos-surface) !important;
    color: var(--hos-text);
}

/* 卡片 / 容器（modern-card、ci-* 系列、navbar dropdown） */
:root[data-theme="dark"] .modern-card,
:root[data-theme="dark"] .hos-mobile-menu,
:root[data-theme="dark"] .hos-user-dropdown,
:root[data-theme="dark"] .hos-search,
:root[data-theme="dark"] .hos-navbar {
    background: var(--hos-card);
    color: var(--hos-text);
}

/* iOS toggle thumb 在 dark 模式下用 off-white 維持對比 */
:root[data-theme="dark"] .hos-prefs-toggle-thumb { background: #f5f5f7; }

/* segmented control 背景在 dark 模式更深 */
:root[data-theme="dark"] .hos-prefs-segment {
    background: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .hos-prefs-segment button.is-active {
    background: rgba(255, 255, 255, 0.18);
    color: #f5f5f7;
}

/* hover state 在 dark 用淺白 */
:root[data-theme="dark"] .hos-user-chip:hover,
:root[data-theme="dark"] .hos-user-chip[aria-expanded="true"],
:root[data-theme="dark"] .hos-prefs-item:hover,
:root[data-theme="dark"] .hos-prefs-row-m:hover {
    background: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .hos-user-chip { background: rgba(255, 255, 255, 0.06); }

/* form input/select 對比 — 用 background-color (longhand) 不用 shorthand
   避免擦掉下拉箭頭 SVG；用 --input-bg (#2c2c2e) 比 --hos-card (#1c1c1e)
   亮一階，輸入框在卡片上才有清楚邊界 */
:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .apple-input {
    background-color: var(--input-bg);
    color: var(--hos-text);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .form-control::placeholder,
:root[data-theme="dark"] .apple-input::placeholder {
    color: var(--hos-text-tertiary);
}

/* 下拉的陰影在 dark 模式要更深、更黑 */
:root[data-theme="dark"] .hos-user-dropdown {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    border-color: var(--hos-border);
}


/* =============================================================
   Compact Layout (緊湊佈局) — 透過 :root[data-compact="1"] 啟用
   僅在手機 RWD (≤767px) 生效；用 :has() 偵測「label+input」pair
   ============================================================= */

@media (max-width: 767.98px) {

    /* === Label + Input pair：垂直堆疊改成左右 === */
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> .form-control:not(textarea)),
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> input:not([type="checkbox"]):not([type="radio"]):not([type="file"])),
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> select) {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 2px !important;
        padding: 3px 0;
        border-bottom: 1px solid var(--hos-border-light);
    }

    /* 同樣的 pair，label 改成靠左寬度約 35% */
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> .form-control:not(textarea)) > .apple-label,
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> input:not([type="checkbox"]):not([type="radio"]):not([type="file"])) > .apple-label,
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> select) > .apple-label {
        flex: 0 0 35%;
        max-width: 35%;
        margin-bottom: 0;
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--hos-text-secondary);
        text-align: left;
    }

    /* form control 接著佔剩下空間 */
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> .form-control:not(textarea)) > .form-control,
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> input:not([type="checkbox"]):not([type="radio"]):not([type="file"])) > input,
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .apple-label):has(> select) > select {
        flex: 1;
        font-size: 0.88rem;
        padding: 4px 8px !important;
        height: auto;
        min-height: 32px;
    }

    /* === Textarea 保持垂直（多行需要全寬） === */
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> textarea) {
        display: block;
        margin-bottom: 4px !important;
    }
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> textarea) > .apple-label {
        font-size: 0.78rem;
        margin-bottom: 2px;
        color: var(--hos-text-secondary);
    }
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> textarea) > textarea {
        font-size: 0.88rem;
        /* 不設 min-height — 保留原 textarea 高度 */
    }

    /* === radio-chip-group / checkbox 群組保持原樣（多項按鈕需要展開） === */
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .radio-chip-group),
    :root[data-compact="1"] :is([class*="col-"], .form-group).mb-3:has(> .checkbox-chip-group) {
        display: block;
    }

    /* === 卡片 / 容器 padding 縮減 === */
    /* === main_content 左右 padding 縮到很小（手機緊湊用最大可視寬度） === */
    :root[data-compact="1"] .hos-main .main_content {
        padding-left: 4px !important;
        padding-right: 4px !important;
        padding-bottom: 12px !important;
    }
    /* Container-fluid 內層 padding 也縮（Bootstrap 預設 15px） */
    :root[data-compact="1"] .container-fluid,
    :root[data-compact="1"] .container {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }
    /* Bootstrap row 預設 -15px margin 配合 col 的 15px padding → 縮成 -4px / 4px */
    :root[data-compact="1"] .row {
        margin-left: -4px !important;
        margin-right: -4px !important;
    }
    :root[data-compact="1"] .row > [class*="col-"] {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    :root[data-compact="1"] .modern-card {
        padding: 8px !important;
        margin-bottom: 6px !important;
    }
    :root[data-compact="1"] .modern-card-body {
        padding: 6px !important;
    }
    :root[data-compact="1"] .modern-card-header {
        padding: 6px 8px !important;
        font-size: 0.92rem;
    }

    /* === Tabs pane 內 padding 縮減 === */
    :root[data-compact="1"] .cd-tabs-pane,
    :root[data-compact="1"] .cd-tabs-pane > .container-fluid {
        padding: 6px !important;
    }

    /* === 區段標題 h6.form-section-title 縮 === */
    :root[data-compact="1"] h6.form-section-title {
        font-size: 0.85rem;
        margin: 6px 0 4px !important;
        padding-bottom: 2px !important;
    }
    /* === <hr> 區隔線縮 === */
    :root[data-compact="1"] hr,
    :root[data-compact="1"] hr.my-4 {
        margin-top: 6px !important;
        margin-bottom: 6px !important;
    }

    /* === 標題行距縮 === */
    :root[data-compact="1"] h2,
    :root[data-compact="1"] h3,
    :root[data-compact="1"] h4 {
        margin-top: 4px;
        margin-bottom: 2px;
    }
    :root[data-compact="1"] .row {
        margin-bottom: 0;
    }
    :root[data-compact="1"] .row + .row {
        margin-top: 0;
    }

    /* === jQuery UI dialog 標題列縮 === */
    :root[data-compact="1"] .ui-dialog-titlebar {
        padding: 6px 10px !important;
        font-size: 0.92rem;
    }

    /* === Section heading 上方間距縮 === */
    :root[data-compact="1"] .mb-3 + .row,
    :root[data-compact="1"] hr {
        margin-top: 4px;
        margin-bottom: 4px;
    }
}

/* ===  Selector 標記：讓 dropdown 內的 toggle 可以顯示「已啟用」狀態
       (Phase 4 的 syncCompactUI 會加 .is-on，dropdown 開啟時看得到) === */
:root[data-compact="1"] [data-pref="compact"] .hos-prefs-toggle { background: var(--hos-success); }
:root[data-compact="1"] [data-pref="compact"] .hos-prefs-toggle .hos-prefs-toggle-thumb { transform: translateX(16px); }


/* =============================================================
   Dark Mode — .cd-tabs-page 全域覆寫
   (此 pattern inline 散布在 Nurse / Doctor / Details /
    Conversation/Details / Conversation/Create 共 5 個 view，
    各自硬編 background: #ffffff。集中在這裡修，未來新 view 沿用此 pattern 自動繼承)
   ============================================================= */

:root[data-theme="dark"] .cd-tabs-page {
    background: var(--hos-surface);
}

@media (max-width: 768px) {
    :root[data-theme="dark"] .cd-tabs-page .cd-tabs {
        background: var(--hos-card);
        border-top-color: var(--hos-border);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
    }
    :root[data-theme="dark"] .cd-tabs-page .cd-tabs .hc-form-tab {
        color: var(--hos-text-secondary);
    }
    :root[data-theme="dark"] .cd-tabs-page .cd-tabs .hc-form-tab.active {
        color: var(--hos-primary);
        background: rgba(10, 132, 255, 0.18);
    }
    :root[data-theme="dark"] .cd-tabs-page .cd-tabs-pane {
        background: var(--hos-surface);
        color: var(--hos-text);
    }
}

/* 桌機線性 layout 下，tab 連結文字也要切深色 */
:root[data-theme="dark"] .cd-tabs-page .cd-tabs .hc-form-tab {
    color: var(--hos-text);
}
:root[data-theme="dark"] .cd-tabs-page .cd-tabs .hc-form-tab:hover {
    background: rgba(255, 255, 255, 0.06);
}


/* =============================================================
   照片類別上傳紀錄 (EarFiles) — RWD 卡片佈局 + dark mode 友善
   ============================================================= */

.ef-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ef-item {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: var(--hos-card);
    border: 1px solid var(--hos-border-light);
    border-radius: 12px;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.ef-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.ef-preview img.preview {
    width: 100%;
    max-width: 100px;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    background: var(--hos-surface);
    cursor: zoom-in;
}
.ef-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.ef-meta-head {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
}
.ef-meta-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 0.78rem;
    color: var(--hos-text-secondary);
}
.ef-time, .ef-doctor, .ef-uploader {
    display: inline-flex;
    align-items: center;
}
.ef-doctor {
    font-size: 0.82rem;
    color: var(--hos-text);
    font-weight: 600;
}
.ef-remark {
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--hos-surface);
    border: 1px solid var(--hos-border-light);
    border-radius: 8px;
    color: var(--hos-text);
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.ef-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.ef-del-btn {
    color: var(--hos-danger);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(255, 59, 48, 0.10);
    white-space: nowrap;
}
.ef-del-btn:hover, .ef-del-btn:focus {
    background: rgba(255, 59, 48, 0.20);
    color: var(--hos-danger);
    text-decoration: none;
}

/* 手機 ≤767px → 改成兩欄 + 動作放右下 */
@media (max-width: 767.98px) {
    .ef-item {
        grid-template-columns: 90px 1fr;
        grid-template-areas:
            "preview meta"
            "actions actions";
        gap: 8px 10px;
    }
    .ef-preview  { grid-area: preview; }
    .ef-meta     { grid-area: meta; }
    .ef-actions  {
        grid-area: actions;
        justify-self: end;
        padding-top: 4px;
        border-top: 1px solid var(--hos-border-light);
        width: 100%;
    }
    .ef-preview img.preview { max-width: 90px; }
}

/* === Dark mode 微調 (大部分已靠 var(--hos-*) 自動處理) === */
:root[data-theme="dark"] .ef-del-btn {
    background: rgba(255, 69, 58, 0.18);
}
:root[data-theme="dark"] .ef-del-btn:hover,
:root[data-theme="dark"] .ef-del-btn:focus {
    background: rgba(255, 69, 58, 0.30);
}
:root[data-theme="dark"] .ef-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}


/* =============================================================
   Dark Mode — 小耳症綜合評估 (.ear-inset-group / .ear-list-*)
   原本用 rgba(255,255,255,0.6) 等寫死的「白底」陣列
   ============================================================= */

:root[data-theme="dark"] .ear-inset-group {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--hos-border);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.06),
        0 2px 10px rgba(0, 0, 0, 0.3);
}
:root[data-theme="dark"] .ear-list-header {
    background: rgba(255, 255, 255, 0.06);
    color: #82b1ff;                     /* dark mode 對應的「醫療藍」標題色 */
    border-bottom-color: var(--hos-border);
}
:root[data-theme="dark"] .ear-list-row {
    border-bottom-color: var(--hos-border-light);
}
:root[data-theme="dark"] .ear-list-row:hover {
    background: rgba(255, 255, 255, 0.04);
}
:root[data-theme="dark"] .ear-label {
    background: rgba(255, 255, 255, 0.03);
    color: var(--hos-text-secondary);
    border-right-color: var(--hos-border-light);
}
:root[data-theme="dark"] .ear-tag {
    background: var(--hos-card);
    color: #82b1ff;
    border-color: var(--hos-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
:root[data-theme="dark"] .ear-tag-success {
    background: rgba(48, 209, 88, 0.18);
    color: #5edc7c;
    border-color: rgba(48, 209, 88, 0.3);
}
:root[data-theme="dark"] .ear-tag-warn {
    background: rgba(255, 159, 10, 0.18);
    color: #ffbb55;
    border-color: rgba(255, 159, 10, 0.3);
}
@media (min-width: 768px) {
    :root[data-theme="dark"] .ear-border-mid {
        border-right-color: var(--hos-border-light);
    }
}
@media (max-width: 767.98px) {
    :root[data-theme="dark"] .ear-label {
        color: #82b1ff;
        background: transparent;
    }
    :root[data-theme="dark"] .ear-border-mid {
        border-bottom-color: var(--hos-border-light);
    }
}


/* =============================================================
   Dark Mode — Paper table (.paper-table-wrap 與 .paper-status-*)
   (照片紀錄改卡片後，paper-table-wrap 主要剩其他護理紀錄/問卷用)
   ============================================================= */

:root[data-theme="dark"] .paper-table-wrap {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .paper-table-wrap table {
    color: var(--hos-text);
}
:root[data-theme="dark"] .paper-table-wrap th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--hos-text-secondary);
    border-bottom-color: var(--hos-border-light);
}
:root[data-theme="dark"] .paper-table-wrap td {
    border-bottom-color: var(--hos-border-light);
}
:root[data-theme="dark"] .paper-section-row {
    border-bottom-color: var(--hos-border-light);
    background: rgba(255, 255, 255, 0.03);
}
:root[data-theme="dark"] .paper-label-mini {
    color: var(--hos-text-secondary);
}
:root[data-theme="dark"] .paper-value {
    color: var(--hos-text);
}
:root[data-theme="dark"] .paper-unit {
    color: var(--hos-text-secondary);
}
:root[data-theme="dark"] .paper-status-yes {
    background: rgba(255, 159, 10, 0.18);     /* 跟訪談橘色配色一致 */
    color: #ffb55a;
    border-color: rgba(255, 159, 10, 0.35);
}
:root[data-theme="dark"] .paper-status-no {
    background: rgba(174, 174, 178, 0.12);
    color: var(--hos-text-secondary);
    border-color: rgba(174, 174, 178, 0.25);
}
:root[data-theme="dark"] .paper-note {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--hos-border-light);
}

/* === 補：paper-inset 容器 / section header / Paper.cshtml 內嵌色 dark mode === */
:root[data-theme="dark"] .paper-inset-group {
    background: var(--hos-card);
    border-color: var(--hos-border-light);
    box-shadow: none;
}
:root[data-theme="dark"] .paper-section-header {
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: var(--hos-border-light);
    color: #ffb55a;     /* 跟訪談 paper-name 一致用橘色，dark 下醒目 */
}

/* utility classes：取代 Paper.cshtml 內 inline 硬編色，讓 dark mode 可覆寫 */
.paper-accent { color: #1c457d; }
.paper-num-badge {
    background: rgba(28, 69, 125, 0.10);
    color: #1c457d;
}
.paper-row-tint { background: rgba(244, 247, 249, 0.4); }
.paper-divider-md {
    border-right: 1px dashed rgba(28, 69, 125, 0.08);
}
@media (max-width: 767.98px) {
    .paper-divider-md { border-right: none; }
}

:root[data-theme="dark"] .paper-accent { color: #ffb55a; }
:root[data-theme="dark"] .paper-num-badge {
    background: rgba(255, 159, 10, 0.15);
    color: #ffb55a;
}
:root[data-theme="dark"] .paper-row-tint {
    background: rgba(255, 255, 255, 0.04);
}
:root[data-theme="dark"] .paper-divider-md {
    border-right-color: var(--hos-border-light);
}


/* =============================================================
   Dark Mode — Bootstrap .bg-light 覆寫
   診療項目(備註) / 詳細備註 / 護理備註 都用了 Bootstrap 的 .bg-light
   (= #f8f9fa !important)，dark 模式底下會閃白，集中在這裡覆寫
   ============================================================= */

:root[data-theme="dark"] .bg-light {
    background-color: var(--hos-card) !important;
    color: var(--hos-text);
}

/* 配套：bg-light 經常跟 .rounded / .p-3 / .modify 一起使用，邊框感補上 */
:root[data-theme="dark"] .bg-light.rounded {
    border: 1px solid var(--hos-border-light);
}


/* =============================================================
   Dark Mode — 行事曆主面板 (.cal-main 及 FullCalendar overrides)
   原檔 line 1965 起一堆 .cal-main 跟 .cal-main .fc-* 用 #fff / 寫死色
   ============================================================= */

:root[data-theme="dark"] .cal-main {
    background: var(--hos-card);
    border-color: var(--hos-border-light);
    color: var(--hos-text);
}

/* FullCalendar 內建元素 (.fc-*) */
:root[data-theme="dark"] .cal-main .fc-toolbar h2 {
    color: var(--hos-text);
}
:root[data-theme="dark"] .cal-main .fc-button {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--hos-border) !important;
    color: var(--hos-text) !important;
}
:root[data-theme="dark"] .cal-main .fc-button:hover {
    background: rgba(255, 255, 255, 0.10) !important;
}
:root[data-theme="dark"] .cal-main .fc-button.fc-state-active,
:root[data-theme="dark"] .cal-main .fc-state-active {
    background: var(--hos-primary) !important;
    border-color: var(--hos-primary) !important;
    color: #fff !important;
}

/* 表頭 / 格線 / 日期 */
:root[data-theme="dark"] .cal-main .fc-widget-header,
:root[data-theme="dark"] .cal-main .fc-widget-content,
:root[data-theme="dark"] .cal-main .fc-day-header {
    border-color: var(--hos-border-light) !important;
}
:root[data-theme="dark"] .cal-main .fc-widget-header th {
    background: rgba(255, 255, 255, 0.04) !important;
    color: var(--hos-text-secondary);
    border-color: var(--hos-border-light) !important;
}
:root[data-theme="dark"] .cal-main td.fc-today {
    background: rgba(10, 132, 255, 0.10) !important;
}
:root[data-theme="dark"] .cal-main .fc-day-number {
    color: var(--hos-text);
}
:root[data-theme="dark"] .cal-main td.fc-today .fc-day-number {
    color: var(--hos-primary);
}

/* 其他 grid cell 預設背景 (light 模式底色由 .fc-day 自帶 #fff 風格的 widget bg) */
:root[data-theme="dark"] .cal-main .fc-day,
:root[data-theme="dark"] .cal-main .fc-content-skeleton,
:root[data-theme="dark"] .cal-main .fc-divider,
:root[data-theme="dark"] .cal-main .fc-row,
:root[data-theme="dark"] .cal-main .fc-scroller {
    background-color: transparent;
    border-color: var(--hos-border-light) !important;
}

/* Calendar sidebar (若存在) */
:root[data-theme="dark"] .cal-sidebar,
:root[data-theme="dark"] .cal-page .cal-sidebar {
    background: var(--hos-card);
    border-color: var(--hos-border-light);
    color: var(--hos-text);
}

/* === Dark mode 補：.cal-sidebar-card (行事曆左側 sidebar 卡片) === */
:root[data-theme="dark"] .cal-sidebar-card {
    background: var(--hos-card);
    border-color: var(--hos-border-light);
    color: var(--hos-text);
}


/* =============================================================
   Dark Mode — .hl-table 列表（hos-calendar List view / SMS /
   Medicine Warning 等用 hl-table 的地方）

   原 light 規則：
   - thead th { background: var(--hos-surface); border-bottom: rgba(0,0,0,0.06); }
   - tr { border-bottom: rgba(0,0,0,0.04); }
   問題 dark：
   - 黑色透明 border 疊在 dark 底色 → 看不到分隔線
   - --hos-surface (#000) 比卡片底色 --hos-card (#1c1c1e) 還暗，
     thead 反而變最深，視覺層級顛倒
   ============================================================= */

:root[data-theme="dark"] .hl-table thead th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--hos-text-secondary);
    border-bottom-color: var(--hos-border-light);
}
:root[data-theme="dark"] .hl-table tbody tr {
    border-bottom-color: var(--hos-border-light);
}
:root[data-theme="dark"] .hl-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}
:root[data-theme="dark"] .hl-table td {
    color: var(--hos-text);
}

/* hl-action-btn (列尾的編輯/刪除按鈕) 在 dark 模式 */
:root[data-theme="dark"] .hl-action-btn {
    color: var(--hos-text-secondary);
    background: rgba(255, 255, 255, 0.04);
}
:root[data-theme="dark"] .hl-action-btn:hover {
    background: rgba(255, 255, 255, 0.10);
    color: var(--hos-text);
}


/* =============================================================
   Dark Mode — .hl-btn-group label (radio/checkbox 圓角 pill 按鈕)
   ============================================================= */

:root[data-theme="dark"] .hl-btn-group label {
    background: var(--hos-card);
    color: var(--hos-text);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .hl-btn-group label:hover {
    border-color: var(--hos-primary);
    color: var(--hos-primary);
    background: rgba(10, 132, 255, 0.10);
}
:root[data-theme="dark"] .hl-btn-group input[type="radio"]:checked + label,
:root[data-theme="dark"] .hl-btn-group input[type="checkbox"]:checked + label {
    background: var(--hos-primary);
    color: #fff;
    border-color: var(--hos-primary);
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}


/* =============================================================
   Dark Mode — 盤查補齊 (.hl-* 列表系列 / .ci-* 個案卡片 / .apple-list-group / .btn-apple-cancel)
   ============================================================= */

/* === .hl-filter-bar 篩選列容器 === */
:root[data-theme="dark"] .hl-filter-bar {
    background: var(--hos-card);
    border-color: var(--hos-border-light);
}
:root[data-theme="dark"] .hl-filter-sep {
    background: var(--hos-border-light);
}
:root[data-theme="dark"] .hl-filter-label {
    color: var(--hos-text-secondary);
}

/* === .hl-filter-select / .hl-filter-input ===
   原本用 var(--hos-surface) 在 dark mode = #000，跟頁面同色看不到輸入框邊界
   改用 --input-bg (#2c2c2e) 對比卡片底色 */
:root[data-theme="dark"] .hl-filter-select,
:root[data-theme="dark"] .hl-filter-input {
    background-color: var(--input-bg);
    border-color: var(--hos-border);
    color: var(--hos-text);
}
:root[data-theme="dark"] .hl-filter-select:focus,
:root[data-theme="dark"] .hl-filter-input:focus {
    border-color: var(--hos-primary);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.20);
}

/* === .hl-filter-btn-secondary 次要按鈕 === */
:root[data-theme="dark"] .hl-filter-btn-secondary {
    background-color: var(--hos-card);
    color: var(--hos-text);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .hl-filter-btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--hos-text);
}

/* === .hl-panel 通用 panel === */
:root[data-theme="dark"] .hl-panel {
    background: var(--hos-card);
    border-color: var(--hos-border-light);
    color: var(--hos-text);
}

/* === .hl-page-btn 分頁按鈕 === */
:root[data-theme="dark"] .hl-page-btn {
    background: var(--hos-card);
    color: var(--hos-text);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .hl-page-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .hl-page-btn.active,
:root[data-theme="dark"] .hl-page-btn.is-active {
    background: var(--hos-primary);
    border-color: var(--hos-primary);
    color: #fff;
}

/* === .ci-case-card / case_row (個案卡片) === */
:root[data-theme="dark"] .ci-case-card,
:root[data-theme="dark"] .ci-case-card.case_row:nth-child(even),
:root[data-theme="dark"] .ci-case-card.case_row.hover {
    background-color: var(--hos-card);
    color: var(--hos-text);
    border-color: var(--hos-border-light);
}
:root[data-theme="dark"] .ci-case-card.case_row:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

/* === Apple modal (訪談問卷選擇 dialog 等) dark mode — 用實色避免穿透 === */
:root[data-theme="dark"] .apple-modal-font {
    background-color: #1c1c1e;       /* 整個 modal 外層底色 */
}
:root[data-theme="dark"] .apple-modal-body,
:root[data-theme="dark"] .apple-footer {
    background-color: #2c2c2e;       /* 比 modal 外層略亮一階，視覺層次 */
}
:root[data-theme="dark"] .apple-header {
    background-color: rgba(28, 28, 30, 0.95);    /* 帶 blur 維持 sticky 感 */
    border-bottom-color: var(--hos-border-light);
}
:root[data-theme="dark"] .apple-list-item {
    border-bottom-color: var(--hos-border-light);
    color: var(--hos-text);
}
:root[data-theme="dark"] .apple-list-item:active {
    background-color: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .apple-list-arrow {
    color: var(--hos-text-secondary);
}
:root[data-theme="dark"] .apple-list-tag {
    background-color: var(--hos-primary, #0a84ff);
}

/* === .apple-list-group === */
:root[data-theme="dark"] .apple-list-group {
    background-color: var(--hos-card);
    border-color: var(--hos-border-light);
    color: var(--hos-text);
}

/* === .btn-apple-cancel === */
:root[data-theme="dark"] .btn-apple-cancel {
    background-color: var(--hos-card);
    color: var(--hos-text);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .btn-apple-cancel:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* === .hos-brand-logo (navbar 左上 logo 容器) === */
:root[data-theme="dark"] .hos-brand-logo {
    background: rgba(255, 255, 255, 0.08);
}


/* =============================================================
   Global Scrollbar (light + dark) — table-wrap / dialog-content /
   一般 overflow 容器都吃這套
   原本寫在 app-custom.css，但該檔沒被 _Layout 載入，搬過來
   ============================================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.30);
}
::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

/* === Dark mode === */
:root[data-theme="dark"] {
    color-scheme: dark;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;  /* Firefox */
}
:root[data-theme="dark"] * {
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
:root[data-theme="dark"] ::-webkit-scrollbar-track {
    background: transparent;
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.40);
}
:root[data-theme="dark"] ::-webkit-scrollbar-corner {
    background: transparent;
}

:root[data-theme="light"] {
    color-scheme: light;
}

/* === Specific containers: table-wrap / dialog content / detail expand ===
   這些容器有自己的 background; scrollbar gutter 用 transparent track
   讓底色透過來，整體和諧 */
.hl-table-wrap,
.hcv-table-wrap,
.paper-table-wrap,
.ui-dialog-content,
.hcv-detail-content,
.hcv-detail-expand,
.cd-tabs-pane {
    scrollbar-gutter: stable;
}


/* =============================================================
   SMS 預覽 / 收訊人 sub-container — 在 modern-card 底色上再深一階
   (從 Views/SMS/Write.cshtml + SendCase.cshtml inline style 集中過來)
   ============================================================= */

.sms-receiver-box,
.sms-preview-box {
    border: 1px solid var(--hos-border-light);
    border-radius: 8px;
    background: var(--hos-surface);
}
.sms-receiver-box {
    min-height: 40px;
    padding: 8px;
    word-break: break-all;
}
.sms-preview-box {
    padding: 12px;
}

:root[data-theme="dark"] .sms-receiver-box,
:root[data-theme="dark"] .sms-preview-box {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--hos-border);
    color: var(--hos-text);
}


/* =============================================================
   Dark Mode 補：所有「hover/sub-element 用 var(--hos-surface)」修正
   原因：dark mode 下 --hos-surface = #000 (頁面底)，比 --hos-card (#1c1c1e) 還暗
   → 卡片內 hover 變黑，視覺看起來像「破洞」或「透明」
   修法：dark 時 hover bg 改用半透明白疊在 card 上 → 比 card 微亮
   ============================================================= */

:root[data-theme="dark"] .hos-nav-right-link:hover,
:root[data-theme="dark"] .hos-mobile-menu-section a:hover,
:root[data-theme="dark"] .hos-module-link:hover,
:root[data-theme="dark"] .apple-list-item:hover,
:root[data-theme="dark"] .ci-actions .btn:hover,
:root[data-theme="dark"] .ci-pagination .pagination li a:hover,
:root[data-theme="dark"] .hos-pagination .pagination li a:hover,
:root[data-theme="dark"] .page.pagesbottom > a:hover,
:root[data-theme="dark"] .hos-pagination-legacy > a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--hos-text);
}

/* ci-date-group .btn (date toolbar)、pp-table thead 等不是 hover 的也要看 */
:root[data-theme="dark"] .ci-date-group .btn {
    background: var(--input-bg);
    color: var(--hos-text);
}
:root[data-theme="dark"] .pp-table thead th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--hos-text-secondary);
}

/* apple-list-item hover 色已被原 light 規則寫死 #007aff，dark 也保留藍但提亮 */
:root[data-theme="dark"] .apple-list-item:hover {
    color: var(--hos-primary);
}


/* =============================================================
   Dark Mode 補：Bootstrap .btn-light
   行事曆 / 個人班表 / 個案資料 (Calendar/IndexV2, myclassV2, Case 等)
   多處 inline 用 class="btn btn-light"，Bootstrap 預設 #f8f9fa 寫死
   ============================================================= */

:root[data-theme="dark"] .btn-light {
    background-color: var(--input-bg);
    color: var(--hos-text);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .btn-light:hover,
:root[data-theme="dark"] .btn-light:focus {
    background-color: rgba(255, 255, 255, 0.10);
    color: var(--hos-text);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .btn-light:active,
:root[data-theme="dark"] .btn-light.active,
:root[data-theme="dark"] .btn-light:not(:disabled):not(.disabled):active {
    background-color: rgba(255, 255, 255, 0.16);
    color: var(--hos-text);
    border-color: var(--hos-border);
    box-shadow: none;
}
:root[data-theme="dark"] .btn-light:disabled,
:root[data-theme="dark"] .btn-light.disabled {
    background-color: var(--hos-card);
    color: var(--hos-text-tertiary);
    border-color: var(--hos-border-light);
}


/* =============================================================
   Dark Mode — jQuery UI dialog buttons (全域)
   .ui-state-default 是 jQuery UI 給按鈕的預設 state class，specificity
   高於 .btn-light，所以即使 .btn btn-light 在 dialog buttons array 裡，
   原本灰底白字 #e6e6e6 + #555 還是會贏。集中在 hos10-modern.css 蓋掉
   (hos-case.css 也有但只在 case views 載入)
   ============================================================= */

:root[data-theme="dark"] .ui-widget,
:root[data-theme="dark"] .ui-widget-content {
    color: var(--hos-text);
}
:root[data-theme="dark"] .ui-state-default,
:root[data-theme="dark"] .ui-widget-content .ui-state-default,
:root[data-theme="dark"] .ui-widget-header .ui-state-default {
    background: var(--hos-card);
    background-image: none;
    border-color: var(--hos-border);
    color: var(--hos-text);
}
:root[data-theme="dark"] .ui-state-default a,
:root[data-theme="dark"] .ui-state-default a:link,
:root[data-theme="dark"] .ui-state-default a:visited {
    color: var(--hos-text);
}
:root[data-theme="dark"] .ui-state-hover,
:root[data-theme="dark"] .ui-state-focus,
:root[data-theme="dark"] .ui-widget-content .ui-state-hover,
:root[data-theme="dark"] .ui-widget-content .ui-state-focus,
:root[data-theme="dark"] .ui-widget-header .ui-state-hover,
:root[data-theme="dark"] .ui-widget-header .ui-state-focus {
    background: rgba(255, 255, 255, 0.10);
    background-image: none;
    border-color: var(--hos-border);
    color: var(--hos-text);
}
:root[data-theme="dark"] .ui-state-active,
:root[data-theme="dark"] .ui-widget-content .ui-state-active,
:root[data-theme="dark"] .ui-widget-header .ui-state-active {
    background: rgba(255, 255, 255, 0.16);
    background-image: none;
    border-color: var(--hos-border);
    color: var(--hos-text);
}

/* dialog .ui-dialog-buttonpane 容器跟外圍細節 */
:root[data-theme="dark"] .ui-dialog-buttonpane {
    background: rgba(255, 255, 255, 0.03);
    border-top-color: var(--hos-border-light);
}


/* =============================================================
   Dark Mode 強化：對話視窗按鈕一定會 dark — 用 !important + 多 selector
   蓋掉所有可能的組合 (.btn-light / .ui-button / .ui-state-default)
   ============================================================= */

:root[data-theme="dark"] .ui-dialog .btn-light,
:root[data-theme="dark"] .ui-dialog button.btn-light,
:root[data-theme="dark"] .ui-dialog .ui-button,
:root[data-theme="dark"] .ui-dialog button.ui-button,
:root[data-theme="dark"] .ui-dialog-buttonpane .ui-button,
:root[data-theme="dark"] .ui-dialog-buttonpane .btn-light,
:root[data-theme="dark"] .ui-dialog .ui-state-default,
:root[data-theme="dark"] .ui-dialog-buttonset > button,
:root[data-theme="dark"] .ui-dialog-buttonset button.ui-button {
    background: var(--input-bg) !important;
    background-image: none !important;
    color: var(--hos-text) !important;
    border-color: var(--hos-border) !important;
}
:root[data-theme="dark"] .ui-dialog .btn-light:hover,
:root[data-theme="dark"] .ui-dialog button.btn-light:hover,
:root[data-theme="dark"] .ui-dialog .ui-button:hover,
:root[data-theme="dark"] .ui-dialog .ui-state-default:hover,
:root[data-theme="dark"] .ui-dialog-buttonpane .ui-button:hover,
:root[data-theme="dark"] .ui-dialog-buttonpane .btn-light:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    background-image: none !important;
    color: var(--hos-text) !important;
    border-color: var(--hos-border) !important;
}
:root[data-theme="dark"] .ui-dialog .btn-light:active,
:root[data-theme="dark"] .ui-dialog .btn-light:focus,
:root[data-theme="dark"] .ui-dialog .ui-button:active,
:root[data-theme="dark"] .ui-dialog .ui-button:focus,
:root[data-theme="dark"] .ui-dialog .ui-state-active,
:root[data-theme="dark"] .ui-dialog .ui-state-focus {
    background: rgba(255, 255, 255, 0.18) !important;
    background-image: none !important;
    color: var(--hos-text) !important;
    border-color: var(--hos-border) !important;
    box-shadow: none !important;
}


/* =============================================================
   Dark Mode 補：歷史紀錄 / 訪談卷 Create / Nurse 紀錄單 / 小耳症評估文字
   ============================================================= */

/* === 1. Record.cshtml (歷史紀錄 .hr-*) === */
:root[data-theme="dark"] .hr-card {
    background: var(--hos-card);
    border-color: var(--hos-border-light);
}
:root[data-theme="dark"] .hr-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--hos-border);
}
:root[data-theme="dark"] .hr-card-date {
    background: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] .hr-card-date .hr-y,
:root[data-theme="dark"] .hr-card-date .hr-t {
    color: var(--hos-text-secondary);
}
:root[data-theme="dark"] .hr-card-date .hr-md {
    color: var(--hos-text);
}
:root[data-theme="dark"] .hr-cure-tag {
    background: rgba(10, 132, 255, 0.18);
    color: #5ea8ff;
}
:root[data-theme="dark"] .hr-card-meta {
    color: var(--hos-text-secondary);
}
:root[data-theme="dark"] .hr-cure-memo {
    background: rgba(255, 255, 255, 0.05);
    color: var(--hos-text);
}
:root[data-theme="dark"] .hr-cure-remark {
    color: var(--hos-text-secondary);
    border-left-color: var(--hos-border-light);
}
:root[data-theme="dark"] .hr-action-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--hos-text);
}
:root[data-theme="dark"] .hr-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--hos-text);
}
:root[data-theme="dark"] .hr-action-btn.primary {
    background: rgba(10, 132, 255, 0.18);
    color: var(--hos-primary);
}
:root[data-theme="dark"] .hr-action-btn.primary:hover {
    background: rgba(10, 132, 255, 0.30);
}
@media (max-width: 600px) {
    :root[data-theme="dark"] .hr-card-actions {
        border-top-color: var(--hos-border-light);
    }
}

/* === 2. Conversation/Create.cshtml (問卷 create .question) === */
:root[data-theme="dark"] .question {
    background-color: var(--hos-card);
    border-color: var(--hos-border-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
:root[data-theme="dark"] .question h3 {
    color: var(--hos-text);
    border-bottom-color: var(--hos-border-light);
}
:root[data-theme="dark"] .question .qno {
    color: var(--hos-primary);
}
:root[data-theme="dark"] .question .qtitle,
:root[data-theme="dark"] .question .option label {
    color: var(--hos-text);
}
:root[data-theme="dark"] .question .option input[type="radio"],
:root[data-theme="dark"] .question .option input[type="checkbox"] {
    accent-color: var(--hos-primary);
}

/* === 3. Nurse 紀錄單 — inline border:#eee 統一覆寫 === */
:root[data-theme="dark"] [style*="border-bottom:1px dashed #eee"],
:root[data-theme="dark"] [style*="border-top:1px dashed #eee"],
:root[data-theme="dark"] [style*="border: 1px solid #eee"],
:root[data-theme="dark"] [style*="border-color: #eee"] {
    border-color: var(--hos-border-light) !important;
}
:root[data-theme="dark"] .med-row {
    background: rgba(255, 255, 255, 0.05);
}

/* === 4. 小耳症綜合評估 inline color 覆寫 (深藍/中灰寫死) === */
:root[data-theme="dark"] .ear-inset-group [style*="#1c457d"] {
    color: #ffb55a !important;       /* 深藍 → 橘 (跟訪談一致) */
}
:root[data-theme="dark"] .ear-inset-group [style*="#54627b"] {
    color: var(--hos-text) !important;
}
:root[data-theme="dark"] .ear-inset-group [style*="#8a96a8"] {
    color: var(--hos-text-secondary) !important;
}
:root[data-theme="dark"] .ear-list-row[style*="rgba(255,255,255,0.95)"] {
    background: rgba(255, 255, 255, 0.05) !important;
}
:root[data-theme="dark"] [style*="rgba(244,247,249,0.8)"] {
    background: rgba(255, 255, 255, 0.06) !important;
}

/* === 5. header 文字對齊：modern-card-header 在 compact 模式 padding-left 太小 === */
@media (max-width: 767.98px) {
    :root[data-compact="1"] .modern-card-header {
        padding: 8px 14px !important;     /* 左右各加到 14px，給標題喘息空間 */
    }
}


/* === Dark mode 補：首頁功能卡 .hos-module-* === */

/* .hos-module-card 本身已用 var(--hos-card)、border-light — 自動 dark
   border-bottom 我剛改 #f0f0f5 → var(--hos-border-light) 也跟著 dark
   但 hover 用 var(--hos-surface) = #000，疊在 card 上反而比 card 更暗
   → 改成半透白讓 hover 微亮 */

:root[data-theme="dark"] .hos-module-card:hover {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
:root[data-theme="dark"] .hos-module-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--hos-primary);
}

/* welcome 標題顏色已用 var()，自動 ok；補 paragraph 微調 */
:root[data-theme="dark"] .hos-welcome p {
    color: var(--hos-text-secondary);
}


/* =============================================================
   精簡模式 (body.is-capturing) — 移除卡片裝飾 + 縮小間距 + 全寬
   啟用方式：右上角下拉「精簡模式」開關，重整自動關閉 (不存 localStorage)
   不隱藏任何按鈕；所有操作正常可用
   ============================================================= */

/* 卡片：去底色 / 邊框 / 陰影 */
body.is-capturing .modern-card,
body.is-capturing .cal-sidebar-card,
body.is-capturing .paper-inset-group,
body.is-capturing .hc-interview-card,
body.is-capturing .modern-card-header,
body.is-capturing .paper-section-row,
body.is-capturing .paper-section-header,
body.is-capturing .paper-table-wrap {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}
/* 卡片標題保留底部細線當分隔 */
body.is-capturing .modern-card-header,
body.is-capturing .paper-section-header {
    border-bottom: 1px solid var(--hos-border-light, #e8e8ed) !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

/* 精簡間距 — padding/margin 大幅縮小 */
body.is-capturing .modern-card,
body.is-capturing .modern-card.mb-4,
body.is-capturing .modern-card.mb-3 {
    margin-bottom: 4px !important;
}
body.is-capturing .card-body {
    padding: 4px 4px !important;
}
body.is-capturing .modern-card-header {
    padding: 2px 0 !important;
    font-size: 0.95rem !important;
}
body.is-capturing .paper-section-row {
    padding: 3px 0 !important;
}
body.is-capturing .paper-section-header {
    padding: 3px 0 !important;
}
body.is-capturing .row.mb-3,
body.is-capturing .row.mb-4,
body.is-capturing .row.mb-2 { margin-bottom: 2px !important; }
body.is-capturing [class*="col-"].mb-3,
body.is-capturing [class*="col-"].mb-4,
body.is-capturing [class*="col-"].mb-2,
body.is-capturing .form-group.mb-3,
body.is-capturing .mb-3,
body.is-capturing .mb-4,
body.is-capturing .mb-2 { margin-bottom: 2px !important; }
body.is-capturing .apple-label { margin-bottom: 0 !important; }

/* form-control 自身高度 / padding 也壓縮 */
body.is-capturing .form-control,
body.is-capturing .apple-input,
body.is-capturing input[type="text"],
body.is-capturing input[type="number"],
body.is-capturing input[type="email"],
body.is-capturing input[type="date"],
body.is-capturing input[type="time"],
body.is-capturing select {
    padding-top: 3px !important;
    padding-bottom: 3px !important;
    min-height: 0 !important;
    height: auto !important;
}

/* 訪談 card 邊框移除，body padding 變小 */
body.is-capturing .hc-interview-card { margin-bottom: 2px !important; }
body.is-capturing .hc-interview-header { padding: 3px 0 !important; background: transparent !important; }
body.is-capturing .hc-interview-body { padding: 2px 0 !important; }
body.is-capturing .hc-interview-topic { padding: 2px 4px !important; margin-bottom: 0 !important; }

/* hr / 分隔線縮小 */
body.is-capturing hr,
body.is-capturing hr.my-4 { margin: 4px 0 !important; }
/* 表格 cell 也壓縮 */
body.is-capturing td,
body.is-capturing th { padding-top: 3px !important; padding-bottom: 3px !important; }

/* 行事曆相關 */
body.is-capturing .cal-page { padding: 0 !important; gap: 0 !important; }
body.is-capturing .cal-main { padding: 0 !important; }

/* .hos-main .main_content：保留原本 max-width:1200px 置中限寬，只縮小 padding */
body.is-capturing .hos-main .main_content {
    padding: 0 8px 24px !important;
}

/* =============================================================
   精簡模式：所有 label / value 改為左右排列
   - hc-info-row 已是 grid (110px + 1fr) → 不動
   - hc-interview-topic 問卷題目+答案改 flex row
   - Paper.cshtml 內 d-flex.flex-column (label 上、value 下) → row
   - Form col 內 apple-label + form-control → 左右
   ============================================================= */

/* 問卷題目 / 答案：左問右答 */
body.is-capturing .hc-interview-topic:not(.hc-section) {
    display: flex !important;
    align-items: baseline !important;
    gap: 12px !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px dashed var(--hos-border-light, #e8e8ed) !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
}
body.is-capturing .hc-interview-topic:not(.hc-section) .hc-interview-topic-name {
    flex: 0 0 auto;
    max-width: 50%;
    margin-bottom: 0 !important;
    margin-right: 8px;
    word-break: break-word;
}
body.is-capturing .hc-interview-topic:not(.hc-section) .hc-interview-topic-options {
    flex: 1 1 auto;
    min-width: 0;
}

/* Paper.cshtml：d-flex.flex-column 把 label 跟 value 堆疊改 row */
body.is-capturing .paper-section-row .d-flex.flex-column {
    flex-direction: row !important;
    align-items: baseline !important;
    gap: 8px;
}
body.is-capturing .paper-section-row .paper-label-mini {
    margin-bottom: 0 !important;
    flex: 0 0 auto;
    min-width: 80px;
}
body.is-capturing .paper-section-row .paper-value,
body.is-capturing .paper-section-row .paper-value + .paper-unit {
    flex: 0 0 auto;
}

/* Form 容器：apple-label + form-control 改 flex row
   選擇器放寬到 descendant (沒 ">"，因為長期國外/海外通訊方式等是 label + 內層 div.d-flex 包 input 的結構)
   也包含 .mb-3 / .form-group 容器 (getDates.cshtml 的「報到時間」「預約日期」用此格式) */
body.is-capturing [class*="col-"]:has(> .apple-label):has(.form-control),
body.is-capturing [class*="col-"]:has(> .apple-label):has(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])),
body.is-capturing [class*="col-"]:has(> .apple-label):has(select),
body.is-capturing [class*="col-"]:has(> .apple-label):has(textarea),
body.is-capturing [class*="col-"]:has(> .apple-label):has(.radio-chip-group),
body.is-capturing .form-group:has(> .apple-label):has(.form-control),
body.is-capturing .mb-3:has(> .apple-label):has(.form-control),
body.is-capturing .mb-3:has(> .apple-label):has(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])),
body.is-capturing .mb-3:has(> .apple-label):has(select),
body.is-capturing .mb-3:has(> .apple-label):has(textarea) {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: nowrap;
}
/* textarea：label 改成跟 textarea 頂部對齊 (textarea 通常多行，label 在中間反而怪) */
body.is-capturing [class*="col-"]:has(> .apple-label):has(textarea),
body.is-capturing .form-group:has(> .apple-label):has(textarea),
body.is-capturing .mb-3:has(> .apple-label):has(textarea) {
    align-items: flex-start !important;
}
body.is-capturing [class*="col-"]:has(> .apple-label):has(textarea) > .apple-label,
body.is-capturing .form-group:has(> .apple-label):has(textarea) > .apple-label,
body.is-capturing .mb-3:has(> .apple-label):has(textarea) > .apple-label {
    padding-top: 6px;     /* 跟 textarea 第一行文字垂直對齊 */
}
/* label 樣式：必須跟上面 flex 容器條件一致，避免「label + 純顯示 div」(如 CaseTreatmentInfo
   的「診療項目 (備註)」結構: label + div.p-3.bg-light.modify) 也吃到 text-align:right */
body.is-capturing [class*="col-"]:has(> .apple-label):has(.form-control) > .apple-label,
body.is-capturing [class*="col-"]:has(> .apple-label):has(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])) > .apple-label,
body.is-capturing [class*="col-"]:has(> .apple-label):has(select) > .apple-label,
body.is-capturing [class*="col-"]:has(> .apple-label):has(textarea) > .apple-label,
body.is-capturing [class*="col-"]:has(> .apple-label):has(.radio-chip-group) > .apple-label,
body.is-capturing .form-group:has(> .apple-label):has(.form-control) > .apple-label,
body.is-capturing .mb-3:has(> .apple-label):has(.form-control) > .apple-label,
body.is-capturing .mb-3:has(> .apple-label):has(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])) > .apple-label,
body.is-capturing .mb-3:has(> .apple-label):has(select) > .apple-label,
body.is-capturing .mb-3:has(> .apple-label):has(textarea) > .apple-label {
    flex: 0 0 auto !important;
    min-width: 80px;
    margin-bottom: 0 !important;
    text-align: right;
}
/* label 之後的兄弟元素 (input / select / textarea / wrapper div) 吃滿剩餘空間 */
body.is-capturing [class*="col-"]:has(> .apple-label):has(.form-control) > .apple-label ~ *,
body.is-capturing [class*="col-"]:has(> .apple-label):has(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])) > .apple-label ~ *,
body.is-capturing [class*="col-"]:has(> .apple-label):has(select) > .apple-label ~ *,
body.is-capturing [class*="col-"]:has(> .apple-label):has(textarea) > .apple-label ~ *,
body.is-capturing [class*="col-"]:has(> .apple-label):has(.radio-chip-group) > .apple-label ~ *,
body.is-capturing .form-group:has(> .apple-label):has(.form-control) > .apple-label ~ *,
body.is-capturing .mb-3:has(> .apple-label):has(.form-control) > .apple-label ~ *,
body.is-capturing .mb-3:has(> .apple-label):has(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])) > .apple-label ~ *,
body.is-capturing .mb-3:has(> .apple-label):has(select) > .apple-label ~ *,
body.is-capturing .mb-3:has(> .apple-label):has(textarea) > .apple-label ~ * {
    flex: 1 1 auto !important;
    min-width: 0;
}

/* === 例外: value 側是巢狀 .row (label 之外又包了多個 col-md-X)，例如「其他通訊方式」
   (col-12 內 label + nested .row > 3 個 input-group)。長 label 跟 3 排 input 搶寬度時
   右邊會被壓扁，強制改成「label 上、內容下」全寬模式。
   compact 跟 capturing 兩個模式都套，雙重保險: display:block + flex-direction:column,
   不管前面規則用 flex 還是 block 都會 stacked。 === */
:root[data-compact="1"] [class*="col-"]:has(> .apple-label):has(> .row),
body.is-capturing [class*="col-"]:has(> .apple-label):has(> .row) {
    display: block !important;
    flex-direction: column !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 0 !important;
}
:root[data-compact="1"] [class*="col-"]:has(> .apple-label):has(> .row) > .apple-label,
body.is-capturing [class*="col-"]:has(> .apple-label):has(> .row) > .apple-label {
    display: block !important;
    flex: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    text-align: left !important;
    margin-bottom: 4px !important;
    padding: 0 !important;
}
:root[data-compact="1"] [class*="col-"]:has(> .apple-label):has(> .row) > .apple-label ~ *,
body.is-capturing [class*="col-"]:has(> .apple-label):has(> .row) > .apple-label ~ * {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* === 例外: 小耳症評估 .ear_area 內，col-md-6 已平分一半空間，
   再左右分 label 會擠死 → compact + capturing 兩個模式都保持 stacked === */
:root[data-compact="1"] .ear_area :is([class*="col-"], .form-group, .mb-3):has(> .apple-label),
body.is-capturing .ear_area :is([class*="col-"], .form-group, .mb-3):has(> .apple-label) {
    display: block !important;
}
:root[data-compact="1"] .ear_area :is([class*="col-"], .form-group, .mb-3):has(> .apple-label) > .apple-label,
body.is-capturing .ear_area :is([class*="col-"], .form-group, .mb-3):has(> .apple-label) > .apple-label {
    flex: none !important;
    width: auto !important;
    min-width: 0 !important;
    text-align: left !important;
    margin-bottom: 4px !important;
}
:root[data-compact="1"] .ear_area :is([class*="col-"], .form-group, .mb-3):has(> .apple-label) > .apple-label ~ *,
body.is-capturing .ear_area :is([class*="col-"], .form-group, .mb-3):has(> .apple-label) > .apple-label ~ * {
    flex: none !important;
    width: 100% !important;
}

/* container 保留 Bootstrap 預設 max-width (大螢幕仍置中限寬，避免內容拉太寬)
   只縮小左右 padding 讓內容更滿 */
body.is-capturing .container,
body.is-capturing .container-fluid,
body.is-capturing .container-sm,
body.is-capturing .container-md,
body.is-capturing .container-lg,
body.is-capturing .container-xl,
body.is-capturing .container-xxl {
    padding-left: 8px !important;
    padding-right: 8px !important;
}
/* 內層 .row：margin 改 0 (避免右側 input 被推出)，col padding 做 gutter */
body.is-capturing .row { margin-left: 0 !important; margin-right: 0 !important; }
body.is-capturing .row > [class*="col-"] { padding-left: 4px !important; padding-right: 4px !important; }

/* body + html 維持原本灰底 (line 33 --hos-surface)，只把字體放大
   不在 .main_content 加底色，保持跟原本一致的視覺 (尤其首頁) */
html.is-capturing,
body.is-capturing {
    font-size: 17px;     /* 預設 16px → 放大到 17px，rem-based 子元素一起變大 */
}

/* 精簡模式：字體一致放大 (不依賴 rem 的也補；apple-label 上面有縮小被蓋過，恢復且放大) */
body.is-capturing .apple-label { font-size: 0.88rem !important; }
body.is-capturing .modern-card-header { font-size: 1.08rem !important; }
body.is-capturing .paper-section-header { font-size: 1.05rem !important; }
body.is-capturing .hc-info-label { font-size: 0.88rem !important; }
body.is-capturing .hc-info-value { font-size: 0.98rem !important; }
body.is-capturing .hc-interview-topic-name { font-size: 0.95rem !important; }
body.is-capturing .hc-op-tag { font-size: 0.92rem !important; }
body.is-capturing .paper-value { font-size: 1.05rem !important; }
body.is-capturing .paper-label-mini { font-size: 0.85rem !important; }
body.is-capturing table.hs-Table,
body.is-capturing table.hl-table,
body.is-capturing .table { font-size: 0.98rem !important; }
/* dark mode body/html 保留原 --hos-surface 黑底，只 main_content 在上面的規則處理 */
