.action-panel {
  grid-template-columns: 1fr 1fr auto;
}

.policy-note span {
  line-height: 1.55;
}

dialog select,
dialog textarea {
  border: 1px solid var(--line);
  padding: 11px;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

#download-fee-oa[aria-disabled="true"] {
  opacity: .68;
  border-style: dashed;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #071b32 0%, #123d66 55%, #e9eef3 55%);
}

.auth-card {
  width: min(430px, 100%);
  padding: 38px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 32px 90px rgba(3, 20, 40, .28);
}

.auth-card .brand-mark { margin-bottom: 24px; background: var(--navy); color: #fff; }
.auth-card h1 { margin: 0 0 10px; color: var(--navy); }
.auth-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.auth-card form { display: grid; gap: 14px; margin-top: 24px; }
.auth-card label, .revenue-toolbar label { display: grid; gap: 6px; color: var(--navy); font-size: 12px; font-weight: 650; }
.auth-card input, .revenue-toolbar input {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.auth-message {
  margin: -2px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--red);
  background: #fff1f1;
  color: var(--red);
  font-size: 13px;
  line-height: 1.55;
}

.auth-card .button:disabled {
  cursor: wait;
  opacity: .72;
}

.topbar .top-actions { align-items: center; }
.user-menu { display: flex; align-items: center; gap: 8px; border-left: 1px solid var(--line); padding-left: 10px; }
.user-menu span { color: var(--navy); font-size: 12px; white-space: nowrap; }

.revenue-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
  padding: 15px;
  background: #fff;
  border: 1px solid var(--line);
}

