/* Higginbotham Carrier Login Manager. Brand: Navy / Coral / Steel, Arial, flat, sharp corners. */
:root {
  --navy: #0A3255;
  --navy-2: #0d3f6b;
  --coral: #F05541;
  --coral-tint: #fdecea;
  --steel: #465F82;
  --medblue: #5596E1;
  --lightblue: #AAD7F5;
  --green: #00B464;
  --white: #FFFFFF;
  --offwhite: #F5F7FA;
  --panel: #fafbfd;
  --gray: #667487;
  --border: #DCE1E8;
  --navy-12: rgba(10, 50, 85, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  color: var(--steel);
  background: var(--offwhite);
  font-size: 14px;
  line-height: 1.6;
}
h1, h2, h3, h4 { color: var(--navy); font-weight: 700; letter-spacing: 0.2px; margin: 0; }
a { color: var(--medblue); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--medblue); outline-offset: 2px; }

/* ---------- Buttons (sharp, flat) ---------- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 9px 16px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--navy);
  color: var(--white);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--coral); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--navy); }
.btn-secondary:hover { background: var(--offwhite); filter: none; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--navy); filter: none; }
.btn-ghost-light { background: transparent; color: var(--white); border-color: rgba(255,255,255,0.5); }
.btn-ghost-light:hover { background: rgba(255,255,255,0.12); filter: none; }
.btn-danger { background: var(--coral); color: var(--white); }
.btn-block { width: 100%; padding: 12px; font-size: 13px; }
.btn-sm { padding: 6px 11px; font-size: 11px; }
a.btn { text-decoration: none; box-sizing: border-box; }

/* ---------- Login / gate ---------- */
.login {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--navy);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-top: 4px solid var(--coral);
  width: 100%; max-width: 380px;
  padding: 34px 30px;
}
.login-logo { width: 220px; max-width: 100%; display: block; margin: 0 auto 20px; }
.login-title { font-size: 20px; text-align: center; }
.login-sub { text-align: center; color: var(--gray); margin: 8px 0 22px; font-size: 13px; line-height: 1.5; }
.login-foot { color: rgba(255,255,255,0.7); font-size: 11px; margin-top: 20px; letter-spacing: 0.3px; }

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 16px; }
.label { display: block; font-size: 10px; font-weight: 700; color: var(--gray); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%;
  font-family: inherit; font-size: 14px;
  color: var(--navy);
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--white);
}
textarea { min-height: 66px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--medblue); box-shadow: none; }
.req-star { color: var(--coral); }
.form-error {
  background: var(--coral-tint); border-left: 4px solid var(--coral);
  color: var(--navy); padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
}
.form-error ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { height: 26px; display: block; }
.brand-divider { width: 1px; height: 26px; background: rgba(255,255,255,0.28); flex: none; }
.brand-app { font-weight: 700; letter-spacing: 0.3px; font-size: 15px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; }

/* SANDBOX tag: a persistent reminder this is not production */
.sandbox-tag {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid rgba(170,215,245,0.45); border-left: 3px solid var(--coral);
  background: rgba(255,255,255,0.06);
  padding: 5px 11px 5px 9px; line-height: 1;
}
.sandbox-ic { width: 18px; height: 18px; color: var(--lightblue); flex: none; }
.sandbox-txt { display: flex; flex-direction: column; gap: 2px; }
.sandbox-a { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; color: var(--white); }
.sandbox-b { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: rgba(170,215,245,0.95); }

/* User chip */
.userchip { display: flex; align-items: center; gap: 9px; }
.userchip-name { font-size: 13px; color: rgba(255,255,255,0.96); font-weight: 700; white-space: nowrap; }

