
  :root {
    --green-950: #003820;
    --green-900: #004d2a;
    --green-800: #006c3a;
    --green-700: #078048;
    --green-100: #dff2e8;
    --green-50: #f1f8f4;
    --gold: #d8a928;
    --gold-soft: #fff5d6;
    --ink: #183128;
    --muted: #62746c;
    --line: #d7e2dc;
    --surface: #ffffff;
    --canvas: #f5f8f6;
    --danger: #b42318;
    --danger-soft: #fff0ee;
    --warning: #8a5b00;
    --shadow: 0 14px 40px rgba(20, 63, 43, .09);
    --radius: 20px;
    --font: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
  }

  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; }
  button, input, select { font: inherit; }
  button, select { cursor: pointer; }
  button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(216, 169, 40, .55); outline-offset: 2px; }
  [hidden] { display: none !important; }
  h1, h2, h3, p { margin-top: 0; }
  h1, h2, h3 { line-height: 1.3; }
  .skip-link { position: fixed; z-index: 1000; left: 1rem; top: -5rem; background: #fff; color: var(--green-900); padding: .7rem 1rem; border-radius: .6rem; }
  .skip-link:focus { top: 1rem; }
  .muted { color: var(--muted); }
  .small { font-size: .82rem; }
  .eyebrow { margin: 0 0 .35rem; color: var(--green-700); font-size: .74rem; font-weight: 800; letter-spacing: .12em; }

  .login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) 1fr; background: #fff; }
  .login-brand { display: grid; place-items: center; position: relative; overflow: hidden; padding: 3rem; color: white; text-align: center; background: radial-gradient(circle at 15% 20%, rgba(231,185,74,.24), transparent 32%), linear-gradient(145deg, var(--green-950), var(--green-700)); }
  .login-brand::before, .login-brand::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; width: 34rem; aspect-ratio: 1; }
  .login-brand::before { right: -18rem; top: -11rem; }
  .login-brand::after { left: -23rem; bottom: -16rem; }
  .login-brand-inner { position: relative; z-index: 1; }
  .login-logo { width: min(210px, 42vw); filter: drop-shadow(0 18px 28px rgba(0,0,0,.25)); margin-bottom: 1.5rem; }
  .ministry-th { margin: 0 0 .15rem; color: #fff; font-size: 1.08rem; font-weight: 850; letter-spacing: .02em; }
  .login-brand .eyebrow { color: #caead8; }
  .login-brand h1 { font-size: clamp(2rem, 3.3vw, 3.6rem); margin-bottom: .6rem; letter-spacing: -.04em; }
  .login-brand h1 span, .brand-dot { color: var(--gold); }
  .login-brand p:last-child { color: #e3f1e9; font-size: 1.12rem; }
  .login-panel { display: grid; place-items: center; padding: 3rem; }
  .login-card { width: min(440px, 100%); }
  .login-card h2 { margin-bottom: .35rem; font-size: 2.15rem; }
  .login-logo-mobile { display: none; width: 90px; margin: 0 auto 1rem; }
  .login-version { display: block; margin: 1.4rem auto 0; }
  .remember-option { display: flex; align-items: center; gap: .65rem; margin-top: .9rem; color: #334c42; cursor: pointer; }
  .remember-option input { flex: 0 0 auto; width: 20px; min-height: 20px; accent-color: var(--green-800); }
  .remember-option strong, .remember-option small { display: block; }
  .remember-option strong { font-size: .86rem; }
  .remember-option small { color: var(--muted); font-size: .7rem; }

  .field { display: grid; gap: .4rem; min-width: 0; margin-top: 1rem; }
  .field > span:first-child { font-size: .88rem; font-weight: 700; color: #334c42; }
  .field small { color: var(--muted); font-size: .75rem; }
  input, select { width: 100%; min-height: 46px; border: 1px solid #cbd9d2; border-radius: 11px; background: #fff; padding: .65rem .78rem; color: var(--ink); transition: .15s ease; }
  input:hover, select:hover { border-color: #94b1a2; }
  input:focus, select:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(7,128,72,.1); outline: none; }
  input[readonly], select:disabled { color: #52665d; background: #f3f6f4; cursor: not-allowed; opacity: 1; }
  .readonly span:first-child::after { content: "  ล็อก"; color: #87978f; font-size: .7rem; font-weight: 500; }
  .password-wrap { position: relative; display: block; }
  .password-wrap input { padding-right: 4.5rem; }
  .password-toggle { position: absolute; top: 50%; right: .7rem; transform: translateY(-50%); }
  .text-button, .version-link { border: 0; background: transparent; color: var(--green-700); font-weight: 700; padding: .25rem; text-decoration: underline; text-underline-offset: 3px; }
  .button { min-height: 44px; border: 1px solid transparent; border-radius: 11px; padding: .65rem 1.1rem; font-weight: 800; transition: .16s ease; }
  .button:hover { transform: translateY(-1px); }
  .button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
  .button.primary { color: #fff; background: var(--green-800); box-shadow: 0 8px 20px rgba(0,108,58,.18); }
  .button.primary:hover { background: var(--green-900); }
  .button.secondary { color: var(--green-900); background: var(--green-100); border-color: #aad1bc; }
  .button.ghost { color: var(--green-900); background: #fff; border-color: var(--line); }
  .button.ghost.danger { color: var(--danger); }
  .button.danger-solid { color: #fff; background: var(--danger); }
  .button.wide { width: 100%; margin-top: .75rem; }
  .form-error { min-height: 1.4rem; color: var(--danger); margin: .55rem 0 0; font-size: .88rem; font-weight: 650; }

  .app-header { position: sticky; top: 0; z-index: 50; height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 max(1.25rem, calc((100vw - 1440px) / 2)); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
  .brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; }
  .brand-logo-wrap { position: relative; display: grid; place-items: center; flex: 0 0 50px; width: 50px; height: 50px; }
  .brand img { position: relative; z-index: 1; width: 50px; height: 50px; object-fit: contain; }
  .brand-logo-fallback { position: absolute; inset: 3px; display: grid; place-items: center; color: #fff; background: var(--green-800); border-radius: 50%; font-size: .55rem; font-weight: 900; }
  .brand strong, .brand small { display: block; }
  .brand strong { font-size: 1.05rem; }
  .brand small { max-width: min(620px, 48vw); color: var(--muted); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions { display: flex; align-items: center; gap: .55rem; }
  .profile-button { display: flex; align-items: center; gap: .65rem; padding: .42rem .58rem; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 999px; }
  .profile-copy { max-width: 230px; text-align: left; }
  .profile-copy strong, .profile-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .profile-copy strong { font-size: .82rem; }
  .profile-copy small { color: var(--muted); font-size: .68rem; }
  .avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: white; background: var(--green-800); font-weight: 800; }
  .header-sign-out { min-height: 42px; padding: .55rem .85rem; color: var(--danger); background: #fff; border: 1px solid #efc4bf; border-radius: 999px; font-weight: 800; white-space: nowrap; }
  .header-sign-out:hover { background: var(--danger-soft); }
  .module-nav { display: flex; gap: .35rem; padding: .65rem max(1.25rem, calc((100vw - 1440px) / 2)); background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .module-tab { white-space: nowrap; color: #4d6258; background: transparent; border: 0; border-radius: 10px; padding: .68rem 1rem; font-weight: 750; }
  .module-tab.active { color: var(--green-900); background: var(--green-100); }

  main { width: min(1440px, 100%); margin: 0 auto; }
  main:focus { outline: none; }
  .page-section { padding: 2rem 1.25rem 4rem; }
  .page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
  .page-heading h1 { margin: 0 0 .25rem; font-size: clamp(1.65rem, 2.5vw, 2.35rem); }
  .page-heading p:last-child { margin-bottom: 0; color: var(--muted); }
  .data-time { font-size: .78rem; }
  .dashboard-heading-actions { display: flex; align-items: center; gap: .75rem; }
  .dashboard-heading-actions .data-time { margin: 0; }
  .home-heading { margin-bottom: 1rem; }
  .home-module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .home-module-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; min-height: 190px; padding: 1.5rem; color: var(--ink); text-align: left; background: linear-gradient(145deg, #fff, var(--green-50)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
  .home-module-card:hover { border-color: #8fc4a8; transform: translateY(-2px); }
  .home-module-icon { display: grid; place-items: center; width: 64px; height: 64px; color: #fff; background: linear-gradient(145deg, var(--green-900), var(--green-700)); border-radius: 18px; font-size: 1.8rem; }
  .home-module-card strong, .home-module-card small { display: block; }
  .home-module-card strong { margin-bottom: .35rem; font-size: 1.15rem; }
  .home-module-card small { color: var(--muted); font-size: .8rem; }
  .home-module-arrow { color: var(--green-700); font-size: 1.7rem; }
  .filter-panel, .form-card, .chart-card, .metric-card, .summary-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 22px rgba(20,63,43,.04); }
  .filter-panel { padding: 1rem 1.15rem 1.15rem; margin-bottom: 1rem; }
  .filter-row { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)) auto; gap: .75rem; align-items: end; }
  .filter-row .field { margin-top: 0; }
  .filter-button { min-width: 100px; }
  .reporting-coverage { display: flex; align-items: flex-start; gap: .65rem; margin-top: .85rem; padding-top: .8rem; border-top: 1px solid var(--line); }
  .coverage-label { flex: 0 0 auto; padding-top: .22rem; color: var(--muted); font-size: .72rem; font-weight: 750; }
  .coverage-tags { display: flex; flex-wrap: wrap; gap: .38rem; }
  .coverage-tag { display: inline-flex; align-items: center; min-height: 28px; padding: .24rem .58rem; border: 1px solid transparent; border-radius: 999px; font-size: .69rem; font-weight: 800; cursor: help; }
  .coverage-tag.complete { color: #075d34; background: #dff4e8; border-color: #9fd1b5; }
  .coverage-tag.partial { color: #755100; background: #fff3c4; border-color: #e6c96d; }
  .coverage-tag.missing { color: #9f251c; background: #ffebe8; border-color: #e7aaa3; }
  .metric-grid { display: grid; grid-template-columns: 1.15fr repeat(4, 1fr); gap: .85rem; margin-bottom: .85rem; }
  .metric-card { min-height: 142px; padding: 1.15rem; overflow: hidden; }
  .metric-card.primary-metric { color: white; background: linear-gradient(145deg, var(--green-900), var(--green-700)); border-color: transparent; }
  .metric-label { color: var(--muted); font-size: .76rem; font-weight: 700; }
  .primary-metric .metric-label { color: #cde6d8; }
  .metric-value { display: block; margin-top: .55rem; font-size: clamp(1.35rem, 2.5vw, 2.35rem); line-height: 1.12; overflow-wrap: anywhere; }
  .metric-sub { display: block; margin-top: .5rem; color: var(--muted); font-size: .72rem; }
  .primary-metric .metric-sub { color: #dceee4; }
  .positive { color: #117a42; }
  .negative { color: var(--danger); }
  .primary-metric .positive, .primary-metric .negative { color: #fff; }
  .chart-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: .85rem; margin-bottom: 2rem; }
  .dashboard-chart-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .specialty-bar-card { grid-column: span 4; }
  .specialty-share-card { grid-column: span 2; }
  .top-procedure-card { grid-column: 1 / -1; }
  .comparison-half-card { grid-column: span 3; }
  .chart-card { padding: 1.05rem; min-height: 350px; min-width: 0; }
  .monthly-trend-card { min-height: 350px; margin-bottom: .85rem; }
  .chart-wide { min-width: 0; }
  .card-heading { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: 1rem; }
  .card-heading > div { display: flex; align-items: center; gap: .6rem; }
  .card-heading h2 { margin: 0; font-size: 1.05rem; }
  .card-heading > span { color: var(--muted); font-size: .7rem; white-space: nowrap; }
  .card-meta { display: grid !important; justify-items: end; gap: .14rem !important; color: var(--muted); text-align: right; white-space: nowrap; }
  .card-meta strong { color: var(--ink); font-size: .72rem; }
  .card-meta span { font-size: .68rem; }
  .chart-surface { min-width: 0; max-width: 100%; min-height: 270px; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; }
  .vertical-chart { width: 100%; height: 270px; display: flex; align-items: end; gap: clamp(.4rem, 2vw, 1.2rem); padding: 1.2rem .4rem 0; border-bottom: 1px solid var(--line); }
  #monthlyTrendChart { overflow-x: auto; overscroll-behavior-x: contain; }
  #monthlyTrendChart .vertical-chart { gap: clamp(2px, .6vw, 9px); min-width: 312px; }
  #monthlyTrendChart .vertical-column strong { font-size: .65rem; }
  .monthly-color-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 8px 0 0; color: var(--muted); font-size: .7rem; }
  .monthly-color-scale { width: 64px; height: 8px; flex: 0 0 auto; border-radius: 4px; background: linear-gradient(90deg, #bde6d3, #006b3d); }
  .monthly-zero-key { display: inline-flex; align-items: center; gap: 4px; }
  .monthly-zero-key::before { content: ''; width: 8px; height: 8px; background: #dce6e0; border-radius: 2px; }
  .vertical-column { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: .3rem; }
  .vertical-column strong { font-size: .72rem; }
  .vertical-bar { width: min(52px, 76%); min-height: 2px; border-radius: 9px 9px 2px 2px; background: linear-gradient(180deg, #37a76d, var(--green-800)); }
  .vertical-column span { width: 100%; overflow: hidden; text-align: center; text-overflow: ellipsis; font-size: .72rem; font-weight: 800; }
  .donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 1.4rem; width: 100%; justify-content: center; }
  .donut { display: grid; place-items: center; flex: 0 0 170px; width: 170px; height: 170px; border-radius: 50%; }
  .donut::after { content: attr(data-total) " เคส"; display: grid; place-items: center; width: 104px; height: 104px; border-radius: 50%; background: white; font-weight: 850; white-space: pre; }
  .legend { display: grid; gap: .4rem; min-width: 150px; }
  .legend-item { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: .4rem; font-size: .7rem; }
  .legend-item strong { white-space: nowrap; }
  .legend-dot { width: 9px; height: 9px; border-radius: 50%; }
  .rank-chart { display: grid; gap: .65rem; }
  .rank-row { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; align-items: center; gap: .65rem; font-size: .78rem; }
  .rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #topProcedureChart .rank-row { grid-template-columns: minmax(260px, 42%) 1fr auto; }
  #topProcedureChart .rank-label { overflow: visible; text-overflow: clip; white-space: normal; line-height: 1.25; }
  .rank-track { height: 16px; background: #edf3ef; border-radius: 999px; overflow: hidden; }
  .rank-bar { height: 100%; min-width: 2px; border-radius: 999px; background: linear-gradient(90deg, var(--green-700), #47ad77); }
  .empty-chart { color: var(--muted); text-align: center; padding: 4rem 1rem; }
  .section-heading { display: flex; justify-content: space-between; align-items: end; margin: 1.6rem 0 .8rem; }
  .section-heading h2, .section-heading h3 { margin: 0; }
  .section-heading.compact { margin-top: 0; }
  .specialty-ranking-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .85rem; }
  .specialty-rank-card { padding: 1rem; background: white; border: 1px solid var(--line); border-radius: 16px; }
  .specialty-rank-card h3 { margin: 0 0 .65rem; font-size: .95rem; }
  .specialty-rank-card h3 span { color: var(--green-700); margin-right: .35rem; }

  .form-card { padding: 1.25rem; margin-bottom: 1rem; }
  .step-number { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: white; background: var(--green-800); font-size: .8rem; font-weight: 800; }
  .required-note { color: var(--danger); font-size: .72rem; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 1rem; }
  .institution-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 0 1rem; margin-top: .15rem; }
  .report-month-card { display: grid; grid-template-columns: auto minmax(210px, 280px) minmax(280px, 1fr); gap: .8rem 1rem; align-items: center; }
  .report-month-card .card-heading { margin: 0; white-space: nowrap; }
  .month-field { margin-top: 0; }
  .report-month-card .info-banner { margin-top: 0; }
  .zero-report { display: flex; align-items: center; gap: .7rem; padding: .85rem; margin: .5rem 0 1rem; border: 1px solid #ead187; border-radius: 12px; background: var(--gold-soft); cursor: pointer; }
  .zero-report input { flex: 0 0 auto; width: 21px; min-height: 21px; accent-color: var(--green-800); }
  .zero-report strong, .zero-report small { display: block; }
  .zero-report small { color: #77652c; }
  .specialty-form { display: grid; gap: .7rem; }
  .specialty-group { border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
  .specialty-toggle { width: 100%; display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; border: 0; color: var(--ink); background: #fff; text-align: left; }
  .specialty-toggle input { width: 21px; min-height: 21px; accent-color: var(--green-800); }
  .specialty-toggle strong { margin-right: auto; }
  .specialty-code { padding: .18rem .48rem; border-radius: 999px; color: var(--green-900); background: var(--green-100); font-size: .7rem; }
  .specialty-total { min-width: 62px; padding: .22rem .5rem; color: var(--green-900); text-align: center; background: var(--green-100); border-radius: 999px; font-size: .72rem; font-weight: 850; white-space: nowrap; }
  .specialty-total.has-cases { color: #fff; background: var(--green-700); }
  .procedure-panel { padding: .9rem; border-top: 1px solid var(--line); background: var(--green-50); }
  .procedure-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .55rem; }
  .procedure-row { display: grid; grid-template-columns: minmax(0,1fr) 92px auto; align-items: center; gap: .5rem; min-height: 58px; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 11px; background: white; transition: .15s ease; }
  .procedure-row.main-procedure { grid-column: 1 / -1; border-color: #e0bc57; background: linear-gradient(90deg, var(--gold-soft), #fff); }
  .procedure-row.filled { border-color: #5faf82; background: #e8f7ef; box-shadow: inset 4px 0 0 var(--green-700); }
  .procedure-name { min-width: 0; font-size: .76rem; overflow-wrap: anywhere; }
  .main-procedure .procedure-name { font-size: .95rem; font-weight: 850; }
  .main-tag { display: inline-block; margin-left: .35rem; padding: .08rem .35rem; color: #6e4a00; background: #f4d889; border-radius: 999px; font-size: .58rem; }
  .procedure-row input { min-height: 39px; text-align: right; }
  .case-unit { color: var(--muted); font-size: .7rem; }
  .custom-area { margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed #bdd0c6; }
  .custom-list { display: grid; gap: .5rem; }
  .custom-row { display: grid; grid-template-columns: minmax(0,1fr) 110px auto; gap: .5rem; }
  .custom-row.filled { padding: .35rem; border-radius: 11px; background: #e8f7ef; box-shadow: inset 4px 0 0 var(--green-700); }
  .icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: #f1f5f2; font-size: 1.35rem; }
  .remove-custom { color: var(--danger); }
  .info-banner { margin-top: 1rem; padding: .8rem 1rem; border-left: 4px solid var(--gold); border-radius: 8px; color: #6b5108; background: var(--gold-soft); }
  .info-banner strong, .info-banner small { display: block; }
  .info-banner strong { font-size: .82rem; }
  .info-banner small { margin-top: .16rem; color: #79662d; font-size: .69rem; line-height: 1.45; }
  .summary-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem; margin: 1rem 0; color: #fff; background: linear-gradient(135deg, var(--green-900), var(--green-700)); border-color: transparent; }
  .summary-card p { margin-bottom: .25rem; color: #c9e5d6; }
  .summary-card h2 { margin: 0; font-size: 1.1rem; }
  .summary-total { display: flex; align-items: baseline; gap: .35rem; white-space: nowrap; }
  .summary-total strong { font-size: 3rem; line-height: 1; }
  .sticky-save { position: sticky; z-index: 20; bottom: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 520px; margin: 1rem 0 0 auto; padding: .75rem .8rem .75rem 1rem; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
  .sticky-save strong, .sticky-save small { display: block; }
  .sticky-save small { color: var(--muted); font-size: .68rem; }

  .dialog { width: min(760px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 20px; color: var(--ink); box-shadow: 0 30px 100px rgba(0,0,0,.25); overflow: auto; }
  .dialog::backdrop { background: rgba(0,35,20,.58); backdrop-filter: blur(3px); }
  .dialog > form, .profile-dialog .password-section { padding: 1.25rem; }
  .dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
  .dialog-heading h2 { margin: 0; }
  .dialog-heading p:last-child { color: var(--muted); margin: .25rem 0 0; }
  .dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
  .dialog-actions .danger:first-child { margin-right: auto; }
  .password-section { border-top: 1px solid var(--line); background: #f7faf8; }
  .profile-dialog { width: min(820px, calc(100% - 2rem)); }
  .compare-dialog { width: min(900px, calc(100% - 2rem)); }
  .comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
  .comparison-card { padding: 1rem; border: 1px solid var(--line); border-radius: 14px; }
  .comparison-card.new { border-color: #6eb58d; background: var(--green-50); }
  .comparison-card h3 { display: flex; justify-content: space-between; gap: .7rem; margin-bottom: .2rem; }
  .comparison-card .timestamp { color: var(--muted); font-size: .7rem; }
  .comparison-card ul { max-height: 270px; overflow: auto; padding-left: 1.2rem; }
  .comparison-total { color: var(--green-800); font-size: 1.6rem; }
  .warning-text { color: var(--warning); }
  .release-meta { display: grid; grid-template-columns: repeat(3,1fr); gap: .6rem; }
  .release-meta div { padding: .7rem; border-radius: 10px; background: var(--green-50); }
  .release-meta dt { color: var(--muted); font-size: .7rem; }
  .release-meta dd { margin: .2rem 0 0; font-weight: 800; overflow-wrap: anywhere; }
  .release-notes { padding-left: 1.3rem; }
  .app-footer { display: flex; justify-content: space-between; gap: 1rem; width: min(1440px,100%); margin: 0 auto; padding: 1rem 1.25rem 2rem; color: var(--muted); font-size: .75rem; }
  .loading-overlay { position: fixed; z-index: 200; inset: 0; display: grid; place-content: center; place-items: center; color: #fff; background: rgba(0,56,32,.76); }
  .spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.28); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
  .loading-overlay p { margin: .7rem 0 0; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .toast-region { position: fixed; z-index: 250; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; width: min(380px, calc(100% - 2rem)); }
  .toast { padding: .8rem 1rem; color: #fff; background: var(--green-900); border-radius: 11px; box-shadow: var(--shadow); }
  .toast.error { background: var(--danger); }

  @media (max-width: 1100px) {
    .filter-row { grid-template-columns: repeat(3, 1fr); }
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .primary-metric { grid-column: span 1; }
  }
  @media (max-width: 820px) {
    .login-view { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-panel { min-height: 100vh; padding: 2rem 1.25rem; background: radial-gradient(circle at top, var(--green-100), #fff 50%); }
    .login-logo-mobile { display: block; }
    .profile-copy { display: none; }
    .brand small { max-width: 42vw; }
    .metric-grid { grid-template-columns: repeat(2,1fr); }
    .chart-grid, .specialty-ranking-grid { grid-template-columns: 1fr; }
    .dashboard-chart-grid > .chart-card { grid-column: 1 / -1; }
    .home-module-grid { grid-template-columns: 1fr; }
    .home-module-card { min-height: 150px; }
    .procedure-list { grid-template-columns: 1fr; }
    .main-procedure { grid-column: auto; }
    .donut-wrap { flex-direction: column; }
  }
  @media (max-width: 620px) {
    .app-header { height: 68px; padding-inline: .85rem; }
    .brand-logo-wrap, .brand img { width: 43px; height: 43px; }
    .brand strong { font-size: .9rem; }
    .brand small { display: none; }
    .header-sign-out { width: 42px; padding: .45rem; overflow: hidden; color: transparent; }
    .header-sign-out span { color: var(--danger); font-size: 1.15rem; }
    .module-nav { padding-inline: .6rem; }
    .module-tab { padding: .6rem .7rem; font-size: .82rem; }
    .page-section { padding: 1.25rem .75rem 3rem; }
    .filter-row, .form-grid, .institution-row, .report-month-card { grid-template-columns: 1fr; }
    .report-month-card .card-heading { white-space: normal; }
    .report-month-card .info-banner { margin-top: 1rem; }
    .dashboard-heading-actions { align-items: flex-end; flex-direction: column-reverse; }
    .dashboard-heading-actions .button { white-space: nowrap; }
    .home-module-card { grid-template-columns: auto 1fr; min-height: 138px; padding: 1rem; }
    .home-module-icon { width: 52px; height: 52px; border-radius: 15px; font-size: 1.45rem; }
    .home-module-arrow { display: none; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .metric-card { min-height: 120px; padding: .9rem; }
    .metric-card.primary-metric { grid-column: 1 / -1; }
    .chart-card { min-height: 310px; }
    .rank-row { grid-template-columns: minmax(90px, 42%) 1fr auto; }
    #topProcedureChart .rank-row { grid-template-columns: minmax(0,1fr) auto; gap: .35rem .55rem; }
    #topProcedureChart .rank-label { grid-column: 1 / -1; }
    #topProcedureChart .rank-track { grid-column: 1; }
    .card-heading { align-items: flex-start; }
    .card-meta { white-space: normal; }
    .profile-dialog .form-grid { grid-template-columns: 1fr; }
    .comparison-grid { grid-template-columns: 1fr; }
    .release-meta { grid-template-columns: 1fr; }
    .custom-row { grid-template-columns: 1fr 85px auto; }
    .procedure-row { grid-template-columns: minmax(0,1fr) 76px auto; }
    .summary-card { align-items: start; }
    .summary-total strong { font-size: 2.4rem; }
    .sticky-save { bottom: .55rem; width: 100%; }
    .dialog-actions { flex-wrap: wrap; }
    .dialog-actions .button { flex: 1; }
    .app-footer { flex-direction: column; align-items: center; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }

.module-nav{flex-wrap:wrap}.admin-toolbar{display:flex;gap:12px;align-items:end;flex-wrap:wrap}.admin-table-scroll{overflow:auto;max-height:65vh;border-radius:12px;background:white}.admin-table-scroll table{width:100%;border-collapse:collapse;min-width:640px}.admin-table-scroll th,.admin-table-scroll td{padding:12px;text-align:left;border-bottom:1px solid #dbe7df}.admin-table-scroll th{position:sticky;top:0;background:#e9f3ed;z-index:1}.admin-table-scroll button{white-space:nowrap}.robotic-admin-dialog{width:min(960px,94vw);max-height:90dvh;overflow:auto;border:0;border-radius:18px;padding:24px}.robotic-admin-dialog::backdrop{background:#071b1466}.admin-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.admin-form-grid label{display:flex;flex-direction:column;gap:6px}.admin-form-grid input:not([type=checkbox]),.admin-form-grid select,.admin-form-grid textarea,.admin-toolbar input{width:100%;padding:10px;border:1px solid #b9ccbf;border-radius:8px;box-sizing:border-box}.admin-form-grid input[type=checkbox]{width:22px;height:22px}.admin-full{grid-column:1/-1}.robotic-admin-dialog [data-error]{color:#b22424}.admin-form-grid .admin-table-scroll{max-height:45vh}@media(max-width:600px){.admin-form-grid{grid-template-columns:1fr}.robotic-admin-dialog{padding:16px}}

.admin-readonly-note{padding:12px 16px;border:1px solid #bfd6f3;background:#eef5fd;border-radius:10px;color:#173858;line-height:1.6}.admin-form-grid output{display:block;min-height:42px;padding:10px 12px;border-radius:8px;background:#f1f5f9;font-weight:500}

  /* v1.6.0 compact responsive system — aligned with the URO•RJ density. */
  :root { --radius: 15px; --shadow: 0 9px 26px rgba(20,63,43,.075); }
  body { font-size: 14px; line-height: 1.42; }
  .eyebrow { margin-bottom: .22rem; font-size: .68rem; }
  .login-brand { padding: 2rem; }
  .login-logo { width: min(164px,36vw); margin-bottom: .9rem; }
  .login-brand h1 { margin-bottom: .35rem; font-size: clamp(1.8rem,3vw,3rem); }
  .login-brand p:last-child { font-size: 1rem; }
  .login-panel { padding: 2rem; }
  .login-card { width: min(400px,100%); }
  .login-card h2 { font-size: 1.75rem; }
  .login-version { margin-top: .7rem; }
  .forgot-password { display: block; margin: .45rem auto 0; }
  .field { gap: .28rem; margin-top: .68rem; }
  .field > span:first-child { font-size: .82rem; }
  input,select { min-height: 44px; padding: .55rem .7rem; border-radius: 9px; }
  .button { min-height: 44px; padding: .55rem .9rem; border-radius: 9px; font-size: .84rem; }
  .app-header { height: 66px; }
  .brand-logo-wrap,.brand img { width: 44px; height: 44px; flex-basis: 44px; }
  .brand strong { font-size: .96rem; }
  .profile-button { padding: .3rem .5rem; }
  .avatar { width: 32px; height: 32px; }
  .header-sign-out { min-height: 38px; padding: .45rem .72rem; font-size: .8rem; }
  .module-nav { gap: .25rem; padding-block: .45rem; }
  .module-tab { padding: .5rem .78rem; border-radius: 8px; font-size: .82rem; }
  main,.app-footer { width: min(1280px,100%); }
  .page-section { padding: 1.25rem 1rem 3rem; }
  .page-heading { margin-bottom: .85rem; }
  .page-heading h1 { margin-bottom: .12rem; font-size: clamp(1.4rem,2.1vw,1.9rem); }
  .home-module-grid { gap: .75rem; }
  .home-module-card { min-height: 132px; gap: .8rem; padding: 1rem; }
  .home-module-icon { width: 52px; height: 52px; border-radius: 14px; font-size: 1.45rem; }
  .home-module-card strong { font-size: 1rem; }
  .filter-panel { padding: .72rem .85rem .85rem; }
  .filter-row { gap: .55rem; }
  .metric-grid,.chart-grid,.specialty-ranking-grid { gap: .65rem; }
  .metric-card { min-height: 112px; padding: .85rem; }
  .metric-value { margin-top: .35rem; font-size: clamp(1.2rem,2.1vw,1.85rem); }
  .chart-card { min-height: 315px; padding: .85rem; }
  .monthly-trend-card { min-height: 315px; }
  .card-heading { margin-bottom: .7rem; }
  .chart-surface { min-height: 245px; }
  .vertical-chart { height: 245px; }
  .form-card { padding: .9rem; margin-bottom: .7rem; }
  .form-grid,.institution-row { gap: 0 .7rem; }
  .report-month-card { gap: .55rem .75rem; }
  .zero-report { padding: .65rem; margin: .35rem 0 .7rem; }
  .specialty-form { gap: .5rem; }
  .specialty-toggle { padding: .67rem .78rem; }
  .procedure-panel { padding: .65rem; }
  .procedure-list { gap: .4rem; }
  .procedure-row { min-height: 50px; padding: .42rem .55rem; }
  .summary-card { padding: .85rem 1rem; }
  .sticky-save { padding: .65rem .75rem; }
  .dialog { border-radius: 14px; }
  .dialog > form,.password-section { padding: 1rem; }
  .recovery-dialog { width: min(520px,calc(100% - 1.5rem)); }
  .privacy-note { margin: .65rem 0 0; padding: .55rem .65rem; color: var(--muted); background: var(--green-50); border-radius: 8px; font-size: .74rem; }
  .form-error.success { color: var(--green-700); }

  .admin-page-heading { align-items: flex-start; }
  .admin-heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; }
  .admin-toolbar { margin-bottom: .65rem; padding: .65rem .75rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
  .admin-search { display: grid; flex: 1 1 360px; gap: .25rem; color: #334c42; font-size: .78rem; font-weight: 700; }
  .admin-count { margin-left: auto; color: var(--muted); font-size: .78rem; font-weight: 700; }
  .admin-table-scroll { max-height: 58vh; border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 4px 16px rgba(20,63,43,.035); }
  .admin-table-scroll table { min-width: 720px; font-size: .78rem; }
  .admin-table-scroll th,.admin-table-scroll td { padding: 8px 9px; vertical-align: top; }
  .admin-table-scroll th { color: #27473a; background: #e7f3eb; font-size: .72rem; }
  .admin-action { min-height: 34px; padding: .35rem .55rem; font-size: .72rem; white-space: nowrap; }
  .admin-row-actions { display: flex; gap: .35rem; }
  .admin-cell-sub { display: block; margin-top: .12rem; color: var(--muted); font-size: .68rem; }
  .admin-nowrap { display: block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-status,.access-summary { display: inline-flex; align-items: center; min-height: 24px; padding: .15rem .45rem; border-radius: 999px; font-size: .68rem; font-weight: 800; white-space: nowrap; }
  .admin-status.active,.access-summary { color: var(--green-900); background: var(--green-100); }
  .admin-status.suspended { color: var(--danger); background: var(--danger-soft); }
  .admin-pagination { margin-top: .65rem; }
  .admin-pagination .button { min-height: 36px; }
  .robotic-master-grid { display: grid; grid-template-columns: minmax(300px,.72fr) minmax(520px,1.28fr); gap: .7rem; }
  .admin-table-card { min-width: 0; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
  .admin-table-card > header { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .65rem .8rem; border-bottom: 1px solid var(--line); }
  .admin-table-card > header h2,.admin-table-card > header p { margin: 0; }
  .admin-table-card > header h2 { font-size: .95rem; }
  .admin-table-card > header p,.admin-table-card > header span { color: var(--muted); font-size: .7rem; }
  .admin-table-card .admin-table-scroll { max-height: 54vh; border: 0; border-radius: 0; box-shadow: none; }
  .admin-suggestion-card { margin-top: .7rem; }
  .robotic-admin-dialog { padding: 1rem; border-radius: 14px; }
  .admin-form-grid { gap: .7rem; }
  .admin-form-grid label { gap: .25rem; font-size: .78rem; font-weight: 700; }
  .admin-form-grid input:not([type=checkbox]),.admin-form-grid select,.admin-form-grid textarea,.admin-toolbar input { min-height: 42px; padding: .5rem .65rem; }

  @media (max-width:1000px) {
    .robotic-master-grid { grid-template-columns: 1fr; }
    .filter-row { grid-template-columns: repeat(3,minmax(0,1fr)); }
  }
  @media (min-width:621px) and (max-width:900px) {
    .home-module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .home-module-card { min-height: 126px; }
    .profile-copy { display: none; }
    .brand small { max-width: 42vw; }
  }
  html.phone-ui body { font-size: 13.5px; }
  html.phone-ui .app-header { height: 60px; padding-inline: .65rem; }
  html.phone-ui .brand-logo-wrap,html.phone-ui .brand img { width: 38px; height: 38px; flex-basis: 38px; }
  html.phone-ui .brand strong { font-size: .84rem; }
  html.phone-ui .module-nav { padding: .35rem .45rem; flex-wrap: nowrap; }
  html.phone-ui .module-tab { padding: .46rem .58rem; }
  html.phone-ui .page-section { padding: .8rem .55rem 2.5rem; }
  html.phone-ui .page-heading { align-items: flex-start; margin-bottom: .6rem; }
  html.phone-ui .page-heading h1 { font-size: 1.3rem; }
  html.phone-ui .page-heading p:last-child { font-size: .76rem; }
  html.phone-ui .home-module-grid { grid-template-columns: 1fr; gap: .5rem; }
  html.phone-ui .home-module-card { min-height: 94px; padding: .7rem; }
  html.phone-ui .home-module-icon { width: 44px; height: 44px; }
  html.phone-ui .form-card,html.phone-ui .filter-panel,html.phone-ui .chart-card { padding: .65rem; }
  html.phone-ui .filter-row,html.phone-ui .form-grid,html.phone-ui .institution-row,html.phone-ui .report-month-card { grid-template-columns: 1fr; }
  html.phone-ui .field { margin-top: .48rem; }
  html.phone-ui .specialty-toggle { padding: .58rem .62rem; gap: .45rem; }
  html.phone-ui .procedure-row { grid-template-columns: minmax(0,1fr) 70px auto; min-height: 46px; padding: .35rem .45rem; }
  html.phone-ui .procedure-name { font-size: .72rem; }
  html.phone-ui .admin-page-heading { display: grid; }
  html.phone-ui .admin-heading-actions { justify-content: flex-start; }
  html.phone-ui .admin-toolbar { padding: .5rem; }
  html.phone-ui .robotic-admin-dialog { width: calc(100% - .75rem); max-height: calc(100dvh - .75rem); padding: .7rem; }
  html.phone-ui .admin-form-grid { grid-template-columns: 1fr; }
  @media (orientation:landscape) {
    html.phone-ui .home-module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    html.phone-ui .form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    html.phone-ui .login-panel { min-height: 100dvh; padding: .75rem 1rem; }
    html.phone-ui .login-logo-mobile { width: 62px; margin-bottom: .35rem; }
    html.phone-ui .login-card { width: min(560px,100%); }
  }
  /* Report content is one pixel larger, with less unused vertical space. */
  #reportView { font-size: 15px; }
  #reportView .page-heading { margin-bottom: .6rem; }
  #reportView .page-heading h1 { font-size: calc(clamp(1.4rem,2.1vw,1.9rem) + 1px); }
  #reportView .eyebrow { font-size: calc(.68rem + 1px); }
  #reportView .form-card { padding: .5rem .85rem; margin-bottom: .5rem; }
  #reportView .card-heading { margin-bottom: .4rem; }
  #reportView .card-heading h2 { font-size: calc(1.05rem + 1px); }
  #reportView .card-heading .small { font-size: calc(.82rem + 1px); }
  #reportView .field { gap: 3px; margin-top: 6px; }
  #reportView .field > span:first-child { font-size: calc(.82rem + 1px); }
  #reportView .readonly span:first-child::after { font-size: calc(.7rem + 1px); }
  #reportView .form-grid, #reportView .institution-row { column-gap: .7rem; }
  #reportView input:not([type=checkbox]), #reportView select { min-height: 38px; padding: .3rem .65rem; }
  #reportView .button { min-height: 38px; padding: .35rem .8rem; font-size: calc(.84rem + 1px); }
  #reportView .step-number { font-size: calc(.8rem + 1px); }
  #reportView .required-note { font-size: calc(.72rem + 1px); }
  #reportView .report-month-card { gap: .4rem .7rem; }
  #reportView .report-month-card .card-heading { margin: 0; }
  #reportView .zero-report { min-height: 44px; padding: .4rem .6rem; margin: .3rem 0 .5rem; }
  #reportView .zero-report small { font-size: calc(11.6667px + 1px); }
  #reportView .specialty-form { gap: 6px; }
  #reportView .specialty-toggle { min-height: 40px; padding: .3rem .7rem; }
  #reportView .specialty-code { font-size: calc(.7rem + 1px); }
  #reportView .specialty-total { font-size: calc(.72rem + 1px); }
  #reportView .procedure-panel { padding: .4rem .55rem; }
  #reportView .procedure-list { gap: 6px; }
  #reportView .procedure-row { min-height: 44px; padding: 3px .5rem; }
  #reportView .procedure-name { font-size: calc(.76rem + 1px); }
  #reportView .main-procedure .procedure-name { font-size: calc(.95rem + 1px); }
  #reportView .main-tag { font-size: calc(.58rem + 1px); }
  #reportView .case-unit { font-size: calc(.7rem + 1px); }
  #reportView .custom-area { margin-top: .5rem; padding-top: .5rem; }
  #reportView .custom-list { gap: 6px; }
  #reportView .info-banner { padding: .4rem .7rem; }
  #reportView .info-banner strong { font-size: calc(.82rem + 1px); }
  #reportView .info-banner small { font-size: calc(.69rem + 1px); }
  #reportView .summary-card { padding: .5rem .75rem; margin: .5rem 0; }
  #reportView .summary-card h2 { font-size: calc(1.1rem + 1px); }
  #reportView .summary-total strong { font-size: calc(3rem + 1px); }
  #reportView .form-error { margin-top: .35rem; font-size: calc(.88rem + 1px); }
  #reportView .sticky-save { gap: .6rem; margin-top: .5rem; padding: .35rem .65rem; }
  #reportView .sticky-save small { font-size: calc(.68rem + 1px); }
  html.phone-ui #reportView { font-size: 14.5px; }
  html.phone-ui #reportView .page-heading h1 { font-size: calc(1.3rem + 1px); }
  html.phone-ui #reportView .page-heading p:last-child { font-size: calc(.76rem + 1px); }
  html.phone-ui #reportView .form-card { padding: .5rem; }
  html.phone-ui #reportView .procedure-name { font-size: calc(.72rem + 1px); }
  html.phone-ui #reportView .zero-report small { font-size: calc(11.25px + 1px); }
  html.phone-ui #reportView .report-month-card .info-banner { margin-top: .4rem; }
  @media (max-width:620px) {
    #reportView .summary-total strong { font-size: calc(2.4rem + 1px); }
  }
  @media (pointer:coarse) {
    #reportView input:not([type=checkbox]), #reportView select, #reportView .button, #reportView .specialty-toggle { min-height: 44px; }
    #reportView .icon-button { min-width: 44px; width: 44px; min-height: 44px; height: 44px; }
  }
  .robotic-admin-dialog.reporter-user-dialog { width: min(1080px,calc(100vw - 24px)); }
  .reporter-permissions { border: 0; padding: 0; margin: 0; min-width: 0; }
  .reporter-permissions legend { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
  .reporter-permission-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
  .reporter-permission-row > label { display: flex; flex-direction: row; align-items: center; gap: 5px; white-space: nowrap; font-size: 12px; min-height: 30px; }
  .reporter-permission-row input[type=checkbox] { width: 16px; height: 16px; min-height: 16px; margin: 0; }
  .reporter-password-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .reporter-password-row > label { min-width: 0; }
  .merge-preview { padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #eef8f3; }
  .merge-preview p { margin: 6px 0; }
  .robotic-admin-dialog input,.robotic-admin-dialog select { transition-property: background-color,border-color,box-shadow; }
  @media (max-width:620px) { .reporter-password-row { grid-template-columns: minmax(0,1fr); } }
  @media (pointer:coarse) { .reporter-permission-row > label { min-height: 44px; } .robotic-admin-dialog input:not([type=checkbox]),.robotic-admin-dialog select,.robotic-admin-dialog .button,html.phone-ui .robotic-admin-dialog .admin-form-grid input:not([type=checkbox]),html.phone-ui .robotic-admin-dialog .admin-form-grid select { min-height: 44px; } }
