/* ── Theme tokens (see SIMPLICITY_BRAND.md) ── */
:root {
    color-scheme: light;
    /* brand palette */
    --brand-blue: #1babe2;
    --brand-orange: #ed8f12;
    --brand-teal: #2cb4aa;
    --brand-steel: #287899;
    --brand-purple: #a32482;
    --brand-navy: #18212a;
    --brand-charcoal: #424142;
    --brand-light: #ededed;
    --brand-blue-text: #0f7ea9;
    --gradient-bar: linear-gradient(90deg, #1babe2 0%, #2cb4aa 30%, #ed8f12 65%, #a32482 100%);
    --font-sans: "azo-sans-web", "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
    --tracking-title: 0.15em;
    --tracking-label: 0.15em;
    --tracking-button: 0.08em;
    --ease: 0.2s ease-out;

    --bg: #f6f6f6;
    --surface: #fff;
    --hover: #ededed;
    --row-hover: #f6f6f6;
    --border: #ededed;
    --border-strong: #d6d6d6;
    --border-subtle: #ededed;
    --text: #424142;
    --text-heading: #18212a;
    --text-muted: #6b6b6b;
    --text-faint: #6b6b6b;
    --text-subtle: #6b6b6b;
    --accent: #287899;
    --accent-hover: #18212a;
    --accent-contrast: #fff;
    --accent-text: #0f7ea9;
    --jumbo-bg: #287899;
    --up: #3b6d11;
    --up-bg: #eaf3de;
    --down: #a32d2d;
    --down-bg: #fcebeb;
    --flat-bg: #ededed;
    --shadow: rgba(24, 33, 42, 0.12);
}

/* dark: follows the system unless the toggle has picked light */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #18212a;
        --surface: #212c37;
        --hover: #2e3a46;
        --row-hover: #2e3a46;
        --border: #2e3a46;
        --border-strong: #3a4754;
        --border-subtle: #2e3a46;
        --text: #ededed;
        --text-heading: #fff;
        --text-muted: #a9b1ba;
        --text-faint: #a9b1ba;
        --text-subtle: #a9b1ba;
        --accent: #1babe2;
        --accent-hover: #6cc8ec;
        --accent-contrast: #18212a;
        --accent-text: #1babe2;
        --up: #8cc265;
        --up-bg: #24331a;
        --down: #e57d7d;
        --down-bg: #3a1f1f;
        --flat-bg: #2e3a46;
        --shadow: rgba(0, 0, 0, 0.5);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #18212a;
    --surface: #212c37;
    --hover: #2e3a46;
    --row-hover: #2e3a46;
    --border: #2e3a46;
    --border-strong: #3a4754;
    --border-subtle: #2e3a46;
    --text: #ededed;
    --text-heading: #fff;
    --text-muted: #a9b1ba;
    --text-faint: #a9b1ba;
    --text-subtle: #a9b1ba;
    --accent: #1babe2;
    --accent-hover: #6cc8ec;
    --accent-contrast: #18212a;
    --accent-text: #1babe2;
    --up: #8cc265;
    --up-bg: #24331a;
    --down: #e57d7d;
    --down-bg: #3a1f1f;
    --flat-bg: #2e3a46;
    --shadow: rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    background: var(--surface);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-brand {
    display: flex;
}

/* supplied brand artwork: never recolour or stretch, only scale by height */
.logo-brand img {
    height: 36px;
    width: auto;
}

.logo-dark {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .logo-light {
        display: none;
    }

    :root:not([data-theme="light"]) .logo-dark {
        display: block;
    }
}

:root[data-theme="dark"] .logo-light {
    display: none;
}

:root[data-theme="dark"] .logo-dark {
    display: block;
}

/* divider keeps clear space between the Simplicity logo and the product name */
.logo-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-heading);
    border-left: 1px solid var(--border-strong);
    padding-left: 14px;
    margin-left: 6px;
}

.logo-name span {
    color: var(--accent-text);
}

.contact-btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-button);
    background: none;
    border: 2px solid var(--accent-text);
    border-radius: 4px;
    padding: 6px 16px;
    cursor: pointer;
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background var(--ease);
}

.contact-btn:hover {
    background: var(--hover);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border-strong);
    border-radius: 4px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-heading);
    transition: background var(--ease);
}

.theme-toggle:hover {
    background: var(--hover);
}

/* ── Dialog ── */
dialog {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    width: calc(100% - 3rem);
    max-width: 480px;
    background: var(--surface);
    box-shadow: 0 8px 32px var(--shadow);
    margin: auto; /* centres it — browsers can be inconsistent here */
    position: fixed; /* ensures it sits relative to the viewport */
    inset: 0;
    height: fit-content;
}

dialog .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

dialog .form-row input,
dialog textarea {
    width: 100%;
    font-family: inherit;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

dialog .form-row input:focus,
dialog textarea:focus {
    outline: 2px solid var(--brand-blue);
    outline-offset: 0;
}

dialog textarea {
    margin-bottom: 8px;
    resize: vertical;
    min-height: 72px;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.dialog-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-heading);
}

.dialog-close {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-faint);
    transition:
        background var(--ease),
        color var(--ease);
}

.dialog-close:hover {
    background: var(--hover);
    color: var(--text);
}

