/* The portal's look: clean, modern and quiet. One blue accent on cool neutrals,
   generous spacing, soft shadows and rounded corners. The colours are the ones
   the portal started with; everything else is built from the tokens below, so
   a brand change is a change here and nowhere else.

   No web fonts: the system UI font (Segoe UI Variable, San Francisco, Roboto)
   is already a modern sans on every device, loads instantly, and sends nobody's
   browser to a third party.

   Phone rules live at the END of this file, in the max-width block. They are
   last deliberately: an override of the same specificity loses to whatever
   comes after it, so a mobile block halfway up stops applying the moment
   someone adds a rule below it. */

:root {
    --bg:            #f4f5f7;
    --surface:       #ffffff;
    --surface-2:     #f8f9fb;
    --border:        #e3e5e9;
    --border-strong: #d3d7de;
    --text:          #16181d;
    --text-muted:    #5c6370;
    --accent:        #1f4ed8;
    --accent-strong: #1740b4;
    --accent-fg:     #ffffff;
    --accent-soft:   #eef2fd;
    --accent-ring:   rgba(31, 78, 216, 0.18);

    --ok-bg:   #ecf8f0;  --ok-border:   #c3e6cf;  --ok-text:   #17602f;
    --err-bg:  #fdf0f0;  --err-border:  #f3c9c9;  --err-text:  #8a1f1f;
    --warn-bg: #fff5e3;  --warn-border: #f1d6a0;  --warn-text: #7a4d00;

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 18px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow:    0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.09);

    --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;

    --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1200px 420px at 50% -160px, rgba(31, 78, 216, 0.08), transparent 70%),
        var(--bg);
    background-repeat: no-repeat;
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

::selection { background: var(--accent-ring); }

/* ---- Header ------------------------------------------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 64px;
    padding: 0.75rem max(1.5rem, calc((100vw - 64rem) / 2));
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(227, 229, 233, 0.9);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
}

.home-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.home-link:hover { color: inherit; }

.mark {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(140deg, #3b6cf0 0%, var(--accent) 55%, var(--accent-strong) 100%);
    box-shadow: 0 2px 6px rgba(31, 78, 216, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.site-name {
    font-family: var(--font-display);
    font-weight: 650;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    font-size: 0.9rem;
}

.header-user .who {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-user form { margin: 0; }

/* ---- Layout ------------------------------------------------------------ */

.content {
    flex: 1;
    width: 100%;
    max-width: 36rem;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

.content-wide { max-width: 56rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
}

.muted-card {
    background: var(--surface-2);
    border-color: var(--border);
    box-shadow: none;
}

.muted-card p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.muted-card h2 { margin-bottom: 0.5rem; }

.is-disabled { opacity: 0.62; }

.site-footer {
    padding: 1.25rem max(1.5rem, calc((100vw - 64rem) / 2));
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---- Type -------------------------------------------------------------- */

h1, h2 { font-family: var(--font-display); letter-spacing: -0.02em; }

h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    margin: 0 0 0.6rem;
    font-size: 1.1rem;
    font-weight: 650;
    line-height: 1.3;
}

.lead { margin: 0 0 1.5rem; color: var(--text-muted); font-size: 1rem; }
.note { margin: 1.1rem 0 0; color: var(--text-muted); font-size: 0.875rem; }
.note.top { margin: -0.25rem 0 1.1rem; }

.addr { overflow-wrap: anywhere; }

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.optional {
    margin-left: 0.3rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-style: normal;
    font-weight: 400;
}

/* ---- Buttons ----------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 46px;
    padding: 0 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.005em;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
    box-shadow: 0 1px 2px rgba(23, 64, 180, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover { background: var(--accent-strong); color: var(--accent-fg); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover { background: var(--surface-2); border-color: #c2c7d0; color: var(--text); }

.btn-small {
    min-height: 36px;
    padding: 0 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.btn:focus-visible,
.admin-nav a:focus-visible,
details summary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--accent-ring);
}

.button-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0; }

/* The one main action of a short form spans it. */
.btn-block { width: 100%; min-height: 50px; font-size: 1rem; }

/* ---- Forms ------------------------------------------------------------- */

.field { display: block; min-width: 0; margin-bottom: 1.1rem; }

.field > span,
fieldset.field legend {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
}

input[type="email"],
input[type="text"],
input[type="password"],
input[type="tel"],
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 0 0.9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

textarea { padding: 0.7rem 0.9rem; resize: vertical; line-height: 1.45; }

select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235c6370' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.95rem center;
}

