:root {
  --primary: #1565C0;
  --primary-dark: #0D47A1;
  --primary-light: #42A5F5;
  --secondary: #00ACC1;
  --success: #2E7D32;
  --warning: #F57F17;
  --danger: #C62828;
  --sidebar-width: 260px;
  --header-height: 60px;
  --bg: #F0F4F8;
  --card-bg: #FFFFFF;
  --text: #1A202C;
  --text-muted: #718096;
  --border: #E2E8F0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Sarabun', 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }

/* ---- LOGIN PAGE ---- */
#loginPage {
  min-height: 100vh;
  background: linear-gradient(135deg, #0D47A1 0%, #1565C0 40%, #0277BD 70%, #00ACC1 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: white; border-radius: 20px; padding: 48px 40px;
  width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  width: 80px; height: 80px; border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 36px; color: white;
  box-shadow: 0 8px 20px rgba(21,101,192,0.4);
}
.login-title { font-size: 22px; font-weight: 700; color: var(--primary); text-align: center; }
.login-subtitle { color: var(--text-muted); text-align: center; font-size: 14px; margin-bottom: 28px; }
.form-control {
  border: 2px solid var(--border); border-radius: 10px; padding: 10px 14px;
  font-size: 15px; width: 100%; transition: border-color 0.2s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,101,192,0.1); }
