/* /var/www/rbrs/portal/assets/css/portal.css
   ADD portal styles. One layout for every brand; brand colours swap via body class. */

:root {
  --brand: #1F35D6;
  --brand-dark: #1A2CB3;
  --bar: #0E1A4F;
  --ink: #1B2233;
  --muted: #5B6478;
  --line: #DFE3EC;
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --success-bg: #E7F6EC; --success-ink: #1C6B37;
  --error-bg: #FDECEC;   --error-ink: #A12A2A;
  --info-bg: #E9EDFC;    --info-ink: #1A2C8F;
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

body.brand-automateav {
  --brand: #7A8436;
  --brand-dark: #66702C;
  --bar: #3D3D3D;
  --info-bg: #F1F3E4;
  --info-ink: #4D5420;
}

*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.6rem; margin: 0 0 16px; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 1rem; margin: 22px 0 6px; font-weight: 600; }
p { margin: 0 0 12px; }
code { font-family: var(--mono); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 460px; }
main.wrap { padding-top: 32px; padding-bottom: 48px; min-height: calc(100vh - 140px); }

/* Top bar */
.topbar { background: var(--bar); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand img { width: 130px; height: auto; display: block; }
.product { font-weight: 600; letter-spacing: 0.12em; font-size: 0.85rem; padding: 2px 8px; border: 1px solid rgba(255,255,255,0.45); border-radius: 4px; }
.topnav { display: flex; align-items: center; gap: 16px; font-size: 0.95rem; }
.topnav a, .topnav .link-button { color: #fff; }
.who { color: #C9D0EE; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* Forms */
.field { margin-bottom: 16px; min-width: 0; }
.field label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; color: var(--ink); background: #fff; }
.field input:focus, .inline-row input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 6px 0 14px; }
.code-input { font-family: var(--mono); font-size: 1.25rem; letter-spacing: 0.2em; }
.code-input::placeholder { font-family: var(--font); font-size: 0.95rem; letter-spacing: normal; }
.code-input.short { width: 170px; padding: 9px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); }
.inline-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn { display: inline-block; background: var(--brand); color: #fff; border: 2px solid var(--brand); border-radius: var(--radius); padding: 10px 20px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-block { width: 100%; }
.btn-secondary { background: #fff; color: var(--brand); }
.btn-secondary:hover { background: var(--info-bg); color: var(--brand-dark); }

/* Messages */
.notice { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; }
.notice-success { background: var(--success-bg); color: var(--success-ink); }
.notice-error { background: var(--error-bg); color: var(--error-ink); }
.notice-info { background: var(--info-bg); color: var(--info-ink); }

/* 2FA setup */
.steps { padding-left: 1.2em; }
.steps li { margin-bottom: 12px; }
.qr { margin: 12px 0; }
.qr img { display: block; width: 200px; height: 200px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.secret { display: inline-block; margin-top: 4px; padding: 4px 8px; background: var(--bg); border-radius: 4px; word-break: break-all; }
.recovery-codes { list-style: none; padding: 16px; margin: 16px 0 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; background: var(--bg); border-radius: var(--radius); }
.recovery-codes code { font-size: 1.05rem; }
details summary { cursor: pointer; color: var(--brand); }

/* Account */
.details { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; margin-right: 6px; }
.pill-on { background: var(--success-bg); color: var(--success-ink); }
.pill-off { background: var(--error-bg); color: var(--error-ink); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px 6px; }
.table td { border-bottom: 1px solid var(--line); padding: 8px 6px; }

/* ---------- Stage 2: customers & contacts ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 4px; }
.head-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.btn-small { padding: 6px 14px; font-size: 0.92rem; }

.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input[type=search] { flex: 1 1 280px; min-width: 0; padding: 9px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; background: #fff; }
.filter-bar select, .field select { padding: 9px 10px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; background: #fff; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
.field label.check { display: inline-flex; font-weight: 400; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }

.card.flush { padding: 0; overflow: hidden; }
.card.empty { text-align: center; padding: 40px 24px; }
.customer-list, .branch-list { list-style: none; margin: 0; padding: 0; }
.customer-list > li { border-bottom: 1px solid var(--line); }
.customer-list > li:last-child { border-bottom: 0; }
.customer-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; text-decoration: none; color: var(--ink); flex-wrap: wrap; }
.customer-row:hover { background: var(--bg); }
.cust-name { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.cust-meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.count { color: var(--muted); font-size: 0.88rem; }
.branch-row { padding-top: 9px; padding-bottom: 9px; padding-left: 36px; border-top: 1px dashed var(--line); }
.branch-row .cust-name { font-weight: 500; }
.branch-mark { color: var(--muted); }
.context-only > .customer-row .cust-name { color: var(--muted); font-weight: 500; }

.brand-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; }
.brand-pill-rbrs { background: #E6E9FB; color: #1A2C8F; }
.brand-pill-automateav { background: #EEF0DD; color: #4D5420; }
.tag { display: inline-block; padding: 0 8px; border-radius: 4px; background: #ECEEF3; color: var(--muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.grid-2 > * { min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.details.wide { grid-template-columns: 105px 1fr; }
.internal-note { background: #FFF8E6; border-left: 3px solid #E0B44C; padding: 10px 12px; border-radius: 0; font-size: 0.95rem; }
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.simple-list li:last-child { border-bottom: 0; }

.people-table td { vertical-align: top; }
.row-left td { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.access-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; margin: 0 4px 2px 0; }
.access-none { background: #ECEEF3; color: var(--muted); }
.access-own { background: #E3F1FA; color: #155A82; }
.access-all { background: var(--success-bg); color: var(--success-ink); }
.access-manage { background: #FFF1D6; color: #7A4E00; }

.placeholder { border-style: dashed; background: transparent; }
.danger-zone { margin-top: 8px; padding: 0 4px; display: flex; gap: 10px; align-items: center; }
.danger-zone form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.link-button.danger { color: var(--error-ink); }

/* Forms (wider pages) */
.form-card { max-width: 720px; }
.field textarea { width: 100%; padding: 10px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; color: var(--ink); resize: vertical; }
.field textarea:focus, .field select:focus, .filter-bar input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
fieldset.field { border: 0; padding: 0; margin: 0 0 16px; }
fieldset.field legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; padding: 0; }
.check-row { display: flex; gap: 20px; flex-wrap: wrap; }
.address-row { grid-template-columns: 2fr 1fr; }
.opt { font-weight: 400; color: var(--muted); }
.has-error input, .has-error textarea { border-color: var(--error-ink); }
.field-error { color: var(--error-ink); font-size: 0.88rem; margin: 6px 0 0; }
.form-actions { display: flex; gap: 16px; align-items: center; margin-top: 8px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; font-weight: 400 !important; }
.radio-card input, .field .radio-card input { width: auto; padding: 0; margin: 4px 0 0; flex: 0 0 auto; accent-color: var(--brand); }
.field .check input { width: 17px; padding: 0; }
.people-table + p, .table + p { margin-top: 12px; }
.topnav a, .topnav .link-button { white-space: nowrap; }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--info-bg); }

/* ---------- Customer details (R3-style) ---------- */
[hidden] { display: none !important; }
.segmented { display: inline-flex; border: 1px solid #C7CDDA; border-radius: var(--radius); overflow: hidden; }
.segmented label { display: inline-flex; align-items: center; gap: 0; margin: 0; padding: 9px 18px; cursor: pointer; font-weight: 500; background: #fff; border-right: 1px solid #C7CDDA; }
.segmented label:last-child { border-right: 0; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked) { background: var(--brand); color: #fff; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.name-row { grid-template-columns: 110px 1fr 1fr; }
.phone-row { grid-template-columns: 1.4fr 1fr; }
.form-section { font-size: 1rem; margin: 24px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; }
.acct { font-family: var(--mono); font-weight: 600; letter-spacing: 0.02em; }
.acct-col { display: inline-block; min-width: 92px; color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.acct-line { margin: 0 0 6px; }
.account-badge { background: var(--bg); padding: 10px 14px; border-radius: var(--radius); }
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 20px; }
.letter-cell { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.letter-cell label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.letter-cell .letter { font-weight: 700; font-size: 1.1rem; }
.letter-cell input { width: 100%; padding: 7px 9px; border: 1px solid #C7CDDA; border-radius: 6px; font: inherit; }
.letter-cell.has-error input { border-color: var(--error-ink); }

.foot { color: var(--muted); font-size: 0.85rem; padding: 18px 0 24px; }
.foot a { color: var(--muted); }

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .who { display: none; }
  .brand img { width: 100px; }
  .card { padding: 18px; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .grid-2, .radio-cards, .address-row { grid-template-columns: 1fr; }
  .name-row { grid-template-columns: 1fr; }
  .phone-row { grid-template-columns: 1.4fr 1fr; gap: 10px; }
  .acct-col { display: block; min-width: 0; font-size: 0.8rem; }
  .cust-name { flex-wrap: wrap; }
  .people-table th:nth-child(2), .people-table td:nth-child(2) { display: none; }
  .customer-row { padding: 12px 14px; }
  .branch-row { padding-left: 28px; }
  .topnav { gap: 12px; font-size: 0.88rem; }
  .product { display: none; }
}
