/* Load after page styles. Local system fonts; no remote assets required. */
:root {
  --portal-navy: #172e49;
  --portal-navy-deep: #102237;
  --portal-teal: #08796f;
  --portal-teal-dark: #056158;
  --portal-canvas: #f5f7fa;
  --portal-surface: #fff;
  --portal-ink: #172637;
  --portal-muted: #566578;
  --portal-line: #e3e9ef;
  --portal-gold-bg: #fff3c4;
  --portal-gold-ink: #775000;
  --portal-radius: 12px;
  --portal-shadow: 0 2px 8px rgb(23 46 73 / 4%);
  --portal-sidebar: 224px;
  --portal-space: clamp(18px, 2.2vw, 32px);
  --primary: var(--portal-navy);
  --primary-dark: var(--portal-navy-deep);
  --primary-light: #30516f;
  --accent: var(--portal-teal);
  --secondary: var(--portal-teal);
  --success: #08734f;
  --warning: #956000;
  --danger: #b42336;
  --info: #087a8a;
  --dark: var(--portal-ink);
  --light: var(--portal-canvas);
  --border: var(--portal-line);
  --text: var(--portal-ink);
  --text-light: var(--portal-muted);
  --gray-50: var(--portal-canvas);
  --gray-100: #f0f3f6;
  --gray-200: var(--portal-line);
  --gray-300: #c6d0db;
  --gray-400: #738296;
  --gray-500: var(--portal-muted);
  --gray-600: #46576b;
  --gray-700: #314256;
  --gray-800: var(--portal-ink);
  --gray-900: #122033;
}
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--portal-canvas);
  color: var(--portal-ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body:has(.dashboard) { display: block; padding: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a, label, [role="button"] { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .65; }
img { max-width: 100%; }
svg { flex-shrink: 0; }
a { color: var(--portal-teal-dark); text-underline-offset: 3px; }
:is(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #098b80 !important;
  outline-offset: 3px;
}
.sidebar :focus-visible { outline-color: #80e4d5 !important; }
.hidden, [hidden] { display: none !important; }
.dashboard { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--portal-sidebar);
  height: 100vh; height: 100dvh; background: var(--portal-navy);
  color: #fff; display: flex; flex-direction: column; z-index: 100;
  overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid rgb(255 255 255 / 5%);
}
.sidebar-header { padding: 26px 22px; border-bottom: 1px solid rgb(255 255 255 / 10%); }
.logo { min-width: 0; gap: 10px; }
.sidebar .logo img { max-width: 172px; object-fit: contain; object-position: left; }
.nav-menu { flex: 1; list-style: none; padding: 15px 10px; margin: 0; }
.nav-item { margin-bottom: 5px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; width: 100%;
  min-height: 44px; padding: 11px 13px; border: 0; border-radius: 8px;
  background: transparent; color: #d3deea; font-size: 13px;
  font-weight: 500; text-decoration: none; text-align: left;
  transition: background .16s ease, color .16s ease;
}
.nav-link:hover { background: rgb(255 255 255 / 8%); color: #fff; }
.nav-link.active { background: #344e69; color: #fff; box-shadow: inset 3px 0 #72d6c5; }
.nav-link svg { width: 17px; height: 17px; stroke: currentColor; }
.sidebar-footer { padding: 18px 14px; padding-bottom: max(18px, env(safe-area-inset-bottom)); border-top: 1px solid rgb(255 255 255 / 10%); }
.user-info { margin-bottom: 12px; }
.user-name { font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.user-role, .agent-id { color: #c2d0df; opacity: 1; font-size: 11px; }
.user-avatar { background: #3b5670; width: 34px; height: 34px; }
.btn-logout { min-height: 42px; background: #344e69; border: 1px solid #4a637c; color: #fff; border-radius: 7px; }
.btn-logout:hover { background: #43617e; }
.main-content { flex: 1; min-width: 0; margin-left: var(--portal-sidebar); padding: var(--portal-space); }
.page-header { margin-bottom: 22px; }
.page-header h1 { font-size: clamp(22px, 2vw, 28px); font-weight: 700; letter-spacing: -.7px; line-height: 1.25; margin-bottom: 5px; }
.page-header p { color: var(--portal-muted); font-size: 13px; }
.stats-grid-full, .stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-mini, .stat-card {
  min-width: 0; background: var(--portal-surface); padding: 15px 17px;
  border: 1px solid var(--portal-line); border-radius: 10px;
  box-shadow: var(--portal-shadow); text-align: left;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-mini:hover, .stat-card:hover { transform: none; border-color: #bdccd7; box-shadow: var(--portal-shadow); }
.stat-num, .stat-value { font-size: 23px; line-height: 1.15; font-weight: 750; letter-spacing: -.7px; font-variant-numeric: tabular-nums; margin: 0; }
.stat-lbl, .stat-label { font-size: 10px; line-height: 1.4; font-weight: 650; text-transform: uppercase; letter-spacing: .6px; color: var(--portal-muted); margin: 0; }
.stat-mini.blue .stat-num { color: #2860b1; }
.stat-mini.orange .stat-num, .stat-mini.yellow .stat-num { color: #926000; }
.stat-mini.green .stat-num, .stat-mini.lime .stat-num { color: #08734f; }
.stat-mini.teal .stat-num { color: #087a8a; }
.stat-mini.red .stat-num, .stat-mini.crimson .stat-num { color: #b42336; }
.stat-mini.pink .stat-num { color: #b22f6a; }
.stat-mini.purple .stat-num { color: #7051ab; }
.stat-header { margin-bottom: 5px; }
.stat-icon { width: 32px; height: 32px; border-radius: 8px; }
.content-section, .submissions-section, .actions-section, .profile-section, .settings-card {
  background: #fff; border: 1px solid var(--portal-line); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow);
}
.content-section { overflow: hidden; }
.submissions-section, .actions-section { padding: 20px; margin-bottom: 22px; }
.section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; }
.submissions-section > .section-header { padding: 0 0 17px; margin-bottom: 0; }
.section-title { font-size: 14px; font-weight: 700; letter-spacing: -.15px; color: var(--portal-ink); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.filter-btn { min-height: 36px; padding: 7px 12px; border: 1px solid var(--portal-line); background: #fff; color: #46576b; border-radius: 7px; }
.filter-btn:hover { background: #f2f7f7; border-color: #a9c9c5; }
.filter-btn.active { background: var(--portal-teal); color: #fff; border-color: var(--portal-teal); }
.table-container { max-width: 100%; overflow: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #b4c1ce #f5f7fa; }
.data-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.data-table th { padding: 13px 17px; color: var(--portal-muted); background: #fafbfd; border-bottom: 1px solid var(--portal-line); font-size: 10px; letter-spacing: .6px; line-height: 1.4; font-weight: 650; text-align: left; text-transform: uppercase; }
.data-table td { padding: 16px 17px; border-bottom: 1px solid #eef1f5; font-size: 12px; line-height: 1.45; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
#submissionsTable, #allSubmissionsTable { min-width: 1320px; }
#submissionsTable td:nth-child(8), #submissionsTable td:nth-child(9), #allSubmissionsTable td:nth-child(8), #allSubmissionsTable td:nth-child(9) { min-width: 112px; max-width: 180px; }
.data-table tbody tr:hover, .data-table tbody tr:focus-within { background: #f7fbfa; }
.customer-name { color: #182637; font-size: 12px; font-weight: 700; }
.customer-email { color: var(--portal-muted); font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }
.customer-info { min-width: 135px; }
.status-badge, .ab-badge { display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 1.35; }
.status-pending, .ab-pending { background: var(--portal-gold-bg); color: var(--portal-gold-ink); }
.status-approved, .status-best-plan, .ab-paid { background: #e1f3eb; color: #075d43; }
.status-submitted { background: #e0f3f4; color: #086475; }
.status-chargeback, .status-cancel, .ab-unpaid { background: #fde8eb; color: #a22135; }
.status-denied-by-carrier { background: #fce8f1; color: #a12761; }
.status-denied-by-la { background: #efe9fb; color: #60428f; }
.status-not-licensed-in-that-state { background: #fff3c4; color: #775000; }
.ab-select { border-radius: 999px !important; font-size: 11px !important; min-height: 32px; max-width: 130px; }
.action-btns { display: flex; gap: 5px; }
.btn-icon, .btn-icon-table { min-width: 32px; min-height: 34px; padding: 7px; background: #fff; border: 1px solid var(--portal-line); border-radius: 6px; color: #4c6073; }
.btn-icon svg, .btn-icon-table svg { width: 15px; height: 15px; stroke: currentColor; }
.btn-icon:hover, .btn-icon-table:hover { border-color: #6caea5; background: #eff8f6; color: var(--portal-teal); }
.btn-icon.delete:hover { border-color: #e6a4ae; background: #fff1f3; color: var(--danger); }
.comment-input { min-height: 60px; resize: vertical; }
.comment-badge, .client-comment-view, .comment-text { overflow-wrap: anywhere; color: #425368; font-size: 12px; }
.client-comment-empty { color: var(--portal-muted); }
.comment-saved { color: var(--success); }
.empty-state { padding: 52px 22px; color: var(--portal-muted); }
.empty-state svg { stroke: #a1b1c0; }
.actions-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.action-card { padding: 22px; border: 1px solid var(--portal-line); background: #fff; border-radius: 10px; }
.action-card:hover { background: #f5fbf9; border-color: #76b5ad; }
.action-icon { background: #eaf6f2; border-radius: 12px; }
.action-icon svg { stroke: var(--portal-teal); }
.action-desc, .submission-details { color: var(--portal-muted); font-size: 13px; }
.submission-card, .agent-card, .customer-card { padding: 18px; background: #fff; border: 1px solid var(--portal-line); border-radius: 10px; margin-bottom: 12px; }
.submission-header, .customer-card-header { gap: 12px; }
.agent-card { gap: 16px; flex-wrap: wrap; }
.agent-actions, .submission-actions, .customer-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-section, .settings-card { padding: 24px; }
.settings-section { max-width: 760px; }
.profile-section { max-width: 720px; }
label, .form-group label { font-size: 13px; font-weight: 600; color: #283e52; }
.form-group { min-width: 0; margin-bottom: 18px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
  color: var(--portal-ink); background: #fff; border: 1px solid #cbd5df;
  border-radius: 8px; padding: 10px 12px; min-height: 42px;
  max-width: 100%; transition: border-color .16s, box-shadow .16s;
}
.form-group :is(input:not([type="radio"]):not([type="checkbox"]), select, textarea) { width: 100%; }
input::placeholder, textarea::placeholder { color: #69798c; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--portal-teal); box-shadow: 0 0 0 3px rgb(8 121 111 / 12%); }
input[readonly], input:disabled { background: #f0f3f6; color: #566578; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--portal-teal); flex-shrink: 0; width: 20px; height: 20px; vertical-align: middle; }
.btn, .btn-primary, .btn-secondary, .btn-danger, .btn-small, .btn-save-comment { border-radius: 8px; font-weight: 600; min-height: 40px; padding: 10px 16px; box-shadow: none; transition: background .16s, border-color .16s; }
.btn-primary, .btn-add, .btn-save-comment, .btn-download { background: var(--portal-teal); color: #fff; border: 1px solid var(--portal-teal); }
.btn-primary:hover, .btn-add:hover, .btn-save-comment:hover, .btn-download:hover { background: var(--portal-teal-dark); box-shadow: none; }
.btn-secondary, .btn-clear, .btn-edit { background: #fff; color: #30465a; border: 1px solid #cbd5df; }
.btn-secondary:hover, .btn-clear:hover, .btn-edit:hover { background: #f1f6f7; }
.btn-danger, .btn-delete, .btn-delete-small { background: var(--danger); color: #fff; }
.btn-small:hover { transform: none; }
.modal { padding: 24px; background: rgb(12 27 44 / 55%); backdrop-filter: blur(3px); }
.modal-content { max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--portal-line); border-radius: 16px; box-shadow: 0 24px 70px rgb(10 26 44 / 22%); }
.modal-header, .modal-body { padding: 22px 24px; }
.modal-header { background: #fff; border-bottom: 1px solid var(--portal-line); gap: 14px; }
.modal-header h2 { font-size: 18px; letter-spacing: -.3px; }
.modal-close { min-width: 40px; min-height: 40px; border-radius: 8px; }
.modal-footer { flex-wrap: wrap; padding: 18px 24px; background: #fafbfd; border-top: 1px solid var(--portal-line); }
.history-item { line-height: 1.6; }
body:has(.login-container) {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 24px;
  background: radial-gradient(ellipse at 20% 10%, #2d526b 0%, transparent 60%), var(--portal-navy-deep);
}
.login-container { max-width: 440px; border: 1px solid rgb(255 255 255 / 20%); border-radius: 20px; box-shadow: 0 26px 80px rgb(0 0 0 / 22%); }
.login-header { background: var(--portal-navy); padding: 34px 28px; border-bottom: 3px solid #5cb5a7; }
.login-header p { color: #d3deea; }
.login-body { padding: 30px; }
.login-body .btn-primary { width: 100%; min-height: 46px; }
.forgot-password a { color: #425a6e; }
.version { color: var(--portal-muted); }
.error-message { color: #a22135; background: #fff0f2; border-color: #b42336; }
body:has(#medicareForm) { padding: 28px 20px; }
body:has(#medicareForm) .container { max-width: 980px; border: 1px solid var(--portal-line); border-radius: 16px; box-shadow: var(--portal-shadow); }
.header { background: var(--portal-navy); padding: 30px; }
.header h1 { font-size: 25px; letter-spacing: -.6px; }
.header p { color: #d5e0eb; opacity: 1; font-size: 12px; letter-spacing: .4px; }
.form-content { padding: 28px; background: #fafbfd; }
#medicareForm .section { padding: 24px; margin-bottom: 20px; background: #fff; border-color: var(--portal-line); border-radius: 12px; }
#medicareForm .section-title { margin-bottom: 20px; padding-bottom: 13px; font-size: 16px; border-color: var(--portal-line); }
/* Existing form rows use the locally bundled Bootstrap responsive column grid. */
#medicareForm .row { display: flex; flex-wrap: wrap; --bs-gutter-x: 20px; --bs-gutter-y: 0; gap: 0; margin-left: -10px; margin-right: -10px; }
#medicareForm .row > .form-group { padding-left: 10px; padding-right: 10px; }
.radio-group, .checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-item, .checkbox-item { min-height: 46px; border: 1px solid var(--portal-line); padding: 10px 14px; border-radius: 8px; }
.radio-item label, .checkbox-item label { margin: 0; cursor: pointer; }
.radio-item:has(:checked), .checkbox-item:has(:checked) { background: #eaf7f3; border-color: #69afa3; }
.agreement-box { background: #f4f8fa; border: 1px solid var(--portal-line); border-radius: 10px; padding: 16px; }
.agreement-box label { font-size: 12px; line-height: 1.8; }
.agreement-box input { margin-right: 8px; }
.agreement-box .form-group { margin: 0; }
.signature-pad { touch-action: none; max-width: 100%; border-color: #bdcad6; background: #fff; }
.signature-controls, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.timestamp { background: #e1f3eb; color: #075d43; }
small { color: var(--portal-muted); font-size: 12px; }
.spinner-ring { border-top-color: var(--portal-teal); }
#loadingOverlay { background: rgb(245 247 250 / 97%); }
.loading-sub { color: var(--portal-muted); }
.portal-skip { position: fixed; left: 12px; top: -80px; z-index: 12000; background: #fff; color: var(--portal-ink); padding: 12px 18px; border-radius: 8px; }
.portal-skip:focus { top: 12px; }
.portal-mobile-bar, .portal-nav-backdrop { display: none; }
.portal-toast-stack { position: fixed; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 11000; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.portal-toast { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid #cbd5df; border-left: 4px solid var(--portal-teal); box-shadow: 0 8px 28px rgb(23 46 73 / 14%); border-radius: 10px; padding: 14px 16px; font-size: 13px; color: var(--portal-ink); pointer-events: auto; }
.portal-toast.toast { position: relative; inset: auto; width: auto; max-width: none; opacity: 1; animation: none; backdrop-filter: none; font-weight: 400; }
.portal-toast.toast.show { display: flex; }
.portal-toast[data-state="error"] { border-left-color: var(--danger); }
.portal-toast[data-state="busy"] { border-left-color: #a57500; }
.portal-toast-message { flex: 1; overflow-wrap: anywhere; }
.portal-toast-dismiss { min-width: 36px; min-height: 36px; border: 0; border-radius: 7px; color: #46576b; background: #f0f3f6; font-size: 20px; }
body.portal-layer-open { overflow: hidden; }
@media (max-width: 1200px) {
  :root { --portal-sidebar: 208px; }
  .stats-grid-full, .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .data-table th, .data-table td { padding-left: 13px; padding-right: 13px; }
}
@media (max-width: 800px) {
  .dashboard { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .portal-ready .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); height: 100dvh; transform: translateX(-100%); visibility: hidden; z-index: 300; transition: transform .2s ease, visibility .2s; }
  .portal-ready.portal-nav-open .sidebar { transform: translateX(0); visibility: visible; }
  .portal-mobile-bar { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 10px 16px; position: sticky; top: 0; z-index: 90; background: var(--portal-navy); color: #fff; border-bottom: 1px solid #344e69; }
  .portal-mobile-bar span { font-size: 13px; font-weight: 650; }
  .portal-nav-toggle { min-width: 44px; min-height: 42px; border: 1px solid #60748b; border-radius: 8px; background: #2c4662; color: #fff; font-size: 21px; }
  .portal-nav-toggle:focus-visible { outline-color: #80e4d5 !important; }
  .portal-nav-open .portal-nav-backdrop { display: block; position: fixed; inset: 0; background: rgb(12 27 44 / 55%); z-index: 290; }
  .stats-grid-full, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-mini, .stat-card { padding: 14px; }
  .actions-grid { grid-template-columns: 1fr; }
  .section-header { align-items: flex-start; flex-direction: column; padding: 16px; }
  .filters { width: 100%; }
  .filters :is(select, .search-box, .date-input) { flex: 1 1 140px; width: auto; min-width: 0; }
  .filter-btn, .btn-icon, .btn-icon-table, .btn-small, .btn-save-comment { min-height: 44px; }
  .btn-icon, .btn-icon-table { min-width: 44px; }
  .submissions-section, .actions-section { padding: 16px; }
  #medicareForm .row > .form-group { flex: 0 0 100%; width: 100%; }
  .modal { padding: 12px; }
  .modal-content { max-height: calc(100dvh - 24px); }
  .modal-header, .modal-body, .modal-footer { padding: 18px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; min-height: 44px; }
  .data-table .ab-select { font-size: 16px !important; min-height: 44px; }
  body:has(#medicareForm) { padding: 14px 10px; }
  .form-content { padding: 14px; }
  #medicareForm .section { padding: 18px; }
  .header { padding: 24px 18px; }
  .customer-card-header, .submission-header { flex-wrap: wrap; }
  .settings-section { padding: 16px; }
  .profile-section, .settings-card { padding: 18px; }
}
@media (max-width: 420px) {
  .stat-lbl { font-size: 9px; }
  .login-body { padding: 24px 20px; }
  body:has(.login-container) { padding: 16px; }
  .modal-footer > button { flex: 1; }
  .form-actions > button { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .portal-mobile-bar, .portal-toast-stack, .portal-skip { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .table-container { overflow: visible; }
  body { background: #fff; }
}
#loadingOverlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; z-index: 9999; }
.spinner-ring { width: 54px; height: 54px; border: 5px solid #e5e7eb; border-top-color: #087f8c; border-radius: 50%; animation: portal-spin .75s linear infinite; margin-bottom: 18px; }
.loading-label { font-size: 17px; font-weight: 700; color: #1e3a5f; margin: 0 0 5px; }
.loading-sub { font-size: 13px; color: #667085; margin: 0; }
@keyframes portal-spin { to { transform: rotate(360deg); } }