.form-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; display: block; }
.input-group { position: relative; margin-bottom: 18px; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-group .form-control { padding-left: 40px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px; border: none; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit;
  text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), #1976D2); color: white; box-shadow: 0 4px 12px rgba(21,101,192,0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(21,101,192,0.4); }
.btn-success { background: linear-gradient(135deg, #2E7D32, #388E3C); color: white; }
.btn-warning { background: linear-gradient(135deg, #E65100, #F57C00); color: white; }
.btn-danger { background: linear-gradient(135deg, #C62828, #D32F2F); color: white; }
.btn-secondary { background: #EDF2F7; color: var(--text); }
.btn-secondary:hover { background: #E2E8F0; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* ---- APP LAYOUT ---- */
#appPage { display: flex; min-height: 100vh; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width); background: linear-gradient(180deg, #0D47A1 0%, #1565C0 60%, #1976D2 100%);
  color: white; position: fixed; top: 0; left: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 100;
  transition: transform 0.3s ease; overflow-y: auto;
}
.sidebar-header {
  padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(255,255,255,0.2); display: flex; align-items: center;
  justify-content: center; font-size: 20px; flex-shrink: 0;
}
.sidebar-title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.sidebar-subtitle { font-size: 11px; opacity: 0.7; }
.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  opacity: 0.5; padding: 8px 20px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px;
  cursor: pointer; transition: all 0.2s; border-radius: 0;
  font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.8);
  margin: 1px 8px; border-radius: 10px;
}
.nav-item:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-item.active { background: rgba(255,255,255,0.2); color: white; font-weight: 700; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; }
.nav-badge {
  margin-left: auto; background: #FF5252; color: white;
  border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.sidebar-user {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.2); display: flex; align-items: center;
  justify-content: center; font-size: 16px; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; opacity: 0.65; }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-width); flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}
.top-header {
  height: var(--header-height); background: white; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }
.breadcrumb { font-size: 13px; color: var(--text-muted); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content-area { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: #FAFBFC; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* ---- KPI TILES ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: white; border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; }
.kpi-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: white; flex-shrink: 0; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ---- TABLE ---- */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: #F7FAFC; padding: 12px 14px; text-align: left; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #F7FAFC; }
tbody tr:last-child td { border-bottom: none; }

/* ---- BADGES / STATUS ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-pending { background: #FFF3E0; color: #E65100; }
.badge-assigned { background: #E3F2FD; color: #1565C0; }
.badge-in_progress { background: #E8F5E9; color: #2E7D32; }
.badge-completed { background: #E8F5E9; color: #1B5E20; }
.badge-deleted { background: #FFEBEE; color: #C62828; }
.badge-draft { background: #F3E5F5; color: #6A1B9A; }
.badge-submitted { background: #E8F5E9; color: #2E7D32; }
.badge-none { background: #F5F5F5; color: #757575; }
.badge-admin { background: #FCE4EC; color: #880E4F; }
.badge-auditor { background: #E3F2FD; color: #0277BD; }
.badge-data_entry { background: #F3E5F5; color: #6A1B9A; }
.badge-nursing_head { background: #E8F5E9; color: #1B5E20; }
.badge-mr_assistant { background: #E3F2FD; color: #0D47A1; }
.badge-discharge_head { background: #FFF3E0; color: #E65100; }
.badge-dept_head { background: #F3E5F5; color: #4A148C; }
.badge-ward_head { background: #E0F7FA; color: #006064; }
.badge-medical_record { background: #EFEBE9; color: #4E342E; }
.badge-active { background: #E8F5E9; color: #2E7D32; }

/* ---- SCORE DISPLAY ---- */
.score-circle { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: white; flex-shrink: 0; }
.score-high { background: linear-gradient(135deg, #2E7D32, #43A047); }
.score-mid { background: linear-gradient(135deg, #E65100, #FB8C00); }
.score-low { background: linear-gradient(135deg, #C62828, #E53935); }
.progress-bar-wrap { height: 8px; background: #E2E8F0; border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }

/* ---- AUDIT FORM ---- */
.section-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.section-tab { padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; background: #EDF2F7; color: var(--text-muted); }
.section-tab.active { border-color: var(--primary); background: #EFF6FF; color: var(--primary); }
.section-tab.section-complete { background: #E8F5E9; color: #2E7D32; }
.section-tab.section-na { background: #F5F5F5; color: #9E9E9E; text-decoration: line-through; }
.audit-section { display: none; }
.audit-section.active { display: block; }
.audit-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: none; }
.item-num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: white; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }
.item-desc { flex: 1; font-size: 14px; line-height: 1.5; }
.toggle-wrap { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.toggle-btn { width: 72px; height: 34px; border-radius: 8px; border: 2px solid var(--border); font-size: 13px; font-weight: 700; cursor: pointer; background: white; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.toggle-btn.pass { background: #E8F5E9; border-color: #43A047; color: #2E7D32; }
.toggle-btn.fail { background: #FFEBEE; border-color: #E53935; color: #C62828; }
.na-toggle { width: 36px; height: 36px; border-radius: 8px; border: 2px solid var(--border); font-size: 11px; font-weight: 700; cursor: pointer; background: white; transition: all 0.2s; color: var(--text-muted); }
.na-toggle.active { background: #F3E5F5; border-color: #AB47BC; color: #6A1B9A; }
.score-summary { position: sticky; bottom: 0; background: white; border-top: 2px solid var(--border); padding: 16px 20px; margin: 0 -20px; display: flex; align-items: center; gap: 16px; box-shadow: 0 -4px 12px rgba(0,0,0,0.08); z-index: 10; }
.score-total { font-size: 24px; font-weight: 800; color: var(--primary); }

/* ---- CRITERIA GROUPS (Nurse's Note) ---- */
.criteria-group { margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.criteria-group-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #F7FAFC; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.group-num { width: 28px; height: 28px; border-radius: 50%; background: #1B5E20; color: white; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.group-name { flex: 1; font-size: 14px; font-weight: 600; min-width: 200px; }
.group-max { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.group-result { font-size: 12px; font-weight: 700; padding: 3px 12px; border-radius: 12px; white-space: nowrap; }
.group-result.pass { background: #E8F5E9; color: #2E7D32; }
.group-result.fail { background: #FFEBEE; color: #C62828; }
.group-result.pending { background: #F5F5F5; color: #757575; }
.criteria-sub-items { padding: 4px 16px; }
.criteria-sub-items .audit-item { padding: 10px 0; }
.criteria-sub-items .item-num { width: 24px; height: 24px; font-size: 11px; background: #78909C; }
.deduction-section { padding: 12px 16px; background: #FFF3E0; border-top: 1px solid #FFE0B2; }
.deduction-label { font-size: 13px; font-weight: 600; color: #E65100; margin-bottom: 8px; }
.deduction-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.deduction-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: #E65100; }
.deduction-item label { cursor: pointer; }
.group-score-line { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: #FAFAFA; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; }

/* ---- REMARKS FIELD ---- */
.remark-input-wrap { margin: 6px 0 6px 40px; }
.remark-input { width: 100%; font-size: 13px; padding: 6px 10px; border: 1px solid #FFB74D; border-radius: 6px; background: #FFF8E1; font-family: inherit; }
.remark-input:focus { border-color: #F57C00; outline: none; box-shadow: 0 0 0 2px rgba(245,124,0,0.15); }
.remark-input::placeholder { color: #BCAAA4; }

/* ---- ROLE VISIBILITY ---- */
body.role-nursing_head .admin-only,
body.role-mr_assistant .admin-only,
body.role-discharge_head .admin-only,
body.role-discharge_staff .admin-only,
body.role-dept_head .admin-only,
body.role-ward_head .admin-only,
body.role-medical_record .admin-only { display: none !important; }

/* ---- MODAL ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: white; z-index: 1; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-lg { max-width: 800px; }

/* ---- FORM ELEMENTS ---- */
.form-group { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ---- TOAST ---- */
#toastContainer { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: white; border-radius: 12px; padding: 14px 18px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); border-left: 4px solid; display: flex; align-items: center; gap: 12px; min-width: 280px; animation: slideIn 0.3s ease; font-size: 14px; }
.toast-success { border-color: #43A047; }
.toast-error { border-color: #E53935; }
.toast-warning { border-color: #FB8C00; }
.toast-info { border-color: #1565C0; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ---- LOADING ---- */
.loading-spinner { width: 40px; height: 40px; border: 4px solid #E2E8F0; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; z-index: 999; flex-direction: column; gap: 12px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }

/* ---- SEARCH / FILTER BAR ---- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .form-control { min-width: 140px; max-width: 200px; }
.filter-bar .form-group { margin-bottom: 0; }

/* ---- CHART CONTAINER ---- */
.chart-container { position: relative; height: 260px; }

/* ---- SECTION SCORE BAR ---- */
.section-score-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-score-name { width: 180px; font-size: 13px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-score-bar { flex: 1; }
.section-score-val { width: 60px; text-align: right; font-size: 13px; font-weight: 700; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .content-area { padding: 16px; }
  .filter-bar .form-control { max-width: 100%; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
}

/* ---- PRINT ---- */
@media print {
  .sidebar, .top-header, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---- MISC ---- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.font-sm { font-size: 13px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.admin-only { display: none !important; }
body.role-admin .admin-only { display: block !important; }
body.role-admin .admin-only.nav-item { display: flex !important; }
body.role-admin .admin-only.nav-section-title { display: block !important; }
body.role-admin .admin-flex { display: flex !important; }
.assign-allowed { display: none !important; }
body.role-admin .assign-allowed { display: block !important; }
body.role-admin .assign-allowed.nav-item { display: flex !important; }
body.role-discharge_head .assign-allowed { display: block !important; }
body.role-discharge_head .assign-allowed.nav-item { display: flex !important; }
.auditor-only { display: none !important; }
body.role-auditor .auditor-only, body.role-admin .auditor-only { display: block !important; }
body.role-auditor .auditor-only.nav-item, body.role-admin .auditor-only.nav-item { display: flex !important; }

/* ---- OP-SPECIFIC STYLES ---- */
.badge-general { background: #E3F2FD; color: #0277BD; }
.badge-chronic { background: #FFF3E0; color: #E65100; }
.badge-form-general { background: #E8F5E9; color: #2E7D32; }
.badge-psychiatric { background: #F3E5F5; color: #6A1B9A; }
.badge-pass { background: #E8F5E9; color: #1B5E20; font-weight: 700; }
.badge-fail { background: #FFEBEE; color: #C62828; font-weight: 700; }
.op-score-summary { border-top-color: #00897B; }
.bonus-section { padding: 12px 16px; background: #E8F5E9; border-top: 1px solid #C8E6C9; }
.bonus-label { font-size: 13px; font-weight: 600; color: #2E7D32; margin-bottom: 8px; }
.bonus-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.bonus-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: #2E7D32; }
.bonus-item label { cursor: pointer; }
.section-tab.section-missing { background: #FFEBEE; color: #C62828; }
.missing-toggle { width: 52px; height: 36px; border-radius: 8px; border: 2px solid var(--border); font-size: 10px; font-weight: 700; cursor: pointer; background: white; transition: all 0.2s; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.missing-toggle.active { background: #FFEBEE; border-color: #E53935; color: #C62828; }
.op-section-toggles { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---- CHART 7-DAY AUDIT ---- */
.c7-daily-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 12px 0; }
.c7-day-cell { text-align: center; }
.c7-day-cell label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.c7-day-cell input { width: 100%; text-align: center; border: 2px solid var(--border); border-radius: 8px; padding: 8px 4px; font-size: 15px; transition: border-color 0.2s; }
.c7-day-cell input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(21,101,192,0.15); }
.c7-day-cell input.has-value { border-color: var(--success); background-color: #E8F5E9; }
.c7-total-section { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 16px 0; }
.c7-total-box { text-align: center; padding: 16px; border-radius: var(--radius); }
.c7-total-box.c7-ontime { background: #E8F5E9; }
.c7-total-box.c7-discharged { background: #E3F2FD; }
.c7-total-box.c7-pct { background: #FFF8E1; }
.c7-total-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.c7-total-value { font-size: 28px; font-weight: 700; }
.c7-rank-list { padding: 0; }
.c7-rank-item { display: flex; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.c7-rank-item:last-child { border-bottom: none; }
.c7-rank-num { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; margin-right: 12px; flex-shrink: 0; background: #f0f0f0; color: var(--text-muted); }
.c7-rank-gold { background: #FFD700 !important; color: #333 !important; }
.c7-rank-silver { background: #C0C0C0 !important; color: #333 !important; }
.c7-rank-bronze { background: #CD7F32 !important; color: #fff !important; }
.c7-rank-name { flex: 1; font-size: 14px; }
.c7-rank-pct { font-weight: 700; font-size: 14px; }
.c7-group-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.c7-tab { padding: 6px 16px; border: 1px solid var(--border); border-radius: 20px; background: white; cursor: pointer; font-size: 13px; font-family: inherit; transition: all 0.2s; }
.c7-tab:hover { background: var(--bg); }
.c7-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.c7-detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.c7-detail-table th, .c7-detail-table td { padding: 8px 10px; border: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.c7-detail-table th { background: #f8f9fa; font-weight: 600; }
@media (max-width: 768px) {
  .c7-daily-grid { grid-template-columns: repeat(4, 1fr); }
  .c7-total-section { grid-template-columns: 1fr; }
}