input::placeholder, textarea::placeholder { color: #9aa1ad; }

input:hover, select:hover, textarea:hover { border-color: #c2c7d0; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}

input[readonly] { background: var(--surface-2); }
select:disabled { color: var(--text-muted); background-color: var(--surface-2); }

.check {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 36px;
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.check input,
.choice input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--accent);
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

fieldset.field { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
fieldset.field legend { padding: 0; }

/* The product: two big tappable choices. */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }

.choice {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 54px;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.choice:hover { border-color: #c2c7d0; }

.choice:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-ring);
    font-weight: 600;
}

/* ---- Alerts ------------------------------------------------------------ */

.alert {
    margin: 0 0 1.1rem;
    padding: 0.8rem 1rem;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: 0.925rem;
    line-height: 1.45;
}

.alert-error { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.alert-ok    { background: var(--ok-bg);  border-color: var(--ok-border);  color: var(--ok-text); }

/* ---- Admin ------------------------------------------------------------- */

/* Tabs across the admin pages, as a segmented control. */
.admin-nav {
    display: inline-flex;
    gap: 0.25rem;
    max-width: 100%;
    margin-bottom: 1.5rem;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.admin-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 1.1rem;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.admin-nav a:hover { color: var(--text); background: var(--surface-2); }

.admin-nav a[aria-current="page"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 0 0 1px var(--border);
}

.user-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

.user-head h2 { margin: 0; overflow-wrap: anywhere; }

.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }

.email-list { list-style: none; margin: 0 0 1rem; padding: 0; border-top: 1px solid var(--border); }

.email-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.email-list .addr { flex: 1 1 12rem; min-width: 0; font-size: 0.95rem; }
.email-list form { margin: 0; }

.inline-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form .btn { min-height: 46px; }

.user-actions form { margin: 0 0 1rem; }

details { border-top: 1px solid var(--border); padding-top: 0.6rem; margin-top: 0.25rem; }
.card > details:first-child, h1 + .lead + details { border-top: 0; padding-top: 0; }

details summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 40px;
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    list-style: none;
}

details summary::-webkit-details-marker { display: none; }

details summary::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s var(--ease);
    margin: 0 0.15rem 0 0.1rem;
}

details[open] summary::before { transform: rotate(45deg); }

details form { margin-top: 0.9rem; }

.link-card { border-color: rgba(31, 78, 216, 0.45); box-shadow: 0 0 0 4px var(--accent-ring), var(--shadow); }

.facts { display: grid; gap: 0.45rem; margin: 0 0 1.1rem; }
.facts div { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.75rem; }
.facts dt { color: var(--text-muted); font-size: 0.85rem; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.region-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0 1rem;
    margin-bottom: 1rem;
}

/* ---- Quote ------------------------------------------------------------- */

.quote-result {
    position: relative;
    overflow: hidden;
    border-color: rgba(31, 78, 216, 0.3);
    box-shadow: var(--shadow-lg);
}

.quote-result::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #3b6cf0, var(--accent) 50%, var(--accent-strong));
}

.price {
    margin: 0;
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.price-note { margin: 0.35rem 0 1.4rem; color: var(--text-muted); font-size: 0.9rem; }

.terms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 0 0 1.5rem;
}

.terms div {
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.terms dt { color: var(--text-muted); font-size: 0.8rem; font-weight: 500; }
.terms dd { margin: 0.1rem 0 0; font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.coverages {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem 1.25rem;
    margin: 0 0 0.5rem;
    padding: 0;
    list-style: none;
}

.coverages li {
    position: relative;
    padding-left: 1.6rem;
    font-size: 0.95rem;
    line-height: 1.4;
}

.coverages li::before {
    content: "";
    position: absolute;
    left: 0.1rem;
    top: 0.32rem;
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 50%;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='8' viewBox='0 0 10 8'%3E%3Cpath d='M1 4l2.6 2.6L9 1.2' fill='none' stroke='%231f4ed8' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 0.6rem no-repeat,
        var(--accent-soft);
}

/* ---- Rate grids: scroll inside their own box; the page never does. ----- */

.table-wrap {
    overflow-x: auto;
    margin: 0 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}

.rate-grid { border-collapse: collapse; font-variant-numeric: tabular-nums; }

.rate-grid th {
    padding: 0.55rem 0.6rem;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.rate-grid thead th { border-bottom: 1px solid var(--border); }
.rate-grid tbody th { text-align: left; border-right: 1px solid var(--border); }
.rate-grid td { padding: 0.25rem; }

.rate-grid input {
    width: 6.5rem;
    min-height: 40px;
    padding: 0 0.6rem;
    border-radius: var(--radius-sm);
    text-align: right;
    box-shadow: none;
}

.rate-grid .shade-default input { background: #e9f6ec; border-color: #a9dab4; }
.rate-grid .shade-grey input { background: #eceef1; font-style: italic; }

/* ---- Motion: only for people who have not asked for less. -------------- */

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Phones. Must stay at the end of the file - see the note at the top.

   The rules that matter: nothing may push the page sideways, form fields must
   compute to at least 16px or iOS zooms in on focus and does not zoom back out,
   and anything tappable needs to be big enough to tap. */
@media (max-width: 640px) {
    .site-header { min-height: 58px; padding: 0.6rem 1rem; gap: 0.75rem; }
    .header-user .who { display: none; }

    .content { padding: 1.25rem 1rem 2.5rem; }
    .card { padding: 1.35rem 1.15rem; border-radius: var(--radius); margin-bottom: 1rem; }

    .site-footer { padding: 1rem; }

    input, select, textarea, button { font-size: 16px; }

    h1 { font-size: 1.45rem; }

    .btn { width: 100%; min-height: 48px; }

    /* Small buttons sit beside other things, so they stay their own width,
       but grow to a comfortable tap height. */
    .btn-small { width: auto; min-height: 40px; }

    /* Two side by side still fit at 375px, and a full-width pair reads as one. */
    .button-row .btn { width: auto; flex: 1 1 auto; }

    .row, .choices, .coverages { grid-template-columns: 1fr; }

    .admin-nav { display: flex; flex-wrap: wrap; width: 100%; overflow-x: visible; }
    .admin-nav a { flex: 1 1 auto; justify-content: center; padding: 0 0.5rem; font-size: 0.85rem; }

    .price { font-size: 2.5rem; }

    .rate-grid input { width: 5.5rem; }
}