/* ---------- Viewing-as dropdown ---------- */
.viewas { position: relative; }
.viewas-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.08); color: var(--white);
  border: 1px solid rgba(255,255,255,0.28); border-radius: 0;
  padding: 6px 10px; font-family: inherit; cursor: pointer; line-height: 1.1;
  appearance: none; -webkit-appearance: none;
}
.viewas-btn:hover { background: rgba(255,255,255,0.16); }
.viewas-btn.impersonating { border-color: var(--coral); background: rgba(240,85,65,0.22); }
.viewas-btn .vic { width: 16px; height: 16px; flex: none; }
.viewas-btn .vchev { width: 13px; height: 13px; flex: none; opacity: 0.85; }
.viewas-btn-lbl { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.viewas-btn-k { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.72); }
.viewas-btn-v { font-size: 12px; font-weight: 700; color: var(--white); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewas-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--white); border: 1px solid var(--border); border-top: 3px solid var(--coral);
  min-width: 300px; max-width: 360px;
}
.viewas-menu-h { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gray); padding: 11px 13px 7px; }
.viewas-menu-scroll { max-height: min(420px, 60vh); overflow: auto; }
.viewas-opt {
  display: block; width: 100%; text-align: left; background: none; cursor: pointer; font-family: inherit;
  border: none; border-top: 1px solid var(--offwhite); border-left: 3px solid transparent;
  padding: 9px 13px; color: var(--navy); appearance: none; -webkit-appearance: none;
}
.viewas-opt:hover { background: var(--offwhite); }
.viewas-opt.active { border-left-color: var(--coral); background: #eef3f9; }
.viewas-opt-name { display: block; font-weight: 700; color: var(--navy); font-size: 13px; }
.viewas-opt-meta { display: block; font-size: 11px; color: var(--gray); margin-top: 1px; }
.viewas-stop { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12.5px; color: var(--navy); }
.viewas-stop .vic { width: 16px; height: 16px; color: var(--coral); flex: none; }
.viewas-stop:hover { background: var(--coral-tint); }

/* ---------- Impersonation banner ---------- */
.impersonation {
  display: flex; align-items: center; gap: 13px;
  background: var(--coral-tint); border-left: 5px solid var(--coral);
  padding: 11px 20px;
}
.impersonation-ic { width: 20px; height: 20px; color: var(--coral); flex: none; }
.impersonation-txt { margin: 0; color: var(--navy); font-size: 13.5px; line-height: 1.45; flex: 1; }
.impersonation-txt strong { color: var(--navy); font-weight: 700; }
.impersonation .btn { flex: none; }

/* ---------- Nav ---------- */
.nav { background: var(--white); border-bottom: 2px solid var(--navy); display: flex; align-items: stretch; padding: 0 12px; gap: 2px; overflow-x: auto; }
.nav-link {
  background: none; border: none; border-bottom: 3px solid transparent;
  color: var(--steel); font-weight: 700; font-size: 11px; line-height: 1;
  padding: 15px 15px 12px; cursor: pointer; font-family: inherit; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 1.1px;
}
.nav-link:hover { color: var(--navy); background: var(--offwhite); }
.nav-link.active { color: var(--navy); border-bottom-color: var(--coral); }

/* ---------- View / layout ---------- */
.view { padding: 24px 22px; max-width: 1320px; margin: 0 auto; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.view-head > div { display: flex; gap: 10px; align-items: center; }
.view-title { font-size: 22px; }
.muted { color: var(--gray); }
.count { color: var(--gray); font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 10px; }

/* ---------- Toolbar (search + filters) ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { margin: 0; }
.toolbar input[type=text], .toolbar select { min-width: 160px; }
.search-wrap { flex: 1 1 240px; }

/* ---------- KPI tiles (dashboard), equal height ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  display: flex; flex-direction: column; gap: 12px; text-align: left; width: 100%;
  background: var(--white); border: 1px solid var(--border); border-top: 4px solid var(--navy);
  padding: 16px 18px 15px; font-family: inherit; appearance: none; -webkit-appearance: none; color: inherit;
}
button.kpi { cursor: pointer; }
.kpi.alert { border-top-color: var(--coral); }
.kpi.clickable { transition: background 0.12s; }
.kpi.clickable:hover { background: var(--offwhite); }
.kpi.alert.clickable:hover { background: var(--coral-tint); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 10px; color: var(--gray); font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px; }
.kpi-ic { color: var(--steel); flex: none; }
.kpi-ic .gl { width: 22px; height: 22px; display: block; }
.kpi.alert .kpi-ic { color: var(--coral); }
.kpi-value { font-size: 32px; font-weight: 700; color: var(--navy); line-height: 1; }
.kpi.alert .kpi-value { color: var(--coral); }
.kpi-foot { margin-top: auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--medblue); display: flex; align-items: center; gap: 5px; }
.kpi.clickable:hover .kpi-foot { color: var(--navy); }
.kpi-arrow { font-size: 13px; line-height: 1; }

/* ---------- Table ---------- */
.table-wrap { background: var(--white); border: 1px solid var(--border); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
thead th {
  background: var(--navy); color: var(--white);
  font-size: 10px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  text-align: left; padding: 11px 14px; white-space: nowrap; cursor: pointer; user-select: none;
  border-right: 1px solid rgba(255,255,255,0.08);
}
thead th:last-child { border-right: none; }
thead th.no-sort { cursor: default; }
thead th .arrow { color: var(--lightblue); margin-left: 4px; font-size: 9px; }
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--steel); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--panel); }
tbody tr:hover { background: #eef3f9; }
td.actions { white-space: nowrap; text-align: right; }
.cell-id { color: var(--navy); font-weight: 700; }
.empty { padding: 40px; text-align: center; color: var(--gray); }

/* ---------- Empty / loading / error state block ---------- */
.state-block { padding: 46px 24px; text-align: center; }
.state-ic { display: inline-flex; color: var(--lightblue); margin-bottom: 12px; }
.state-ic .gl { width: 34px; height: 34px; }
.state-title { color: var(--navy); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.state-sub { font-size: 13px; color: var(--gray); max-width: 460px; margin: 0 auto; line-height: 1.5; }
.loading { padding: 36px; text-align: center; color: var(--gray); font-size: 13px; letter-spacing: 0.3px; }
.loading::before {
  content: ""; display: block; width: 20px; height: 20px; margin: 0 auto 12px;
  border: 2px solid var(--border); border-top-color: var(--coral);
  animation: clm-spin 0.7s linear infinite;
}
@keyframes clm-spin { to { transform: rotate(360deg); } }

/* ---------- Badges (sharp rectangles) ---------- */
.badge { display: inline-block; padding: 3px 8px; font-size: 9px; font-weight: 700; color: var(--white); background: var(--gray); border-radius: 0; text-transform: uppercase; letter-spacing: 1px; line-height: 1.35; }
.badge-active { background: var(--green); }
.badge-inactive { background: var(--coral); }
.badge-review { background: var(--coral); }
.badge-ok { background: var(--offwhite); color: var(--steel); }
.badge-info { background: var(--medblue); }
.badge-admin { background: var(--coral); }
.badge-editor { background: var(--medblue); }
.badge-viewer { background: var(--steel); }
.badge-tier-1 { background: var(--coral); }
.badge-tier-2 { background: var(--medblue); }
.badge-tier-3 { background: var(--steel); }

/* ---------- Secret cell (mask + eyeball) ---------- */
.secret { display: inline-flex; align-items: center; gap: 6px; }
.secret-val { font-family: "Courier New", monospace; letter-spacing: 1px; color: var(--navy); }
.eye { background: none; border: 1px solid var(--border); border-radius: 0; cursor: pointer; padding: 3px 7px; font-size: 11px; line-height: 1; color: var(--steel); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.eye:hover { border-color: var(--medblue); color: var(--navy); }
.none { color: var(--gray); }

/* ---------- Review reason ---------- */
.review-reason { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--steel); }
.review-banner {
  margin-bottom: 16px; background: var(--coral-tint); border-left: 4px solid var(--coral); padding: 12px 14px;
}
.review-banner-h {
  font-size: 10px; font-weight: 700; color: var(--coral); text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 5px;
}
.review-banner-body { color: var(--navy); font-size: 14px; line-height: 1.5; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.pager .muted { font-size: 12px; }
.pager-size { display: flex; align-items: center; gap: 6px; margin-right: auto; text-transform: uppercase; letter-spacing: 1px; font-size: 11px; }
.pager-size select { min-width: auto; width: auto; padding: 5px 8px; font-size: 12px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,50,85,0.55); display: flex; align-items: flex-start; justify-content: center; padding: 44px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--white); width: 100%; max-width: 640px; border-top: 4px solid var(--coral); }
.modal-head { background: var(--navy); color: var(--white); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { color: var(--white); font-size: 16px; }
.modal-x { background: none; border: none; color: var(--white); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-x:hover { color: var(--lightblue); }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--offwhite); align-items: center; }
.modal-foot .spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.full { grid-column: 1 / -1; }
.modal.wide { max-width: 880px; }

/* Carrier / office profile (drill-down) */
a.profile-link { color: var(--medblue); cursor: pointer; text-decoration: none; border-bottom: 1px dotted var(--medblue); }
a.profile-link:hover { color: var(--navy); border-bottom-color: var(--navy); }
a.ext-link { color: var(--medblue); text-decoration: none; border-bottom: 1px dotted var(--medblue); word-break: break-all; }
a.ext-link:hover { color: var(--navy); border-bottom-color: var(--navy); }
.profile-ref { margin-bottom: 16px; }
.profile-summary { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray); margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.profile-section { margin-bottom: 20px; }
.profile-h { font-size: 13px; margin: 0 0 8px; color: var(--navy); display: flex; align-items: baseline; gap: 8px; }
.profile-h .profile-open { margin-left: auto; }
.empty-sm { color: var(--gray); font-size: 13px; padding: 4px 0; }
.profile-more { font-size: 11px; margin-top: 6px; }
.table-wrap.mini table { font-size: 13px; }
.table-wrap.mini thead th { font-size: 9px; padding: 8px 11px; letter-spacing: 1px; cursor: default; }
.table-wrap.mini tbody td { padding: 8px 11px; }
.table-wrap.mini tbody tr { cursor: pointer; }

/* Detail rows */
.detail-list { margin: -4px 0; }
.detail-row { display: grid; grid-template-columns: 190px 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: start; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { margin: 0; padding-top: 5px; }
.detail-row .val { color: var(--navy); word-break: break-word; padding-top: 2px; }
.detail-row .row-actions { display: flex; align-items: center; }

/* Small inline icon buttons (pencil / copy) */
.btn-icon {
  background: none; border: 1px solid transparent; border-radius: 0; cursor: pointer;
  padding: 3px 7px; font-size: 10px; line-height: 1; color: var(--steel); font-family: inherit;
  text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap; font-weight: 700;
}
.btn-icon:hover { border-color: var(--medblue); color: var(--navy); background: var(--offwhite); }
.copy-text { opacity: 0.45; }
.detail-row:hover .copy-text { opacity: 1; }
.copy-secret {
  background: none; border: 1px solid var(--border); border-radius: 0; cursor: pointer;
  padding: 3px 7px; font-size: 11px; line-height: 1; color: var(--steel); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
}
.copy-secret:hover { border-color: var(--medblue); color: var(--navy); }

/* Inline per-field editor */
.inline-edit { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.inline-edit input, .inline-edit select, .inline-edit textarea { width: 100%; }
.inline-actions { display: flex; gap: 8px; }
.inline-hint { font-size: 11px; color: var(--gray); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: var(--white); padding: 12px 18px; font-size: 13px; z-index: 100; border-left: 4px solid var(--green); max-width: 90vw; }
.toast.error { border-left-color: var(--coral); }

/* ---------- Autocomplete (roster search) ---------- */
.ac-wrap { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; background: var(--white); border: 1px solid var(--border); max-height: 240px; overflow-y: auto; z-index: 10; }
.ac-item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--offwhite); }
.ac-item:hover, .ac-item.active { background: var(--offwhite); }
.ac-item .ac-name { color: var(--navy); font-weight: 700; }
.ac-item .ac-meta { color: var(--gray); font-size: 12px; }

.role-pill { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; }
.users-hint { color: var(--gray); font-size: 12.5px; margin: -6px 0 16px; max-width: 720px; line-height: 1.55; }

/* ---------- Report tables: bounded height with a sticky header ---------- */
#table-host > .table-wrap { max-height: max(360px, calc(100vh - 320px)); overflow: auto; }
#table-host > .table-wrap thead th { position: sticky; top: 0; z-index: 2; }

/* Type-ahead filter combos (carrier / office / EPIC branch) */
.combo-wrap input { min-width: 210px; }

/* Hover copy button on agent-code cells */
.cell-code { white-space: nowrap; }
.cell-code .copy-cell { opacity: 0; margin-left: 6px; transition: opacity 0.12s; }
tr:hover .copy-cell, .copy-cell:focus { opacity: 1; }
