  :root {
    --navy: #2D5F5D;
    --navy-mid: #3A7270;
    --blue: #2D5F5D;
    --blue-light: #EAF2F1;
    --accent: #B8A9D4;
    --green: #3A7F6A;
    --amber: #C49A3C;
    --red: #B85450;
    --text: #1C1C2E;
    --muted: #7A7A8C;
    --border: #E0DAD0;
    --bg: #F5F0E8;
    --white: #FDFAF5;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { font-family: 'Jost', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

  /* ── LOGIN ── */
  #login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1C3534 0%, #2D5F5D 60%, #3A7270 100%);
    position: relative;
    overflow: hidden;
  }
  #login-screen::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(184,169,212,0.2) 0%, transparent 70%);
    top: -100px; right: -100px;
  }
  #login-screen::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(45,95,93,0.15) 0%, transparent 70%);
    bottom: -50px; left: -50px;
  }
  .login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 48px 52px;
    width: 440px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
    animation: fadeUp 0.5s ease;
  }
  @keyframes fadeUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:none; } }
  .login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
  }
  .login-logo-icon {
    width: 44px; height: 44px;
    background: var(--navy);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
  }
  .login-logo-icon svg { width: 24px; height: 24px; }
  .login-logo-text { font-family: 'Cormorant Garamond', serif; font-size: 20px; color: var(--navy); }
  .login-title { font-family: 'Cormorant Garamond', serif; font-size: 28px; color: var(--navy); margin-bottom: 6px; }
  .login-sub { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
  .form-group { margin-bottom: 18px; }
  .form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 6px; letter-spacing: 0.03em; }
  .form-group input {
    width: 100%; padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: 'Jost', sans-serif;
    font-size: 15px;
    color: var(--text);
    transition: border-color 0.2s;
    outline: none;
  }
  .form-group input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(45,95,93,0.15); }
  .login-btn {
    width: 100%; padding: 13px;
    background: var(--navy);
    color: white;
    border: none; border-radius: 10px;
    font-family: 'Jost', sans-serif;
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s, transform 0.1s;
  }
  .login-btn:hover { background: var(--navy-mid); }
  .login-btn:active { transform: scale(0.99); }
  .login-error {
    background: #FEF2F2; color: var(--red);
    border: 1px solid #FECACA;
    border-radius: 8px; padding: 10px 14px;
    font-size: 13px; margin-top: 14px;
    display: none;
  }

  /* ── PORTAL ── */
  #portal { display: none; }
  .topbar {
    background: var(--navy);
    color: white;
    padding: 0 32px;
    height: 64px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  }
  .topbar-left { display: flex; align-items: center; gap: 14px; }
  .topbar-icon {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
  }
  .topbar-title { font-family: 'Cormorant Garamond', serif; font-size: 18px; }
  .topbar-right { display: flex; align-items: center; gap: 16px; }
  .practice-badge {
    background: rgba(255,255,255,0.12);
    padding: 6px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 500;
  }
  .logout-btn {
    background: transparent; border: 1.5px solid rgba(255,255,255,0.3);
    color: white; padding: 6px 16px; border-radius: 8px;
    font-family: 'Jost', sans-serif; font-size: 13px;
    cursor: pointer; transition: background 0.2s;
  }
  .logout-btn:hover { background: rgba(255,255,255,0.1); }

  .nav-tabs {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex; gap: 0;
    padding: 0 32px;
  }
  .nav-tab {
    padding: 14px 22px;
    font-size: 14px; font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
  }
  .nav-tab:hover { color: var(--navy); }
  .nav-tab.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }

  .content { padding: 32px; max-width: 1300px; margin: 0 auto; }

  /* ── SUMMARY CARDS ── */
  .cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
  .card {
    background: var(--white);
    border-radius: 14px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    animation: fadeUp 0.4s ease both;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  }
  .card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); border-color: var(--navy); }
  .card.active-card { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(45,95,93,0.25); }
  .card:nth-child(1) { animation-delay: 0.05s; }
  .card:nth-child(2) { animation-delay: 0.1s; }
  .card:nth-child(3) { animation-delay: 0.15s; }
  .card:nth-child(4) { animation-delay: 0.2s; }
  .card-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 10px; }
  .card-value { font-family: 'Cormorant Garamond', serif; font-size: 32px; color: var(--navy); line-height: 1; }
  .card-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
  .card-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
  .card-icon.blue { background: var(--blue-light); }
  .card-icon.green { background: #D6EDE8; }
  .card-icon.amber { background: #F5EDD6; }
  .card-icon.purple { background: #EDE9F5; }

  /* ── CHARTS ── */
  .charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 32px; }
  .chart-card {
    background: var(--white);
    border-radius: 14px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  }
  .chart-title { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 20px; }
  .chart-wrap { position: relative; height: 220px; }

  /* ── TABLE ── */
  .section-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--navy); margin-bottom: 16px; }
  .table-card {
    background: var(--white);
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    overflow: hidden;
    margin-bottom: 32px;
  }
  .table-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
  }
  .table-header-title { font-size: 14px; font-weight: 600; color: var(--navy); }
  .search-input {
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Jost', sans-serif;
    font-size: 13px;
    outline: none;
    width: 220px;
    transition: border-color 0.2s;
  }
  .search-input:focus { border-color: var(--navy); }
  table { width: 100%; border-collapse: collapse; }
  thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px; font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
  tbody tr:last-child { border-bottom: none; }
  tbody tr:hover { background: var(--blue-light); }
  tbody td { padding: 13px 16px; font-size: 13px; color: var(--text); }
  .badge {
    display: inline-block;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
  }
  .badge-blue { background: #EAF2F1; color: #2D5F5D; }
  .badge-green { background: #D6EDE8; color: #2A6357; }
  .badge-amber { background: #F5EDD6; color: #8A6A1E; }
  .badge-red { background: #F5E0DF; color: #8A3230; }
  .badge-gray { background: #F1F5F9; color: #475569; }
  .badge-purple { background: #EDE9F5; color: #6B4FA0; }

  /* ── FILTERS ── */
  .filter-bar {
    display: flex; flex-wrap: wrap; gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }
  .filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 140px; flex: 1; }
  .filter-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
  .filter-select, .filter-input {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Jost', sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--white);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
  }
  .filter-select:focus, .filter-input:focus { border-color: var(--navy); }
  .reset-btn {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--muted);
    padding: 6px 14px;
    border-radius: 8px;
    font-family: 'Jost', sans-serif;
    font-size: 12px; font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
  }
  .reset-btn:hover { border-color: var(--navy); color: var(--navy); }

  /* ── LOADING ── */
  .loading {
    display: flex; align-items: center; justify-content: center;
    padding: 80px; color: var(--muted); gap: 12px; font-size: 14px;
  }
  .spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .tab-content { display: none; }
  .tab-content.active { display: block; }

  @media (max-width: 900px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .content { padding: 16px; }
  }

  /* ── RESET PASSWORD MODAL ── */
  .modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
  }
  .modal-overlay.open { display: flex; }
  .modal-box {
    background: var(--white);
    border-radius: 16px;
    padding: 36px 40px;
    width: 380px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
    animation: fadeUp 0.3s ease;
  }
  .modal-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--navy); margin-bottom: 6px; }
  .modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
  .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
  .modal-cancel {
    flex: 1; padding: 11px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: 'Jost', sans-serif; font-size: 14px;
    color: var(--muted); cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
  }
  .modal-cancel:hover { border-color: var(--navy); color: var(--navy); }
  .modal-submit {
    flex: 2; padding: 11px;
    background: var(--navy); color: white;
    border: none; border-radius: 10px;
    font-family: 'Jost', sans-serif; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: background 0.2s;
  }
  .modal-submit:hover { background: var(--navy-mid); }
  .modal-success { font-size: 13px; color: var(--green); margin-top: 12px; display: none; }
  .modal-error { font-size: 13px; color: var(--red); margin-top: 10px; display: none; background: #FEF2F2; border: 1px solid #FECACA; border-radius: 8px; padding: 8px 12px; }

/* ════════════════════════════════════════════════════════════════════════
   Above: copied verbatim from the old IDR Client Portal (idr_portal.html).
   Below: the same look for the pages the old portal didn't have --
   first-time setup, backup codes, account, claim timeline. Keep the old
   block untouched so the two portals stay visually identical.
   ════════════════════════════════════════════════════════════════════════ */
body.auth-page #login-screen { padding: 32px 16px; }
.login-card.wide { width: 500px; }
.login-card a { color: var(--navy); }
.login-links { text-align: center; margin-top: 16px; font-size: 13px; }
.login-links a { color: var(--muted); text-decoration: none; border-bottom: 1px dashed var(--border); }
.login-steps { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--green); margin-bottom: 6px; }
.login-note { background: #F5EDD6; color: #8A6A1E; border: 1px solid #EBD9AA; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 18px; }
.login-error.show { display: block; margin: 0 0 18px; }
.login-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 6px 0 12px; }
.login-check input { width: 16px; height: 16px; accent-color: var(--navy); }
.howto { padding-left: 20px; font-size: 14px; color: var(--text); margin-bottom: 12px; }
.howto li { margin-bottom: 6px; }
.qr { display: flex; justify-content: center; margin: 8px 0 14px; }
.qr img { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
details.small { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
details summary { cursor: pointer; color: var(--navy); }
code { font-family: ui-monospace, Consolas, monospace; }
.codes { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 18px; }
.codes li { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px; text-align: center; font-size: 15px; letter-spacing: .05em; }

.topbar a { color: white; text-decoration: none; }
.topbar-right form { display: flex; align-items: center; gap: 16px; }
.account-link { font-size: 13px; opacity: .85; }
.account-link:hover { opacity: 1; text-decoration: underline; }
a.nav-tab { text-decoration: none; display: block; }
.flash { background: #F5EDD6; color: #8A6A1E; border: 1px solid #EBD9AA; border-radius: 10px; padding: 10px 16px; font-size: 13px; margin-bottom: 20px; }
.flash.error { background: #FEF2F2; color: var(--red); border-color: #FECACA; }
.updated { font-size: 12px; color: var(--muted); margin: -16px 0 24px; text-align: right; }
.foot { max-width: 1300px; margin: 0 auto; padding: 0 32px 32px; font-size: 12px; color: var(--muted); }
#overview-drilldown { display: none; margin-top: 32px; }
#overview-drilldown.open { display: block; }
.table-scroll { overflow-x: auto; }
td a.patient { color: var(--text); text-decoration: none; }
td a.patient:hover { color: var(--navy); text-decoration: underline; }
.muted-cell { color: var(--muted); font-size: 12px; }
.owed { color: var(--red); font-weight: 600; }
.paid { color: var(--green); font-weight: 600; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-family: 'Cormorant Garamond', serif; font-size: 30px; color: var(--navy); line-height: 1.1; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.back { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 14px; }
.back:hover { color: var(--navy); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: 14px; }
.detail-list dt { color: var(--muted); }
.timeline { list-style: none; }
.timeline li { padding: 9px 0 9px 22px; position: relative; border-left: 2px solid var(--border); margin-left: 6px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--navy); }
.timeline li.future::before { background: var(--white); border: 2px solid var(--border); }
.timeline .d { display: inline-block; min-width: 100px; color: var(--muted); }
.account-form .form-group input { background: var(--white); }
.account-form .login-btn { width: auto; padding: 11px 22px; }
.btn-outline { display: inline-block; background: transparent; border: 1.5px solid var(--border); color: var(--navy); padding: 9px 18px; border-radius: 10px; font-family: 'Jost', sans-serif; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn-outline:hover { border-color: var(--navy); }
.chart-card p { font-size: 14px; margin-bottom: 12px; }
.chart-card .stack { display: grid; gap: 4px; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .login-card, .login-card.wide { width: 100%; padding: 36px 24px; }
  .topbar { padding: 0 16px; }
  .practice-badge, .account-link { display: none; }
  .nav-tabs { padding: 0 16px; }
  .foot { padding: 0 16px 24px; }
}

/* Teramed's own multi-practice login: pick which practice's view to see. */
.viewing-as { font-size: 12px; opacity: .7; }
.switch-form { display: inline; }
.practice-badge.switch { border: 1.5px solid transparent; color: white; font-family: 'Jost', sans-serif; cursor: pointer; opacity: .6; }
.practice-badge.switch:hover { opacity: .9; }
.practice-badge.switch.on { opacity: 1; border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.2); }

/* Federal / New York State switch, for practices with both kinds of claim. */
.track-switch { display: inline-flex; background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 24px; }
.track-btn { border: none; background: transparent; padding: 9px 18px; border-radius: 9px; font-family: 'Jost', sans-serif; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background .2s, color .2s; }
.track-btn span { font-size: 12px; font-weight: 400; opacity: .8; }
.track-btn:hover { color: var(--navy); }
.track-btn.active { background: var(--navy); color: white; }
@media (max-width: 900px) { .track-switch { display: flex; } .track-btn { flex: 1; padding: 9px 8px; } .track-btn span { display: block; } }

/* Show-password eye inside password boxes (static/password-toggle.js). */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; border: none;
  color: var(--muted); cursor: pointer; padding: 6px; display: flex; border-radius: 6px; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--navy); background: var(--blue-light); outline: none; }

/* Uploads tab: the billing company sends EOB packets; Teramed's inbox. */
.upload-form { display: flex; flex-wrap: wrap; gap: 14px; padding: 18px 24px; align-items: flex-end; background: var(--bg); }
.upload-form .filter-group.grow { flex: 2; }
.upload-form input[type=file] { padding: 7px 10px; }
.upload-actions .login-btn { width: auto; padding: 10px 26px; margin: 0; }
.reset-btn.mark-added { border-color: var(--navy); color: var(--navy); font-weight: 600; }
.reset-btn.mark-added:hover { background: var(--navy); color: white; }

a.track-btn { text-decoration: none; display: inline-block; }
.preview-fieldset { border: none; display: contents; }
.preview-fieldset .login-btn { opacity: .5; cursor: not-allowed; }

/* Staff "View as" picker and the read-only banner while it's on. */
.view-as-form { display: flex; align-items: center; gap: 8px; }
.view-as-select { background: rgba(255,255,255,0.12); color: white; border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 8px; padding: 5px 8px; font-family: 'Jost', sans-serif; font-size: 13px; max-width: 260px; }
.view-as-select option { color: var(--text); background: var(--white); }
.viewas-banner { background: #F5EDD6; color: #8A6A1E; border-bottom: 1px solid #EBD9AA; padding: 10px 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 13px; }
.viewas-banner form { margin: 0; }
@media (max-width: 900px) { .view-as-form .viewing-as { display: none; } .viewas-banner { padding: 10px 16px; flex-wrap: wrap; } }

/* The upload form while a staff login is viewing as someone: visibly off. */
.viewas-note { background: #F5EDD6; color: #8A6A1E; font-size: 13px; padding: 10px 24px; border-bottom: 1px solid #EBD9AA; }
.preview-fieldset .filter-group { opacity: .5; }
.preview-fieldset input, .preview-fieldset select { cursor: not-allowed; }