.send-btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-button);
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    background: var(--accent);
    color: var(--accent-contrast);
    cursor: pointer;
    transition: background var(--ease);
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.form-status {
    font-size: 12px;
    color: var(--down);
    margin-bottom: 8px;
}

.form-status:empty {
    display: none;
}

/* honeypot field */
.hp {
    position: absolute;
    left: -9999px;
}

/* ── History Dialog ── */
#historyDialog {
    width: calc(100% - 3rem);
    max-width: 560px;
    max-height: calc(100vh - 3rem);
}

/* only header stays put; table body scrolls */
#historyDialog[open] {
    display: flex;
    flex-direction: column;
}

#historyDialog .table-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

#historyDialog table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 1.25rem;
}

#historyDialog thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--accent-text);
    padding: 0 10px 10px 10px;
    position: sticky;
    top: 0;
    background: var(--surface);
    /* border-bottom doesn't stick with border-collapse, so use a shadow */
    box-shadow: inset 0 -1px 0 var(--border);
}

#historyDialog tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--ease);
}

#historyDialog tbody tr:last-child {
    border-bottom: none;
}

#historyDialog tbody tr:hover {
    background: var(--row-hover);
}

#historyDialog tbody td {
    padding: 9px 10px;
    color: var(--text);
}

#historyDialog tbody td:nth-child(3) {
    font-weight: 500;
}

/* reuse your existing tile-change colours for the change column */
#historyDialog tbody td.up {
    color: var(--up);
    font-weight: 500;
}

#historyDialog tbody td.down {
    color: var(--down);
    font-weight: 500;
}

#historyDialog tbody td.flat {
    color: var(--text-faint);
}

/* ── Jumbotron ── */
.jumbotron {
    background-color: var(--jumbo-bg);
    /* dot-grid texture from the brand graphic language */
    background-image: radial-gradient(rgba(255, 255, 255, 0.15) 1.5px, transparent 1.5px);
    background-size: 16px 16px;
    color: #fff;
    padding: 3rem 0;
}

.jumbotron-title {
    font-size: 28px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-title);
    margin-bottom: 0.75rem;
}

.jumbotron-text {
    font-size: 16px;
    font-weight: 300;
    line-height: 1.6;
    max-width: 960px;
}

/* ── Main content ── */
main {
    flex: 1;
    padding: 1.5rem 0;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.25rem;
}

.search-wrap {
    position: relative;
    flex: 1;
    max-width: 340px;
}

.search-wrap input {
    width: 100%;
    padding: 8px 10px 8px 10px;
    font-family: inherit;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

.search-wrap input:focus {
    outline: 2px solid var(--brand-blue);
    outline-offset: 0;
}

.count {
    font-size: 13px;
    color: var(--text-faint);
}

/* ── Content container ── */
.container {
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.5rem;
}

/* ── Sector grid ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--brand-blue);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tile-sector {
    font-size: 12px;
    color: var(--accent-text);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-button);
}

.tile-margin {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1;
}

.tile-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 4px;
    width: fit-content;
}

.tile-change svg {
    width: 13px;
    height: 13px;
}

.tile-change.up {
    background: var(--up-bg);
    color: var(--up);
}

.tile-change.up svg {
    stroke: var(--up);
}

.tile-change.down {
    background: var(--down-bg);
    color: var(--down);
}

.tile-change.down svg {
    stroke: var(--down);
}

.tile-change.flat {
    background: var(--flat-bg);
    color: var(--text-muted);
}

.tile-change.flat svg {
    stroke: var(--text-muted);
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-faint);
    font-size: 14px;
}

/* ── Privacy policy ── */
.policy {
    max-width: 960px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--brand-blue);
    border-radius: 8px;
    padding: 24px;
    line-height: 1.6;
}

.policy > * + * {
    margin-top: 16px;
}

.policy h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--accent-text);
    /* keeps contents-list targets clear of the sticky header */
    scroll-margin-top: 88px;
}

.policy > * + h2 {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.policy h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-heading);
}

.policy > * + h3 {
    margin-top: 24px;
}

.policy > h2 + *,
.policy > h3 + * {
    margin-top: 8px;
}

.policy ul {
    padding-left: 1.5em;
}

.policy li + li,
.policy li > ul {
    margin-top: 8px;
}

.policy a {
    color: var(--accent-text);
    overflow-wrap: anywhere;
}

.policy address {
    font-style: normal;
}

.policy-transfer dt {
    font-weight: 700;
    color: var(--text-heading);
}

.policy-transfer dd + dt {
    margin-top: 8px;
}

.policy strong {
    color: var(--text-heading);
}

.policy-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: var(--accent-text);
    text-decoration: none;
}

.policy-back:hover {
    text-decoration: underline;
}

/* ── Footer ── */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

footer span {
    font-size: 11px;
    color: var(--text-subtle);
}

footer strong {
    font-weight: 700;
    color: var(--text-muted);
}

footer a {
    color: inherit;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ── Brand gradient bar ── */
.brand-bar {
    height: 6px;
    background: var(--gradient-bar);
}

/* keeps the bar attached to the sticky header */
header + .brand-bar {
    position: sticky;
    top: 60px;
    z-index: 100;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    /* the logo needs the room on phones; the hero names the product */
    .logo-name,
    .contact-label {
        display: none;
    }

    .contact-btn {
        padding: 6px 10px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
