:root {
  --blue-950: #082b61;
  --blue-900: #0e3d80;
  --blue-800: #164f9e;
  --blue-100: #e8f0fb;
  --green-600: #18b966;
  --green-100: #e8f9f0;
  --red-600: #dc3f4f;
  --red-100: #fdecee;
  --orange-600: #de7d17;
  --orange-100: #fff2df;
  --risk-600: #bd9200;
  --risk-100: #fff8d9;
  --purple-600: #7556c8;
  --female-600: #d13b79;
  --female-100: #fceaf2;
  --male-600: #1769aa;
  --male-100: #e8f3fb;
  --ink: #14213a;
  --muted: #6f7f99;
  --line: #e3e8ef;
  --surface: #ffffff;
  --background: #f4f7fa;
  --shadow: 0 8px 24px rgba(27, 49, 83, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--background); }
body { margin: 0; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: #fff; background: linear-gradient(180deg, #164f9e 0%, #0d3d7d 56%, #092f65 100%); box-shadow: 8px 0 26px rgba(6, 43, 97, .14); z-index: 30; }
.brand { min-height: 76px; display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark, .login-logo { width: 34px; height: 34px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; font-weight: 800; background: linear-gradient(135deg, #1dca70, #0c83bd); border: 2px solid rgba(255,255,255,.9); }
.brand-mark.has-image, .login-logo.has-image { overflow: hidden; padding: 2px; background: #fff; border-color: rgba(255,255,255,.92); }
.brand-mark img, .login-logo img { width: 100%; height: 100%; display: block; object-fit: contain; border-radius: inherit; }
.brand strong { font-size: 18px; letter-spacing: .1px; }
.brand > span:last-child { min-width: 0; }
.brand strong, .brand small { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small, .sidebar-footer small { display: block; color: rgba(255,255,255,.62); font-size: 11px; margin-top: 2px; }
.main-nav { padding: 16px 12px; }
.nav-label { margin: 6px 7px 10px; color: rgba(255,255,255,.42); text-transform: uppercase; letter-spacing: .09em; font-weight: 700; font-size: 10px; }
.main-nav a { display: flex; align-items: center; gap: 12px; min-height: 58px; margin-bottom: 5px; padding: 9px 12px; border-radius: 12px; color: rgba(255,255,255,.74); transition: .18s ease; }
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.main-nav a.active { color: #fff; background: linear-gradient(135deg, #23c66f, #1fb965); box-shadow: 0 8px 18px rgba(12, 40, 80, .2); }
.main-nav a > span:last-child { font-weight: 700; }
.main-nav small { display: block; margin-top: 2px; font-size: 11px; font-weight: 400; opacity: .7; }
.nav-icon { width: 22px; text-align: center; font-size: 20px; opacity: .8; }
.sidebar-footer { margin-top: auto; display: flex; gap: 10px; align-items: center; min-height: 78px; padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #24d477; box-shadow: 0 0 0 4px rgba(36,212,119,.12); }
.main-content { min-width: 0; }
.topbar { height: 76px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 20; padding: 0 24px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.topbar p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.role-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 10px; color: var(--blue-900); background: var(--blue-100); border-radius: 999px; font-size: 12px; font-weight: 700; }
.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-size: 13px; font-weight: 700; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #14539f, #19ad6a); }
.user-menu-popover { position: absolute; right: 0; top: 44px; width: 180px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.user-menu-popover a, .user-menu-popover button { width: 100%; display: block; padding: 9px 10px; color: var(--ink); background: transparent; border: 0; border-radius: 8px; text-align: left; font-size: 13px; }
.user-menu-popover a:hover, .user-menu-popover button:hover { background: var(--background); }
.mobile-menu { display: none; width: 38px; height: 38px; color: var(--blue-900); background: var(--blue-100); border: 0; border-radius: 10px; }
.page-wrap { padding: 24px; }
.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 12px 15px; color: #145935; background: var(--green-100); border: 1px solid #c8eed9; border-radius: 10px; font-size: 13px; }
.message.error { color: #8b1e2a; background: var(--red-100); border-color: #f4cdd2; }
.message.warning { color: #86511b; background: var(--orange-100); border-color: #f5d7af; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { min-height: 132px; display: flex; align-items: flex-start; justify-content: space-between; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--blue-800); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(27,49,83,.04); }
.metric-card.green { border-left-color: var(--green-600); }
.metric-card.red { border-left-color: var(--red-600); }
.metric-card.orange { border-left-color: var(--orange-600); }
.metric-card.risk { border-left-color: var(--risk-600); }
.metric-card.male { border-left-color: var(--male-600); }
.metric-card.female { border-left-color: var(--female-600); }
.metric-card span { color: #56708f; font-size: 12px; }
.metric-card strong { display: block; margin-top: 9px; font-size: 32px; line-height: 1; }
.metric-card small { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }
.metric-card i { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--blue-800); background: var(--blue-100); font-size: 20px; font-style: normal; font-weight: 800; }
.metric-card.green i { color: var(--green-600); background: var(--green-100); }
.metric-card.red i { color: var(--red-600); background: var(--red-100); }
.metric-card.orange i { color: var(--orange-600); background: var(--orange-100); }
.metric-card.risk i { color: var(--risk-600); background: var(--risk-100); }
.metric-card.male i { color: var(--male-600); background: var(--male-100); }
.metric-card.female i { color: var(--female-600); background: var(--female-100); }
.metric-card strong.metric-place { max-width: 170px; font-size: 20px; line-height: 1.15; }
.callout { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(27,49,83,.04); }
.callout-warning { border-color: #f1d6d9; }
.callout-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--red-600); background: var(--red-100); border-radius: 10px; font-size: 23px; }
.callout strong { font-size: 15px; }
.callout p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.callout .btn { margin-left: auto; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.panel { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(27,49,83,.045); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0; font-size: 16px; }
.panel-heading p { margin: 5px 0 0; color: #8a9ab1; font-size: 12px; }
.panel-heading > a { color: var(--blue-800); font-size: 12px; font-weight: 700; }
.distribution-list { display: grid; gap: 15px; }
.distribution-item > div:first-child { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 12px; }
.distribution-item strong { color: #8a9ab1; font-weight: 500; }
.progress { height: 8px; overflow: hidden; background: #eef2f7; border-radius: 999px; }
.progress span, .progress i { width: 0; min-width: 0; height: 100%; display: block; border-radius: inherit; background: var(--blue-800); transition: width .25s ease; }
.bar-normal { background: var(--green-600) !important; }
.bar-moderate { background: var(--orange-600) !important; }
.bar-risk { background: var(--risk-600) !important; }
.bar-severe { background: var(--red-600) !important; }
.bar-above { background: var(--purple-600) !important; }
.bar-na { background: #a5b0c0 !important; }
.bar-blue { background: var(--blue-800) !important; }
.bar-male { background: var(--male-600) !important; }
.bar-female { background: var(--female-600) !important; }
.bar-unknown { background: #9aa6b7 !important; }
.activity-list { display: grid; }
.activity-item { display: grid; grid-template-columns: 38px 1fr auto; gap: 11px; align-items: center; padding: 10px 6px; border-bottom: 1px solid #eef1f5; }
.activity-item:last-child { border-bottom: 0; }
.activity-avatar, .mini-avatar { display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #14539f, #19ad6a); border-radius: 12px; font-weight: 800; text-transform: uppercase; }
.activity-avatar { width: 38px; height: 38px; }
.activity-avatar.calendar { color: var(--blue-900); background: var(--blue-100); }
.activity-item strong { display: block; font-size: 13px; }
.activity-item small { display: block; margin-top: 4px; color: #8a9ab1; font-size: 11px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #a5b0c0; }
.status-normal { --status-color: var(--green-600); --status-bg: var(--green-100); }
.status-risk { --status-color: var(--risk-600); --status-bg: var(--risk-100); }
.status-moderate { --status-color: var(--orange-600); --status-bg: var(--orange-100); }
.status-severe { --status-color: var(--red-600); --status-bg: var(--red-100); }
.status-above { --status-color: var(--purple-600); --status-bg: #f0ebff; }
.status-na { --status-color: #66758c; --status-bg: #eef1f5; }
.status-dot.status-normal, .status-dot.status-risk, .status-dot.status-moderate, .status-dot.status-severe, .status-dot.status-above { background: var(--status-color); }

.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 750; transition: .17s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--blue-800); box-shadow: 0 6px 14px rgba(22,79,158,.16); }
.btn-success { color: #fff; background: var(--green-600); }
.btn-secondary { color: #31455f; background: #fff; border-color: #d8e0e9; }
.btn-block { width: 100%; }
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-actions > div { display: flex; gap: 9px; flex-wrap: wrap; }
.filter-bar { flex: 1; display: grid; grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(130px, auto)) auto; gap: 9px; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #d6dee8; border-radius: 9px; outline: none; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #4c8bd8; box-shadow: 0 0 0 3px rgba(35,106,193,.1); }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--blue-800); }
.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-heading { padding: 20px 20px 0; }
.table-responsive { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 12px 16px; color: #697c94; background: #f8fafc; border-bottom: 1px solid var(--line); text-align: left; text-transform: uppercase; letter-spacing: .04em; font-size: 10px; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.person-cell { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.mini-avatar { width: 32px; height: 32px; border-radius: 9px; }
.mini-avatar.sex-male, .activity-avatar.sex-male { background: linear-gradient(135deg, #15559f, #258dcc); }
.mini-avatar.sex-female, .activity-avatar.sex-female { background: linear-gradient(135deg, #9b3c87, #e45589); }
.person-cell.sex-male small { color: var(--male-600); }
.person-cell.sex-female small { color: var(--female-600); }
.person-cell small, .cell-sub { display: block; margin-top: 3px; color: #8c9aae; font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; max-width: 210px; padding: 5px 8px; color: var(--status-color, #66758c); background: var(--status-bg, #eef1f5); border-radius: 999px; font-size: 10px; font-weight: 750; line-height: 1.2; }
.table-link, .link-button { color: var(--blue-800); font-size: 12px; font-weight: 750; white-space: nowrap; }
.link-button { padding: 0; background: transparent; border: 0; }
.table-actions { display: flex; align-items: center; gap: 12px; }
.empty-state { padding: 35px 15px; color: #7d8ca1; text-align: center; }
.empty-state strong { display: block; color: #52657d; }
.empty-state p { margin: 6px 0 0; font-size: 12px; }
.empty-state.compact { padding: 18px 8px; }

.record-form { display: grid; gap: 17px; }
.form-section { padding: 22px; }
.section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.section-title > span { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; color: var(--blue-900); background: var(--blue-100); border-radius: 10px; font-weight: 800; }
.section-title h2 { margin: 0; font-size: 17px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 18px; }
.form-grid.one-column { grid-template-columns: 1fr; }
.form-field label { display: block; margin-bottom: 7px; color: #3a4d65; font-size: 12px; font-weight: 750; }
.form-field .required { margin-left: 3px; color: var(--red-600); }
.span-2 { grid-column: span 2; }
.checkbox-field { display: flex; align-items: end; min-height: 55px; }
.checkbox-label { display: flex !important; align-items: center; gap: 9px; margin: 0 !important; cursor: pointer; }
.help-text { display: block; margin-top: 5px; color: #8795a8; font-size: 10px; }
.field-error { display: block; margin-top: 5px; color: var(--red-600); font-size: 11px; font-weight: 650; }
.form-errors { padding: 12px; color: #8b1e2a; background: var(--red-100); border-radius: 10px; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.sticky-actions { position: sticky; bottom: 10px; z-index: 10; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.clinical-note { margin-bottom: 18px; padding: 12px 14px; color: #33506d; background: #eff6ff; border-left: 4px solid var(--blue-800); border-radius: 8px; font-size: 12px; line-height: 1.5; }
.method-indicator { display: inline-block; margin-left: 5px; color: var(--blue-900); font-weight: 800; }
.auto-method-field select { color: var(--blue-900); background: var(--blue-100); border-color: #c9dcf4; pointer-events: none; }
.auto-method-field label::after { content: " ✓"; color: var(--green-600); }
.age-preview { display: flex; align-items: center; gap: 12px; margin: -4px 0 20px; padding: 13px 15px; color: var(--blue-900); background: linear-gradient(135deg, #eef5ff, #f5fbff); border: 1px solid #dbe9fa; border-radius: 12px; }
.age-preview span { color: var(--muted); font-size: 11px; }
.age-preview strong { font-size: 15px; }
.age-preview small { margin-left: auto; color: #7d8ca1; font-size: 10px; }
.field-disabled { opacity: .48; }
.field-disabled input, .field-disabled select, .field-disabled textarea { background: #eef2f6; cursor: not-allowed; }
.live-assessment { display: grid; grid-template-columns: minmax(220px, .85fr) 1.4fr; gap: 14px; margin-bottom: 18px; padding: 15px; color: var(--status-color); background: var(--status-bg); border: 1px solid color-mix(in srgb, var(--status-color) 18%, transparent); border-radius: 13px; transition: .2s ease; }
.live-status { display: flex; flex-direction: column; justify-content: center; padding: 6px 10px; }
.live-status span { font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.live-status strong { margin: 5px 0; font-size: 18px; }
.live-status small { color: #5f7087; font-size: 10px; line-height: 1.45; }
.live-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.live-metrics div { min-width: 0; padding: 11px 8px; background: rgba(255,255,255,.72); border-radius: 9px; text-align: center; }
.live-metrics span { display: block; color: #6d7e94; font-size: 9px; }
.live-metrics strong { display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--status-color); font-size: 12px; }
.content-narrow { max-width: 680px; margin: 0 auto; }

.profile-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.profile-card { grid-row: span 1; }
.profile-card.sex-male { border-top: 4px solid var(--male-600); }
.profile-card.sex-female { border-top: 4px solid var(--female-600); }
.profile-card.sex-male .profile-placeholder { background: linear-gradient(135deg, #15559f, #258dcc); }
.profile-card.sex-female .profile-placeholder { background: linear-gradient(135deg, #9b3c87, #e45589); }
.sex-chip { display: inline-flex; align-items: center; margin-left: 5px; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.sex-chip.sex-male { color: var(--male-600); background: var(--male-100); }
.sex-chip.sex-female { color: var(--female-600); background: var(--female-100); }
.sex-chip.sex-unknown { color: #66758c; background: #eef1f5; }
.result-card .sex-chip { margin: 8px 0 0; }
.profile-head { display: flex; align-items: center; gap: 15px; margin-bottom: 19px; }
.profile-head img, .profile-placeholder { width: 74px; height: 74px; display: grid; place-items: center; flex: 0 0 auto; object-fit: cover; border-radius: 18px; color: #fff; background: linear-gradient(135deg, #14539f, #19ad6a); font-size: 24px; font-weight: 800; }
.profile-head h2 { margin: 8px 0 4px; font-size: 18px; }
.profile-head p { margin: 0; color: var(--muted); font-size: 12px; }
.info-list { display: grid; gap: 0; margin: 0; }
.info-list > div { display: grid; grid-template-columns: minmax(110px, .7fr) 1.3fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid #edf1f5; }
.info-list > div:last-child { border-bottom: 0; }
.info-list dt { color: #7d8ca1; font-size: 11px; }
.info-list dd { margin: 0; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.status-hero { padding: 18px; color: var(--status-color); background: var(--status-bg); border-radius: 12px; text-align: center; }
.status-hero span { display: block; font-size: 11px; }
.status-hero strong { display: block; margin: 4px 0; font-size: 35px; }
.status-hero p { margin: 0; font-size: 11px; font-weight: 750; }
.mini-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.mini-metrics div { padding: 10px 7px; background: #f7f9fb; border-radius: 9px; text-align: center; }
.mini-metrics span { display: block; color: var(--muted); font-size: 9px; }
.mini-metrics strong { display: block; margin-top: 4px; font-size: 12px; }
.history-chart, .who-chart { min-height: 340px; position: relative; }
.history-chart svg, .who-chart svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 11px; }
.legend-point { width: 10px; height: 10px; border-radius: 50%; background: var(--red-600); }
.legend-point.sex-male { background: var(--male-600); }
.legend-point.sex-female { background: var(--female-600); }
.legend-line { width: 24px; height: 2px; margin-left: 12px; background: var(--blue-800); }
.success-text { color: var(--green-600); }

.photo-evolution { margin-bottom: 18px; overflow: hidden; }
.photo-comparison-wrap { max-width: 980px; margin: 0 auto 24px; }
.photo-comparison-wrap > p { margin: 8px 0 0; color: var(--muted); text-align: center; font-size: 10px; }
.photo-compare { --reveal: 50; position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #0c1727; border-radius: 15px; box-shadow: 0 12px 32px rgba(8,43,97,.16); }
.photo-compare img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: contain; }
.photo-compare .photo-after { clip-path: inset(0 0 0 calc(var(--reveal) * 1%)); }
.photo-compare input { width: 100%; height: 100%; min-height: 0; position: absolute; inset: 0; z-index: 4; margin: 0; opacity: 0; cursor: ew-resize; }
.compare-divider { width: 3px; height: 100%; position: absolute; left: calc(var(--reveal) * 1%); top: 0; z-index: 3; transform: translateX(-50%); background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.18); pointer-events: none; }
.compare-divider::after { content: "↔"; width: 38px; height: 38px; display: grid; place-items: center; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--blue-900); background: #fff; border-radius: 50%; box-shadow: 0 5px 18px rgba(0,0,0,.22); font-weight: 900; }
.compare-label { position: absolute; bottom: 12px; z-index: 3; padding: 6px 9px; color: #fff; background: rgba(8,24,45,.72); border-radius: 7px; font-size: 10px; pointer-events: none; }
.compare-label.before { left: 12px; }
.compare-label.after { right: 12px; }
.photo-timeline { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 15px; }
.photo-card { min-width: 0; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 15px rgba(27,49,83,.05); }
.photo-open { width: 100%; height: 210px; display: block; position: relative; overflow: hidden; padding: 0; background: #eaf0f6; border: 0; }
.photo-open img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .25s ease; }
.photo-open:hover img { transform: scale(1.025); }
.photo-open > span { position: absolute; right: 10px; bottom: 10px; padding: 5px 8px; color: #fff; background: rgba(8,43,97,.78); border-radius: 7px; font-size: 9px; font-weight: 800; }
.photo-card-body { padding: 13px; }
.photo-card-meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 9px; }
.photo-stage { padding: 4px 7px; color: var(--green-600); background: var(--green-100); border-radius: 999px; font-size: 9px; font-weight: 800; }
.photo-card time { color: var(--muted); font-size: 10px; }
.photo-card-body > strong { font-size: 12px; }
.photo-card-body > p { margin: 7px 0; color: #607188; font-size: 11px; line-height: 1.45; }
.photo-actions { display: flex; align-items: center; gap: 12px; margin-top: 11px; padding-top: 10px; border-top: 1px solid #edf1f5; }
.photo-actions a, .photo-actions button { padding: 0; color: var(--blue-800); background: none; border: 0; font-size: 10px; font-weight: 800; }
.photo-actions button { color: var(--red-600); }
.photo-empty .btn { margin-top: 14px; }
.photo-dialog { width: min(960px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; overflow: hidden; background: #081425; border: 0; border-radius: 16px; box-shadow: 0 28px 80px rgba(0,0,0,.45); }
.photo-dialog::backdrop { background: rgba(5,15,29,.78); backdrop-filter: blur(5px); }
.photo-dialog img { width: 100%; max-height: calc(100vh - 100px); display: block; object-fit: contain; }
.photo-dialog > button { width: 38px; height: 38px; position: absolute; right: 10px; top: 10px; z-index: 2; color: #fff; background: rgba(0,0,0,.55); border: 0; border-radius: 50%; font-size: 25px; }
.photo-dialog > p { margin: 0; padding: 13px 18px; color: #dfe9f5; font-size: 12px; text-align: center; }
.privacy-note { margin-bottom: 16px; padding: 13px 14px; color: #36506c; background: #eef6ff; border: 1px solid #dae9fa; border-radius: 11px; }
.privacy-note strong { font-size: 12px; }
.privacy-note p { margin: 4px 0 0; font-size: 10px; line-height: 1.45; }
.photo-upload-preview { min-height: 220px; display: grid; place-items: center; margin-bottom: 18px; overflow: hidden; color: #7d8ca1; background: linear-gradient(135deg, #f2f6fa, #edf3f8); border: 2px dashed #cad6e2; border-radius: 14px; font-size: 12px; }
.photo-upload-preview img { width: 100%; max-height: 420px; display: block; object-fit: contain; }
.recent-photo-panel { grid-column: 1 / -1; }
.recent-photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.recent-photo { min-width: 0; display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: center; padding: 8px; background: #f7f9fb; border-radius: 11px; }
.recent-photo img { width: 58px; height: 58px; object-fit: cover; border-radius: 9px; }
.recent-photo strong, .recent-photo small { display: block; }
.recent-photo strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.recent-photo small { margin-top: 4px; color: var(--muted); font-size: 9px; }

.assessment-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px; margin-bottom: 18px; }
.result-card { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 220px; color: var(--status-color); background: var(--status-bg); text-align: center; }
.result-z { font-size: 52px; line-height: 1; margin: 12px 0 6px; }
.result-card h2 { max-width: 360px; margin: 0; font-size: 18px; }
.result-card p { max-width: 420px; margin: 13px 0 0; color: #53657c; font-size: 11px; }
.eyebrow { color: var(--blue-800); text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 800; }
.recovered-badge { margin-top: 10px; padding: 5px 9px; color: #116c3c; background: #fff; border-radius: 999px; font-size: 10px; font-weight: 800; }
.metric-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric-list div { padding: 16px; background: #f7f9fb; border-radius: 11px; }
.metric-list span { display: block; color: var(--muted); font-size: 11px; }
.metric-list strong { display: block; margin-top: 6px; font-size: 23px; }
.metric-help { grid-column: 1 / -1; margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.measurement-warning { margin: 18px 0; padding: 16px 18px; color: #8a252f; background: #fff2f3; border: 1px solid #f2c8ce; border-left: 5px solid var(--red-600); border-radius: 12px; }
.measurement-warning strong { display: block; font-size: 14px; }
.measurement-warning p { margin: 5px 0 0; font-size: 11px; line-height: 1.5; }
.nutrition-classification { margin: 18px 0; }
.nutrition-scale { height: 76px; display: flex; position: relative; margin: 28px 4px 8px; color: #fff; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.scale-band { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 3px; text-align: center; }
.scale-band strong { font-size: 10px; }
.scale-band small { margin-top: 3px; font-size: 8px; opacity: .9; }
.scale-severe, .scale-moderate, .scale-risk, .scale-above { width: 14.285%; }
.scale-normal { width: 42.86%; }
.scale-severe { background: #b52135; border-radius: 12px 0 0 12px; }
.scale-moderate { background: var(--orange-600); }
.scale-risk { color: #5c4800; background: #f1c94a; }
.scale-normal { background: var(--green-600); }
.scale-above { background: var(--purple-600); border-radius: 0 12px 12px 0; }
.scale-marker { width: 3px; height: 94px; position: absolute; top: -9px; z-index: 2; transform: translateX(-50%); background: #17233a; border-radius: 4px; box-shadow: 0 0 0 2px #fff, 0 3px 9px rgba(0,0,0,.25); }
.scale-marker::after { content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: #17233a; }
.scale-marker b { position: absolute; left: 50%; bottom: -23px; transform: translateX(-50%); padding: 3px 6px; color: #fff; background: #17233a; border-radius: 6px; font-size: 9px; white-space: nowrap; }
.scale-note { margin: 27px 0 0; color: var(--muted); font-size: 10px; text-align: center; line-height: 1.5; }
.municipality-list { display: grid; gap: 13px; }
.municipality-row { display: grid; grid-template-columns: minmax(210px, .8fr) minmax(160px, 1.2fr) 55px; gap: 14px; align-items: center; }
.municipality-row strong, .municipality-row small { display: block; }
.municipality-row strong { font-size: 12px; }
.municipality-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.municipality-row b { color: #66768c; text-align: right; font-size: 11px; }
.clinical-disclaimer { margin: 18px 0 0; padding: 11px 14px; color: #697a90; background: #edf2f7; border-radius: 9px; font-size: 10px; text-align: center; }
.supplementary-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 18px 0; }
.chart-details { padding: 0; overflow: hidden; }
.chart-details summary { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 18px 20px; cursor: pointer; list-style: none; }
.chart-details summary::-webkit-details-marker { display: none; }
.chart-details summary strong, .chart-details summary small { display: block; }
.chart-details summary strong { font-size: 14px; }
.chart-details summary small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.chart-details summary b { color: var(--blue-800); font-size: 11px; white-space: nowrap; }
.chart-details[open] summary { border-bottom: 1px solid var(--line); }
.chart-details .who-chart { min-height: 260px; padding: 10px; }

.span-2-panel { grid-column: span 2; }
.vertical-bars { min-height: 230px; display: flex; align-items: flex-end; justify-content: space-around; gap: 15px; padding: 20px 20px 0; border-bottom: 1px solid var(--line); }
.vertical-bars > div { width: 25%; height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
.vertical-bars span { width: 56%; min-height: 0; order: 2; background: linear-gradient(180deg, #2a78cb, #164f9e); border-radius: 8px 8px 0 0; transition: height .25s ease; }
.vertical-bars strong { order: 1; margin-bottom: 5px; font-size: 13px; }
.vertical-bars small { position: absolute; top: 205px; white-space: nowrap; color: var(--muted); font-size: 10px; }
.monthly-bars { display: grid; gap: 10px; }
.month-row { display: grid; grid-template-columns: 70px minmax(100px, 1fr) 35px 55px; gap: 10px; align-items: center; font-size: 11px; }
.month-row .progress i { background: linear-gradient(90deg, #1fbb69, #28ca76); }
.month-row small { color: var(--muted); }
.rank-list { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.rank-list li { display: flex; justify-content: space-between; gap: 15px; padding: 11px 0; border-bottom: 1px solid #edf1f5; counter-increment: rank; font-size: 12px; }
.rank-list li::before { content: counter(rank); width: 23px; height: 23px; display: grid; place-items: center; flex: 0 0 auto; color: var(--blue-800); background: var(--blue-100); border-radius: 7px; font-size: 10px; font-weight: 800; }
.rank-list li span { flex: 1; }
.report-summary span, .role-guide span { padding: 7px 10px; color: #52657d; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; }

.donor-report { max-width: 960px; margin: 0 auto; padding: 34px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.donor-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 20px; border-bottom: 2px solid var(--blue-900); }
.donor-header > div:first-child { display: grid; grid-template-columns: 42px auto; column-gap: 10px; align-items: center; }
.donor-header .brand-mark { grid-row: span 2; width: 42px; height: 42px; }
.donor-header small, .donor-header span { display: block; color: var(--muted); font-size: 10px; }
.donor-profile { display: grid; grid-template-columns: 90px 1fr auto; gap: 18px; align-items: center; padding: 25px 0; }
.donor-profile img, .donor-profile .profile-placeholder { width: 90px; height: 90px; border-radius: 18px; object-fit: cover; }
.donor-profile h1 { margin: 4px 0; font-size: 25px; }
.donor-profile p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.donor-status { max-width: 210px; padding: 15px; color: var(--status-color); background: var(--status-bg); border-radius: 12px; text-align: center; }
.donor-status span, .donor-status strong { display: block; }
.donor-status span { font-size: 10px; }
.donor-status strong { margin-top: 5px; font-size: 12px; }
.donor-report section { margin-top: 24px; }
.donor-report section h2 { font-size: 16px; }
.comparison-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.comparison-grid div { padding: 16px; background: #f7f9fb; border-radius: 12px; }
.comparison-grid span { color: var(--muted); font-size: 10px; }
.comparison-grid strong { display: block; margin-top: 6px; font-size: 18px; }
.comparison-grid p { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.donor-photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.donor-photo-grid figure { margin: 0; overflow: hidden; background: #f7f9fb; border-radius: 11px; }
.donor-photo-grid img { width: 100%; height: 170px; display: block; object-fit: cover; }
.donor-photo-grid figcaption { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; font-size: 9px; }
.donor-photo-grid figcaption span { color: var(--muted); }
.donor-report footer { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.donor-report footer > div { display: flex; justify-content: space-around; margin-top: 45px; text-align: center; line-height: 1.7; }

.error-page { min-height: 55vh; display: grid; place-items: center; align-content: center; text-align: center; }
.error-page > strong { color: var(--blue-100); font-size: 120px; line-height: 1; }
.error-page h2 { margin: -15px 0 10px; }
.error-page p { color: var(--muted); }
.error-page .btn { margin-top: 10px; }

.login-page { background: #eef4f9; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, #fff 0, #f5f9fc 34%, #eaf2f8 100%); }
.login-panel { width: 100%; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 390px; padding: 38px 34px; background: rgba(255,255,255,.96); border: 1px solid #dce6ef; border-radius: 20px; box-shadow: 0 18px 50px rgba(24,57,100,.1); text-align: center; }
.login-logo { width: 48px; height: 48px; margin: 0 auto 17px; }
.login-card h1 { margin: 0; color: var(--blue-950); font-size: 25px; letter-spacing: .05em; }
.login-title { margin: 7px 0 4px; color: #405873; font-size: 13px; font-weight: 700; }
.login-tagline { margin: 7px 0 0; color: #7c8ca0; font-size: 10px; }
.login-card .muted { color: var(--muted); font-size: 12px; }
.stack-form { display: grid; gap: 9px; margin-top: 24px; text-align: left; }
.stack-form label { margin-top: 5px; color: #42566e; font-size: 12px; font-weight: 750; }
.stack-form .btn { margin-top: 12px; }
.login-note { display: block; margin-top: 20px; color: #8a97aa; text-align: center; font-size: 10px; }
.donation-credit { margin-top: 18px; padding-top: 15px; border-top: 1px solid #e5edf4; display: grid; gap: 3px; color: #75869b; font-size: 10px; line-height: 1.35; }
.donation-credit strong { color: var(--blue-950); font-size: 12px; font-weight: 750; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.entity-config-grid { display: grid; grid-template-columns: minmax(210px, .55fr) 1.45fr; gap: 28px; align-items: start; }
.entity-brand-previews { display: grid; gap: 14px; }
.entity-logo-preview { display: flex; flex-direction: column; align-items: center; padding: 24px; background: linear-gradient(145deg, #f4f8fc, #eef5fb); border: 1px dashed #cbd9e8; border-radius: 16px; text-align: center; }
.entity-logo-canvas { width: 150px; height: 150px; display: grid; place-items: center; overflow: hidden; margin-bottom: 14px; color: #fff; background: linear-gradient(135deg, var(--blue-800), var(--green-600)); border: 8px solid #fff; border-radius: 28px; box-shadow: 0 14px 32px rgba(18,64,116,.14); }
.entity-logo-canvas img { width: 100%; height: 100%; display: block; padding: 5px; object-fit: contain; background: #fff; }
.entity-logo-canvas span { font-size: 54px; font-weight: 850; }
.entity-logo-preview strong { font-size: 13px; }
.entity-logo-preview small { max-width: 240px; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.entity-favicon-preview { display: flex; align-items: center; gap: 13px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; text-align: left; }
.entity-favicon-canvas { width: 52px; height: 52px; display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; color: #fff; background: linear-gradient(135deg, var(--blue-800), var(--green-600)); border: 6px solid #f4f7fb; border-radius: 13px; box-shadow: 0 7px 18px rgba(18,64,116,.12); }
.entity-favicon-canvas img { width: 100%; height: 100%; display: block; object-fit: contain; background: #fff; }
.entity-favicon-canvas span { font-weight: 850; }
.entity-favicon-preview strong, .entity-favicon-preview small { display: block; }
.entity-favicon-preview strong { font-size: 12px; }
.entity-favicon-preview small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.entity-brand-panel { padding: 22px; }
.entity-contact { text-align: center; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-grid { grid-template-columns: 1fr 1fr; }
  .current-status { grid-column: span 2; }
  .filter-bar { grid-template-columns: 1fr 1fr 1fr; }
  .filter-bar input { grid-column: span 2; }
}

@media (max-width: 880px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -280px; width: 260px; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open::after { content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(5,22,45,.52); backdrop-filter: blur(2px); }
  .mobile-menu { display: grid; place-items: center; }
  .page-wrap { padding: 16px; }
  .topbar { height: 68px; padding: 0 16px; }
  .role-chip { display: none; }
  .dashboard-grid, .assessment-grid { grid-template-columns: 1fr; }
  .supplementary-charts { grid-template-columns: 1fr; }
  .span-2-panel { grid-column: auto; }
  .profile-grid { grid-template-columns: 1fr; }
  .current-status { grid-column: auto; }
  .page-actions { align-items: stretch; flex-direction: column; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar input { grid-column: span 2; }
  .page-actions > .btn { align-self: flex-end; }
  .login-shell { padding: 18px; }
  .live-assessment { grid-template-columns: 1fr; }
  .entity-config-grid { grid-template-columns: 1fr; }
  .photo-timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn, input, select { min-height: 44px; }
}

@media (max-width: 620px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .callout { align-items: flex-start; flex-wrap: wrap; }
  .callout .btn { width: 100%; margin-left: 0; }
  .topbar-actions .user-menu summary > span:last-child { display: none; }
  .topbar h1 { max-width: 47vw; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
  .topbar p { max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-wrap { padding: 11px; }
  .panel, .form-section { padding: 15px; border-radius: 13px; }
  .page-actions > div { display: grid; grid-template-columns: 1fr; }
  .page-actions .btn, .detail-actions > .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar input { grid-column: auto; }
  .detail-actions > div { display: grid; }
  .profile-head { align-items: flex-start; }
  .metric-list, .comparison-grid { grid-template-columns: 1fr; }
  .donor-profile { grid-template-columns: 70px 1fr; }
  .donor-profile img, .donor-profile .profile-placeholder { width: 70px; height: 70px; }
  .donor-status { grid-column: span 2; max-width: none; }
  .donor-report { padding: 20px; }
  .donor-photo-grid { grid-template-columns: 1fr; }
  .donor-photo-grid img { height: min(70vw, 280px); }
  .age-preview { align-items: flex-start; flex-direction: column; gap: 4px; }
  .age-preview small { margin-left: 0; }
  .live-metrics { grid-template-columns: repeat(2, 1fr); }
  .sticky-actions { bottom: 5px; }
  .sticky-actions .btn { flex: 1; }
  .photo-timeline { grid-template-columns: 1fr; }
  .photo-open { height: min(65vw, 260px); }
  .photo-compare { aspect-ratio: 4 / 5; }
  .compare-label { max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .recent-photo-grid { grid-template-columns: 1fr; }
  .history-chart, .who-chart { min-height: 220px; overflow-x: auto; }
  .login-card { padding: 30px 22px; border-radius: 16px; }
  .entity-logo-canvas { width: 125px; height: 125px; }
  .nutrition-scale { height: 105px; }
  .scale-band strong { font-size: 8px; }
  .scale-band small { font-size: 7px; }
  .municipality-row { grid-template-columns: 1fr 45px; gap: 8px; }
  .municipality-row .progress { grid-column: 1 / -1; grid-row: 2; }
  table { min-width: 680px; }
  .photo-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .messages { display: none !important; }
  .app-shell { display: block; }
  .page-wrap { padding: 0; }
  .donor-report { max-width: none; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .donor-report table { page-break-inside: avoid; }
}

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