/* Insurance portal: plain CSS, no build step (works as-is on shared hosting). */
:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --ink: #1c2430;
    --ink-soft: #4a5565;
    --muted: #6b7686;
    --line: #dfe4ea;
    --brand: #1f4e79;
    --brand-dark: #163a5b;
    --brand-tint: #e5eef7;
    --ok-bg: #e4f3e8;   --ok: #1d6b34;
    --warn-bg: #fdf1dc; --warn: #8a5a00;
    --err-bg: #fbe9e7;  --err: #b3261e;
    --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--ink-soft); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a.active, .nav a:hover { color: var(--brand); border-bottom-color: var(--brand); }
.me { display: flex; align-items: center; gap: 12px; font-size: .92rem; margin-left: auto; }
.me-name { color: var(--ink-soft); }
.role { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--brand-tint); color: var(--brand); padding: 2px 6px; border-radius: 4px; margin-left: 4px; }
.inline { display: inline; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
    font: inherit; width: 100%; padding: 10px 12px; border: 1px solid #c9d1db; border-radius: 8px; background: #fff; color: var(--ink); min-height: 44px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(31, 78, 121, .3); outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.check input { width: 18px; height: 18px; }
.error { color: var(--err); font-size: .92rem; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; padding: 10px 18px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.block { width: 100%; }
button.link { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--ink-soft); cursor: pointer; }
button.link:hover { color: var(--brand); text-decoration: underline; }

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile.accent { border-color: var(--brand); background: var(--brand-tint); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.overdue { color: var(--err); font-weight: 600; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: #eceff3; color: var(--muted); }

@media (max-width: 560px) {
    .card { padding: 16px; }
    .me-name { display: none; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tile strong { font-size: 1.05rem; }
}

/* ---------- Step 3 screens ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.crumbs { margin: 0 0 4px; font-size: .9rem; }
.crumbs a { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.filters .grow, .grow { flex: 1 1 220px; }
input[type=search] { font: inherit; padding: 10px 12px; border: 1px solid #c9d1db; border-radius: 8px; background: #fff; min-height: 44px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; }
input.short { width: auto; flex: 0 1 190px; min-width: 120px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.two-col .card { margin-bottom: 16px; }
h2.first { margin-top: 0; }
.facts { margin: 0; display: grid; gap: 8px; }
.facts div { display: grid; grid-template-columns: 150px 1fr; gap: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.strong { font-weight: 600; }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: .88rem; }
.btn.wa { background: #e7f6ec; border-color: #b9e2c6; color: #146c34; }
button.link.danger, .danger { color: var(--err); }
.badge-err { background: var(--err-bg); color: var(--err); }
.table-wrap.flat { border: 0; }
.errors { margin: 0; padding-left: 18px; }
.history { margin: 10px 0 0; padding-left: 18px; }
select[size] { min-height: 150px; }
.notice { display: flex; flex-direction: column; gap: 6px; }
.notice p { margin: 0; }
.notice details summary { cursor: pointer; color: var(--brand); }
.renewal-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.due { display: flex; flex-direction: column; align-items: flex-end; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
@media (max-width: 560px) {
    .facts div { grid-template-columns: 1fr; gap: 0; }
    .due { align-items: flex-start; }
}
.notice > .badge { align-self: flex-start; }
.row input[type=date], .row input[type=file], .row select { width: auto; }
.nav { flex-wrap: nowrap; white-space: nowrap; }
@media (max-width: 720px) {
    .topbar-inner { row-gap: 0; padding-top: 8px; }
    .nav { order: 3; flex: 1 1 100%; overflow-x: auto; gap: 18px; padding-bottom: 6px; }
}

/* ---------- Step 4 screens ---------- */
.add-box summary, .add-inline summary, .inline-edit summary { cursor: pointer; }
.add-box[open] summary { margin-bottom: 12px; }
.add-inline { margin-top: 12px; }
.add-inline[open] form { margin-top: 10px; }
.link-like { color: var(--brand); }
td.actions { width: 1%; text-align: right; }
td.wrap { white-space: normal; max-width: 260px; }
.inline-edit { position: relative; }
.inline-edit .popover { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; text-align: left; white-space: normal; padding: 12px; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; min-width: 280px; }
.sharing { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0; }
.sharing legend { padding: 0 4px; color: var(--muted); }
.share-list { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.sharing .muted { margin: 4px 0 0; }
tr.dim td { color: var(--muted); }
.btn.danger-outline { color: var(--err); border-color: #e7b9b4; }
.broker .page-head { align-items: flex-start; margin-bottom: 4px; }
.broker h2 .badge { vertical-align: middle; margin-left: 6px; }
.statement { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.field[hidden], [hidden] { display: none !important; }
@media (max-width: 1240px) { .me-name { display: none; } }
.inline-edit .popover { position: absolute; right: 0; top: 100%; z-index: 20; box-shadow: 0 8px 24px rgba(28, 36, 48, .14); background: #fff; }
.table-wrap.flat { overflow: visible; }
@media (max-width: 720px) { .table-wrap.flat { overflow-x: auto; } .inline-edit .popover { position: static; box-shadow: none; } }

/* ---------- Step 5 ---------- */
.help { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.results, .table-wrap.flat.results { max-height: 480px; overflow: auto; margin-bottom: 12px; }
.results thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.policy-card .page-head { align-items: flex-start; }
.policy-card .statement { margin: 12px 0; }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.warn a { color: var(--warn); }
.match { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 8px; }
.match-side { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.match-side p { margin: 0 0 4px; }

/* ---------- Statements ---------- */
.statement-doc h1 { margin: 2px 0; }
.period { margin: 6px 0 14px; }
table.soa tr.opening td, table.soa tfoot td { background: #f8fafc; font-weight: 600; }
table.soa tr.closing td { border-top: 2px solid var(--ink); font-weight: 700; }
.right { text-align: right; }
.right p { margin: 0; }
@media print {
    @page { margin: 14mm; }
    body { background: #fff; font-size: 11pt; }
    .topbar, .no-print, .flash, .crumbs { display: none !important; }
    main.wrap { padding: 0; max-width: none; }
    .card { border: 0; padding: 0; }
    .table-wrap { border: 0; overflow: visible; }
    th, td { padding: 5px 6px; }
    td.wrap { white-space: normal; }
}
.chip { display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); text-decoration: none; font-size: .92rem; min-height: 36px; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Reported payments ---------- */
.notices { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.pay-box { margin: 10px 0; }
.pay-box > summary { list-style: none; display: inline-flex; }
.pay-box > summary::-webkit-details-marker { display: none; }
.pay-box[open] > summary { margin-bottom: 10px; }
.pay-to { background: var(--brand-tint); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.pay-to p { margin: 0 0 4px; }
.card.attention { border-color: #f0d9a8; background: #fffaf0; }
.inline-reject > summary { list-style: none; }
.inline-reject > summary::-webkit-details-marker { display: none; }
.inline-reject[open] form { margin-top: 8px; }
.me a { color: var(--ink-soft); }
.banks { margin: 0 0 6px; padding-left: 18px; display: grid; gap: 4px; }
input:disabled, select:disabled, textarea:disabled { background: #eef1f5; color: var(--muted); cursor: not-allowed; }

/* File pickers: "Choose file" looks like the other buttons. */
input[type=file] { font: inherit; font-size: .92rem; color: var(--ink-soft); max-width: 100%; }
input[type=file]::file-selector-button {
    font: inherit; font-weight: 600; font-size: .92rem; color: var(--ink); background: #fff; border: 1px solid var(--line);
    border-radius: 8px; padding: 8px 16px; min-height: 40px; margin-right: 12px; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--bg); }

/* Messages shown over the page after saving, when the page keeps its place. */
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 50; width: min(720px, calc(100% - 32px)); display: grid; gap: 8px; }
.toasts .flash { margin: 0; padding-right: 40px; position: relative; box-shadow: 0 6px 20px rgba(20, 30, 45, .18); }
.toast-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; padding: 4px; }

/* Every button: the same blue button with white writing. */
.btn, .btn.primary, .btn.wa, .btn.danger-outline,
input[type=file]::file-selector-button {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn:hover, .btn.primary:hover, .btn.wa:hover, .btn.danger-outline:hover,
input[type=file]::file-selector-button:hover {
    background: var(--brand-dark); border-color: var(--brand-dark); color: #fff;
}
.btn:disabled, .btn[disabled] { background: #9ca3af; border-color: #9ca3af; color: #fff; cursor: not-allowed; }

/* Everything clickable shows the hand cursor, and text links all react the same way on hover:
   underlined, in the darker link colour (red links stay red). */
summary, label.check, .check input, select, input[type=date]::-webkit-calendar-picker-indicator, a, button { cursor: pointer; }
a:not(.btn):not(.brand), button.link, summary:not(.btn), .crumbs a { text-decoration: none; transition: color .12s; }
a:not(.btn):not(.brand):hover, button.link:hover, summary:not(.btn):hover, .crumbs a:hover { color: var(--brand-dark); text-decoration: underline; text-underline-offset: 3px; }
button.link.danger:hover, a.danger:hover { color: var(--err); }
.nav a:not(.btn):not(.brand), .nav a:not(.btn):not(.brand):hover { text-decoration: none; }
.brand:hover { text-decoration: none; color: var(--ink); }

/* Renewal form: fields side by side, aligned at the bottom, at their normal height. */
.renewal-form .row { align-items: flex-end; flex-wrap: wrap; }
.renewal-form .field { flex: 0 1 220px; margin: 0; }
.renewal-form .field input, .renewal-form .field select { height: 44px; flex: 0 0 auto; width: 100%; min-width: 0; }
.renewal-form .field strong { display: block; padding: 10px 0; }

/* Cancel sits next to its Save button. */
[data-cancel] { margin-left: 8px; }
.row > [data-cancel] { margin-left: 0; }

/* The top menu stays at the top of the screen when scrolling. */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--card); box-shadow: 0 1px 0 var(--line); }
/* Jumping to a section (#insurers) keeps its heading below the fixed menu. */
main [id] { scroll-margin-top: 120px; }
/* A locked setting looks greyed out until Edit is pressed. */
input[readonly] { background: var(--bg); color: var(--muted); cursor: default; }
/* Wide tables scroll left and right: the scroll bar always shows (Mac hides it otherwise),
   and the ‹ › buttons above the table scroll it for those without a trackpad. */
.table-wrap::-webkit-scrollbar { height: 12px; }
.table-wrap::-webkit-scrollbar-track { background: #eef1f5; border-radius: 0 0 var(--radius) var(--radius); }
.table-wrap::-webkit-scrollbar-thumb { background: #b6c0cc; border-radius: 6px; border: 2px solid #eef1f5; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #8d99a8; }
@supports (-moz-appearance: none) { .table-wrap { scrollbar-color: #b6c0cc #eef1f5; } }
.table-scroll { display: flex; justify-content: flex-end; gap: 6px; margin: 0 0 6px; }
.table-scroll[hidden] { display: none; }
.table-scroll button { width: 34px; height: 30px; padding: 0; font-size: 1.1rem; line-height: 1; }
.table-scroll button:disabled { opacity: .35; cursor: default; }
@media print { .table-scroll { display: none !important; } }
/* Settings → Arabic dictionary: the English and Arabic boxes side by side. */
.dict-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dict-add input { flex: 1 1 220px; width: auto; max-width: 360px; }
.dict-more { margin: 4px 0 12px; }
.dict-more > form, .dict-more > p { margin-top: 10px; }
/* "Import from Excel" opens like a button; the word list scrolls inside its own box. */
.dict-more > summary { list-style: none; display: inline-flex; }
.dict-more > summary::-webkit-details-marker { display: none; }
.dict-list { max-height: 420px; overflow-y: auto; }
.dict-list thead th { position: sticky; top: 0; z-index: 1; background: var(--card); box-shadow: 0 1px 0 var(--line); }
/* Long lists in Settings scroll inside their own box. */
.scroll-box { max-height: 480px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px 8px; }
.scroll-box h3 { margin-top: 18px; }
.scroll-box h3.first { margin-top: 12px; }
/* In a scrolling box, Edit opens under the row instead of floating (so it is never cut off). */
.scroll-box .inline-edit .popover, .dict-list .inline-edit .popover { position: static; box-shadow: none; }
.check-inline { display: inline-flex; align-items: center; gap: .3em; white-space: nowrap; }
