/*
 * Client Portal styles. Plain CSS, self-hosted, no frameworks (D-22).
 * Brand colors from NeverBlue IT's guide. White text on the brand orange is
 * only 3:1, so buttons and links use rust red (5.2:1) and orange carries the
 * brand bar, accents and highlights. Body text is the brand grey (7:1).
 */

:root {
    --orange: #f76b17;
    --grey: #635461;
    --yellow: #ffc957;
    --rust: #bf412c;
    --rust-dark: #9c3423;
    --ink: #3d333c;
    --muted: #6e636c;
    --line: #e4dfe3;
    --page: #f7f5f6;
    --card: #ffffff;
    --error-bg: #fbeae7;
    --info-bg: #fff6e0;
    --ok-bg: #eaf5ec;
    --ok: #2e6b3a;
    --radius: 8px;
    --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
}

/* Brand stripe across the top of every page */
body::before {
    content: "";
    display: block;
    height: 6px;
    background: linear-gradient(90deg, var(--yellow) 0%, var(--orange) 55%, var(--rust) 100%);
}

h1,
h2,
h3 {
    color: var(--grey);
    line-height: 1.25;
    margin: 0 0 0.5rem;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.2rem;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--rust);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--rust-dark);
}

:focus-visible {
    outline: 3px solid var(--rust);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Signed-out pages: one centered card ---------- */

.auth-main {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2.5rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 26rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(61, 51, 60, 0.06);
    padding: 2rem 1.75rem;
}

.auth-card.wide {
    max-width: 34rem;
}

.auth-logo {
    display: block;
    width: 180px;
    height: auto;
    margin: 0 auto 1.5rem;
}

.auth-card h1 {
    text-align: center;
}

.auth-card .lead {
    text-align: center;
    color: var(--muted);
}

.auth-alt {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.95rem;
}

/* ---------- Signed-in pages ---------- */

.app-header {
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.app-header-inner {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.5rem;
}

.app-logo {
    display: block;
    width: 110px;
    height: auto;
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    flex: 1;
}

.app-nav a {
    color: var(--grey);
    text-decoration: none;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border-bottom: 3px solid transparent;
}

.app-nav a:hover {
    background: var(--page);
}

.app-nav a[aria-current="page"] {
    border-bottom-color: var(--orange);
    border-radius: 6px 6px 0 0;
}

.app-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.app-user strong {
    display: block;
    color: var(--ink);
}

.app-user form {
    margin: 0;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.page-title {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--yellow);
}

.page-title h1 {
    margin: 0;
}

.page-title .sub {
    color: var(--muted);
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
}

.tile,
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.tile {
    border-top: 4px solid var(--orange);
}

.tile p {
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.panel + .panel {
    margin-top: 1.25rem;
}

.panel h2 {
    margin-bottom: 0.25rem;
}

.panel .lead {
    color: var(--muted);
}

/* ---------- Forms ---------- */

.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.field .hint {
    display: block;
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 0.3rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    font: inherit;
    color: var(--ink);
    padding: 0.6rem 0.75rem;
    border: 1px solid #b9b0b7;
    border-radius: 6px;
    background: #fff;
}

input:focus-visible {
    outline: 3px solid var(--rust);
    outline-offset: 0;
    border-color: var(--rust);
}

input[aria-invalid="true"] {
    border-color: var(--rust);
    background: var(--error-bg);
}

input.code {
    font-family: var(--mono);
    font-size: 1.5rem;
    letter-spacing: 0.4em;
    text-align: center;
}

.check {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    margin-bottom: 1.1rem;
}

.check input {
    margin-top: 0.3rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--rust);
}

.form-narrow {
    max-width: 24rem;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    padding: 0.65rem 1.25rem;
    border-radius: 6px;
    border: 2px solid var(--rust);
    background: var(--rust);
    color: #fff;
    cursor: pointer;
}

.btn:hover {
    background: var(--rust-dark);
    border-color: var(--rust-dark);
    color: #fff;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-secondary {
    background: #fff;
    color: var(--grey);
    border-color: #b9b0b7;
}

.btn-secondary:hover {
    background: var(--page);
    color: var(--ink);
    border-color: var(--grey);
}

.btn-small {
    padding: 0.35rem 0.8rem;
    font-size: 0.875rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

/* ---------- Messages ---------- */

.alert {
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    border-left: 4px solid;
}

.alert p:last-child {
    margin-bottom: 0;
}

.alert-error {
    background: var(--error-bg);
    border-color: var(--rust);
}

.alert-info {
    background: var(--info-bg);
    border-color: var(--yellow);
}

.alert-ok {
    background: var(--ok-bg);
    border-color: var(--ok);
}

/* ---------- Set-up steps ---------- */

.steps {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    font-size: 0.85rem;
    counter-reset: step;
}

.steps li {
    flex: 1;
    text-align: center;
    color: var(--muted);
    padding-top: 0.5rem;
    border-top: 4px solid var(--line);
    counter-increment: step;
}

.steps li::before {
    content: counter(step) ". ";
}

.steps li.done {
    border-top-color: var(--yellow);
}

.steps li[aria-current="step"] {
    border-top-color: var(--orange);
    color: var(--ink);
    font-weight: 600;
}

/* ---------- Authenticator and recovery codes ---------- */

.qr {
    display: block;
    width: 200px;
    height: 200px;
    margin: 0 auto 1rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.qr svg {
    display: block;
    width: 100%;
    height: 100%;
}

.secret {
    font-family: var(--mono);
    font-size: 1rem;
    word-spacing: 0.3em;
    background: var(--page);
    border: 1px dashed #b9b0b7;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    text-align: center;
    overflow-wrap: anywhere;
}

.codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 1rem;
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 1rem;
    background: var(--page);
    border: 1px dashed #b9b0b7;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 1.05rem;
    text-align: center;
}

details {
    margin-bottom: 1rem;
}

summary {
    cursor: pointer;
    color: var(--rust);
}

/* ---------- Quotes (docs/plans/QUOTE_PLAN.md) ---------- */

.app-header-note {
    margin: 0 0 0 auto;
    font-size: 0.9rem;
    color: var(--muted);
}

.back {
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.quote-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 5px solid var(--orange);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.quote-bar.approved {
    border-left-color: var(--ok);
}

.quote-bar p {
    margin: 0;
}

.quote-bar-state {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--grey);
}

.quote-bar-sub {
    color: var(--muted);
}

.quote-bar-sub strong {
    color: var(--ink);
}

/* The quotation itself: view, print, PDF and admin pages */
.quote-doc {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.quote-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1.75rem;
}

.quote-from img {
    display: block;
    width: 150px;
    height: auto;
    margin-bottom: 0.6rem;
}

.quote-from p,
.quote-parties p {
    margin: 0;
}

.quote-title {
    margin: 0;
    padding-top: 1.25rem;
    text-align: center;
    font-style: italic;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.12em;
    color: var(--grey);
}

.quote-meta {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end;
    gap: 0.15rem 0.75rem;
    margin: 0;
    padding-top: 1.25rem;
    font-weight: 600;
}

.quote-meta dt {
    text-align: right;
}

.quote-meta dd {
    margin: 0;
    text-align: right;
}

.quote-parties {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.quote-parties h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.quote-parties .quote-delivery {
    margin-top: 0.75rem;
}

.quote-intro {
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.quote-lines,
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.quote-lines th,
.data-table th {
    text-align: left;
    font-size: 0.85rem;
    color: var(--grey);
    border-bottom: 2px solid var(--grey);
    padding: 0.5rem;
}

.quote-lines td,
.data-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.quote-lines .num,
.data-table .num {
    text-align: right;
    white-space: nowrap;
}

.quote-lines .qty {
    text-align: center;
    white-space: nowrap;
}

.quote-lines tfoot th,
.quote-lines tfoot td {
    border: 0;
    padding: 0.3rem 0.5rem;
    text-align: right;
    font-size: 0.95rem;
    color: var(--ink);
}

.quote-lines tfoot th {
    font-weight: 600;
}

.quote-lines tfoot tr.total th,
.quote-lines tfoot tr.total td {
    border-top: 2px solid var(--grey);
    font-size: 1.05rem;
    font-weight: 700;
}

.quote-notes {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    font-size: 0.9rem;
}

.quote-notes p {
    margin-bottom: 0.5rem;
}

.quote-cards {
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
    background: var(--page);
    border-radius: 4px;
    padding: 0.4rem;
}

.quote-signoff {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.5rem 2rem;
    margin-top: 1.5rem;
}

.quote-agreed {
    grid-column: 1 / -1;
    margin: 0;
    font-style: italic;
}

.quote-signoff .sig {
    display: block;
    min-height: 1.75rem;
    padding: 1rem 0 0.15rem;
    border-bottom: 1px solid var(--ink);
    text-align: center;
    font-weight: 600;
}

.quote-signoff .sig-label {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.quote-approve .code {
    max-width: 14rem;
}

.panel-flush {
    padding: 0;
}

.badge {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--info-bg);
    color: var(--ink);
    border: 1px solid var(--yellow);
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok);
    border-color: var(--ok);
}

.badge-expired {
    background: var(--error-bg);
    color: var(--rust-dark);
    border-color: var(--rust);
}

.pager {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 0 0;
}

.table-foot {
    font-size: 0.875rem;
    color: var(--muted);
}

.badge-closed {
    background: var(--page);
    color: var(--muted);
    border-color: var(--muted);
}

/* ---------- Tickets and activity (docs/mockups/tickets-*.html, activity.html) ---------- */

/* Filters are plain GET links, so they work without JavaScript */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 2rem;
    margin-bottom: 1rem;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.filter-tabs .filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-right: 0.25rem;
}

.filter-tabs a {
    padding: 0.25rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--grey);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.filter-tabs a:hover {
    background: var(--page);
}

.filter-tabs a[aria-current="true"] {
    background: var(--grey);
    border-color: var(--grey);
    color: #fff;
}

.ticket-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.ticket-head p {
    margin: 0;
}

.thread {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
}

.message {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.message + .message {
    margin-top: 1rem;
}

/* Replies from NeverBlue */
.message.from-staff {
    border-left-color: var(--orange);
}

.message-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    color: var(--muted);
}

.message-head strong {
    color: var(--ink);
}

/* Plain text from the Portal API: keep its line breaks, wrap long words */
.message-body {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-note {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    font-style: italic;
    color: var(--muted);
}

.data-table .when {
    white-space: nowrap;
}

.summary {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1rem;
    margin: 0 0 1.25rem;
}

.summary dt {
    font-weight: 600;
    color: var(--grey);
}

.summary dd {
    margin: 0;
}

.form-narrow-panel {
    max-width: 36rem;
}

.email-preview {
    max-width: 40rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.95rem;
}

/* Print layout (/quote/print) and the PDF page for Portal's worker: US Letter */
.print-page {
    background: #fff;
}

.print-main {
    width: 100%;
    max-width: 8.5in;
    margin: 0 auto;
    padding: 1rem;
}

.print-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin-bottom: 1rem;
}

.print-toolbar p {
    margin: 0;
    color: var(--muted);
}

.print-page .quote-doc {
    border: 0;
    padding: 0.25in;
}

@media (max-width: 40rem) {
    .quote-doc {
        padding: 1.25rem;
    }

    .quote-head,
    .quote-parties,
    .quote-signoff {
        grid-template-columns: 1fr;
    }

    .quote-title,
    .quote-meta dt,
    .quote-meta dd {
        text-align: left;
    }

    .quote-title {
        padding-top: 0;
    }

    .quote-meta {
        justify-content: start;
        padding-top: 0;
    }

    .app-header-note {
        margin-left: 0;
    }
}

/* ---------- Footer ---------- */

.site-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    padding: 1.5rem 1rem 2rem;
}

.site-footer a {
    color: var(--muted);
}

@media (max-width: 30rem) {
    .auth-card {
        padding: 1.5rem 1.1rem;
    }

    .app-user {
        width: 100%;
        justify-content: space-between;
    }
}

@page {
    size: letter;
    margin: 0.5in;
}

@media print {
    body::before,
    .app-header,
    .site-footer,
    .actions,
    .quote-bar,
    .quote-approve,
    #delegate,
    .print-toolbar,
    .back,
    .alert {
        display: none;
    }

    body {
        background: #fff;
    }

    .app-main,
    .print-main {
        max-width: none;
        padding: 0;
    }

    .quote-doc {
        border: 0;
        padding: 0;
        margin: 0;
        font-size: 10.5pt;
    }

    .quote-lines tr {
        break-inside: avoid;
    }

    .quote-doc a {
        color: inherit;
        text-decoration: none;
    }
}