.revenue-toolbar .source-status { margin-right: auto; }
.revenue-kpis { margin-bottom: 18px; }
.revenue-kpis strong { font-size: 24px !important; }
.revenue-table-filters { display:grid; grid-template-columns:minmax(210px,1fr) 170px 260px auto; align-items:end; gap:10px; margin:0 0 10px; padding:14px 15px; border:1px solid var(--line); background:#fff; }
.revenue-table-filters label { display:grid; gap:6px; color:var(--navy); font-size:11px; font-weight:650; }
.revenue-table-filters input,.revenue-table-filters select { width:100%; min-height:38px; border:1px solid var(--line); border-radius:5px; padding:8px 10px; background:#fff; color:var(--ink); font:inherit; }
.revenue-table-filters input:focus,.revenue-table-filters select:focus { outline:2px solid rgba(47,111,166,.17); border-color:#4c82ad; }
.revenue-table-count { align-self:center; color:var(--muted); font-size:11px; white-space:nowrap; }
.company-master-tabs { margin:0 0 12px; }
.company-master-tabs .tab { min-width:180px; }
.company-master-toolbar { min-height:72px; margin:0 0 18px; padding:15px; border:1px solid var(--line); background:#fff; }
.company-master-controls { min-height:40px; display:flex; align-items:center; gap:14px; }
.company-master-controls label { display:flex; align-items:center; gap:10px; color:var(--navy); font-size:12px; font-weight:650; }
.company-master-controls input { border:1px solid var(--line); border-radius:5px; padding:9px 11px; background:#fff; color:var(--ink); font:inherit; }
.company-master-controls .source-status { margin-right:auto; line-height:1.6; }
.company-master-controls .button { margin-left:auto; }
.sf-company-aliases { min-width:240px; max-width:520px; }
.sf-company-aliases summary { cursor:pointer; color:#2f6fa6; line-height:1.55; }
.sf-company-aliases div { margin-top:8px; padding:9px 10px; background:#f5f8fb; color:var(--muted); line-height:1.65; }
.sf-association-editor { margin:16px 0; padding:14px; border:1px solid var(--line); background:#f8fafc; }
.sf-association-editor > label { margin:0 0 12px; }
.sf-selected-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; color:var(--navy); font-size:12px; }
.sf-selected-head span { color:var(--muted); font-weight:400; }
.sf-company-selected { display:flex; flex-wrap:wrap; gap:6px; min-height:32px; margin-bottom:12px; }
.sf-company-chip { display:inline-flex; align-items:center; gap:6px; border:1px solid #b9d0e3; border-radius:999px; padding:5px 8px 5px 10px; background:#edf5fb; color:#214f76; font-size:10px; }
.sf-company-chip button { border:0; padding:0; background:transparent; color:#59758d; font-size:15px; line-height:1; }
.sf-company-empty { color:var(--muted); font-size:11px; }
.sf-company-empty-block { padding:12px; }
.sf-company-alias-options { max-height:270px; overflow:auto; border:1px solid var(--line); background:#fff; }
.sf-company-option { display:grid; grid-template-columns:20px minmax(0,1fr); gap:8px; align-items:start; margin:0; padding:10px 11px; border-bottom:1px solid #edf0f3; cursor:pointer; }
.sf-company-option:last-child { border-bottom:0; }
.sf-company-option:hover { background:#f5f9fc; }
.sf-company-option input { margin-top:2px; }
.sf-company-option strong { display:block; color:var(--ink); font-size:11px; line-height:1.45; }
.sf-company-option small { display:block; margin-top:3px; color:var(--muted); font-size:9px; line-height:1.45; }
.sf-company-option.transfer small { color:#946b00; }
#revenue-exceptions { margin-top: 18px; }
.table-action[disabled] { opacity: .5; cursor: not-allowed; }
.cell-warning { color: #8a6500; font-weight: 650; }
.cell-muted { color: var(--muted); }
dialog small { color: var(--muted); font-weight: 400; }

@media (max-width: 1240px) {
  .topbar { height: auto; padding: 20px 0; align-items: flex-start; gap: 16px; }
  .topbar > .top-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 1080px) {
  .brand strong {
    font-size: 13px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .action-panel {
    grid-template-columns: 1fr;
  }

  .revenue-toolbar { align-items: stretch; flex-direction: column; }
  .revenue-toolbar .source-status { margin-right: 0; }
  .revenue-table-filters { grid-template-columns:1fr 1fr; }
  .revenue-table-count { align-self:end; min-height:38px; display:flex; align-items:center; }
}

@media (max-width: 720px) {
  .revenue-table-filters { grid-template-columns:1fr; }
  .company-master-tabs { width:100%; overflow:auto; }
  .company-master-controls { align-items:stretch; flex-direction:column; }
  .company-master-controls label { align-items:stretch; flex-direction:column; }
  .company-master-controls .button { width:100%; margin-left:0; }
}

.portal-screen { min-height: 100vh; padding: 60px max(32px, calc((100vw - 1180px) / 2)); background: linear-gradient(145deg,#071b32,#103657 42%,#f5f7fa 42%); }
.portal-head { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:56px; color:#fff; }
.portal-head h1 { margin:0 0 10px; font-size:36px; }
.portal-head p:not(.eyebrow) { color:#b9cadb; }
.portal-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:18px; }
.portal-card { min-height:310px; padding:30px; border:1px solid var(--line); background:#fff; text-align:left; display:flex; flex-direction:column; box-shadow:0 20px 55px rgba(7,27,50,.15); }
.portal-card[disabled] { display:none; }
.portal-card:hover { transform:translateY(-3px); border-color:#8fb2d2; }
.portal-card.resident { border-top:4px solid #2f6b55; }
.portal-card.knowledge { border-top:4px solid #416f9c; }
.portal-card.admin { border-top:4px solid #8a6300; }
.portal-index { color:#8aa0b8; font-size:11px; }
.portal-card strong { margin-top:45px; color:var(--navy); font-size:21px; }
.portal-card p { color:var(--muted); font-size:13px; line-height:1.75; }
.portal-card em { margin-top:auto; color:var(--blue); font-style:normal; font-size:12px; font-weight:700; }
.nav-item.disabled { opacity:.46; cursor:default; }
.platform-hero { padding:34px; background:#fff; border:1px solid var(--line); display:flex; justify-content:space-between; align-items:center; }
.platform-hero h2 { margin:0; color:var(--navy); font-size:28px; }
.platform-hero p:not(.eyebrow) { max-width:720px; color:var(--muted); line-height:1.7; }
.resident-hero { border-left:4px solid var(--green); }
.workspace-badge { min-width:140px; padding:20px; background:var(--green-soft); color:var(--green); text-align:center; font-size:12px; }
.workspace-badge strong { font-size:19px; }
.access-card-grid { display:flex; gap:10px; margin-top:16px; }
.access-card { padding:10px 13px; border:1px solid #bcd2c6; background:#fff; color:var(--green); font-size:12px; }
.module-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
.module-card { min-height:190px; padding:22px; border:1px solid var(--line); background:#fff; text-align:left; display:flex; flex-direction:column; }
.module-card.active { border-top:3px solid var(--green); cursor:pointer; }
.module-card > span { color:#8ca0b5; font-size:11px; }
.module-card strong { margin:28px 0 8px; color:var(--navy); font-size:16px; }
.module-card p { color:var(--muted); line-height:1.6; font-size:12px; }
.module-card em { margin-top:auto; color:#9ba5af; font-style:normal; font-size:10px; }
.resident-status label { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:12px; }
.resident-status select,.resident-status input { border:1px solid var(--line); padding:8px 10px; background:#fff; }
.resident-status .button { margin-left:auto; }
.resident-action { grid-template-columns:1fr 1fr auto; }
.admin-layout { display:grid; grid-template-columns:420px minmax(0,1fr); gap:18px; align-items:start; }
.admin-card { background:#fff; border:1px solid var(--line); padding:24px; }
.admin-card h3 { margin:0 0 20px; color:var(--navy); }
.admin-card > label { display:grid; gap:6px; margin:13px 0; color:var(--navy); font-size:12px; font-weight:650; }
.admin-card input,.admin-card select { border:1px solid var(--line); padding:10px; background:#fff; }
.admin-card fieldset { margin:15px 0; border:1px solid var(--line); display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.admin-card legend { color:var(--muted); font-size:11px; }
.admin-card fieldset label { color:var(--ink); font-size:11px; }
.admin-form-actions,.table-actions { display:flex; align-items:center; gap:8px; }
.admin-form-actions { justify-content:flex-end; margin-top:18px; }
.users-card .table-shell { max-height:720px; }
#platform-user-table td:first-child strong,#platform-user-table td:first-child small { display:block; }
#platform-user-table td:first-child small { color:var(--muted); margin-top:3px; }
.resident-result-head { display:flex; align-items:center; justify-content:space-between; margin:28px 0 16px; }
.resident-result-actions { display:flex; align-items:center; gap:10px; }
.source-audit { margin:14px 0 18px; padding:14px 16px; border-left:3px solid #8ca0b5; background:#f4f7fa; color:var(--ink); font-size:12px; line-height:1.65; }
.source-audit strong { color:var(--navy); }
.source-audit ul { margin:8px 0 0; padding-left:20px; }
#resident-result-table td:nth-child(6) strong,#resident-result-table td:nth-child(6) small { display:block; }
#resident-result-table td:nth-child(6) small { margin-top:3px; color:var(--muted); }
#director-resident-detail { margin-top:28px; }
#director-resident-detail-table td:last-child { min-width:260px; }
.resident-result-head h2 { margin:0; color:var(--navy); }
.resident-kpis { margin-bottom:16px; }
#resident-result-table td:first-child strong,#resident-result-table td:first-child small { display:block; }
#resident-result-table td:first-child small { color:var(--muted); margin-top:3px; }
#resident-result-table td:last-child { min-width:220px; }

.knowledge-layout { display:grid; grid-template-columns:310px minmax(0,1fr); min-height:calc(100vh - 150px); gap:18px; }
.knowledge-panel,.knowledge-conversation { border:1px solid var(--line); background:#fff; }
.knowledge-panel { padding:26px; }
.knowledge-panel h2 { margin:7px 0 10px; color:var(--navy); font-size:21px; }
.knowledge-panel > p:not(.eyebrow) { color:var(--muted); font-size:12px; line-height:1.7; }
.knowledge-scope-switch { display:grid; grid-template-columns:1fr 1fr; gap:7px; margin:22px 0 14px; }
.knowledge-scope-switch button { padding:10px 8px; border:1px solid var(--line); background:#f5f7fa; color:var(--muted); cursor:pointer; font-size:12px; }
.knowledge-scope-switch button.active { border-color:var(--blue); background:#eaf3fb; color:var(--navy); font-weight:700; }
.knowledge-stats { display:grid; padding:18px; background:#0c2944; color:#fff; }
.knowledge-stats strong { font-size:30px; line-height:1; }
.knowledge-stats span { margin-top:7px; font-size:12px; }
.knowledge-stats small { margin-top:14px; color:#a9bfd2; line-height:1.5; }
.knowledge-starters { margin:24px 0; }
.knowledge-starters > strong { display:block; margin-bottom:10px; color:var(--navy); font-size:12px; }
#knowledge-starter-list { display:grid; gap:7px; }
#knowledge-starter-list button,.knowledge-suggestions button { padding:9px 11px; border:1px solid #c8d7e4; background:#fff; color:#2f5e85; text-align:left; cursor:pointer; font-size:11px; line-height:1.45; }
#knowledge-starter-list button:hover,.knowledge-suggestions button:hover { border-color:#6e9cc2; background:#f4f9fd; }
.knowledge-panel > .button { width:100%; }
.knowledge-conversation { display:grid; grid-template-rows:auto minmax(340px,1fr) auto; min-width:0; }
.knowledge-head { display:flex; align-items:center; justify-content:space-between; padding:22px 26px; border-bottom:1px solid var(--line); }
.knowledge-head h2 { margin:4px 0 0; color:var(--navy); font-size:21px; }
.knowledge-messages { overflow:auto; padding:28px; background:#f7f9fb; }
.knowledge-message { display:flex; align-items:flex-start; gap:10px; max-width:820px; margin:0 0 20px; }
.knowledge-message.user { flex-direction:row-reverse; margin-left:auto; }
.knowledge-avatar { flex:0 0 32px; width:32px; height:32px; display:grid; place-items:center; border-radius:50%; background:#123b5c; color:#fff; font-size:11px; font-weight:700; }
.knowledge-message.user .knowledge-avatar { background:#2f6b55; }
.knowledge-bubble { padding:15px 17px; border:1px solid #d9e2ea; background:#fff; color:var(--ink); font-size:13px; line-height:1.75; box-shadow:0 5px 18px rgba(12,41,68,.04); }
.knowledge-message.user .knowledge-bubble { border-color:#bcd4c7; background:#edf6f1; }
.knowledge-message-loading .knowledge-bubble { min-width:220px; color:var(--navy); }
.knowledge-message-loading .knowledge-bubble > span:first-child { font-weight:700; }
.knowledge-message-loading .knowledge-bubble small { display:block; margin-top:5px; color:var(--muted); font-size:10px; }
.knowledge-loading-dots { display:inline-flex; gap:3px; margin-left:7px; vertical-align:middle; }
.knowledge-loading-dots i { width:5px; height:5px; border-radius:50%; background:#4c82ad; animation:knowledge-loading-pulse 1.2s infinite ease-in-out; }
.knowledge-loading-dots i:nth-child(2) { animation-delay:.15s; }
.knowledge-loading-dots i:nth-child(3) { animation-delay:.3s; }
@keyframes knowledge-loading-pulse { 0%,70%,100% { opacity:.3; transform:translateY(0); } 35% { opacity:1; transform:translateY(-2px); } }
@media(prefers-reduced-motion:reduce){.knowledge-loading-dots i{animation:none;opacity:.75}}
.knowledge-confidence { display:block; margin-top:9px; color:var(--muted); font-size:10px; }
.knowledge-citations { margin-top:13px; padding:12px 13px; border-left:3px solid #7196b7; background:#f2f6f9; }
.knowledge-citations strong { color:var(--navy); font-size:11px; }
.knowledge-citations p { margin:6px 0 0; color:#5f7181; font-size:10px; line-height:1.6; }
.knowledge-suggestions { display:flex; flex-wrap:wrap; gap:7px; margin-top:12px; }
.knowledge-form { padding:18px 24px 20px; border-top:1px solid var(--line); background:#fff; }
.knowledge-form > label { display:block; margin-bottom:7px; color:var(--navy); font-size:11px; font-weight:700; }
.knowledge-form textarea { width:100%; box-sizing:border-box; resize:vertical; border:1px solid #bdccd9; padding:12px 13px; color:var(--ink); font:inherit; line-height:1.55; }
.knowledge-form textarea:focus { outline:2px solid rgba(47,111,166,.17); border-color:#4c82ad; }
.knowledge-form > div { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:10px; }
.knowledge-form small { color:var(--muted); font-size:10px; line-height:1.5; }
.knowledge-form .button { flex:0 0 auto; }

@media(max-width:1080px){.portal-grid,.module-grid{grid-template-columns:1fr 1fr}.admin-layout{grid-template-columns:1fr}.knowledge-layout{grid-template-columns:1fr}.knowledge-panel{display:grid;grid-template-columns:1fr 1fr;gap:12px}.knowledge-panel .eyebrow,.knowledge-panel h2,.knowledge-panel>p{grid-column:1/-1}.knowledge-starters{margin:0}.knowledge-panel>.button{align-self:end}}
@media(max-width:720px){.portal-screen{padding:30px 18px}.portal-grid,.module-grid{grid-template-columns:1fr}.portal-head{display:block}.portal-head .button{margin-top:15px}.platform-hero{display:block}.workspace-badge{margin-top:16px}.resident-status{display:grid}.resident-status .button{margin:0}.admin-card fieldset{grid-template-columns:1fr}.resident-result-head{align-items:flex-start;gap:12px}.resident-result-actions{flex-direction:column;align-items:stretch}}
@media(max-width:720px){.knowledge-panel{display:block}.knowledge-starters{margin:24px 0}.knowledge-messages{padding:16px}.knowledge-form>div{align-items:stretch;flex-direction:column}.knowledge-form .button{width:100%}}
