:root {
    color-scheme: light;
    font-family: var(--dl-font, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
    color: var(--dl-text, #17231e);
    background: var(--dl-background, #f2f6f3);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
/* grid-template-columns: the implicit auto track would size to the widest
   child's max-content (the sticky portal-nav, ~1900px wide) and push every
   workspace page wider than the viewport. minmax(0,100%) pins the track to the
   body width; login panels stay centered via justify-self and workspace items
   stretch (see the :has(main.workspace) rule below). */
html { background: var(--dl-background, #f2f6f3); }
body { color: var(--dl-text, #17231e); background: var(--dl-background, #f2f6f3); min-height: 100vh; margin: 0; padding: calc(1.25rem * var(--dl-space-scale, 1)); display: grid; grid-template-columns: minmax(0, 100%); place-items: center; }
.panel { width: min(100%, 30rem); padding: clamp(1.25rem, 5vw, 2.5rem); background: #fff; border: 1px solid var(--dl-border, #dce7df); border-radius: var(--dl-card-radius, 1rem); box-shadow: var(--dl-shadow-strength, 0 1rem 2.5rem #173d2710); }
.eyebrow { margin: 0 0 .75rem; color: var(--dl-primary, #187447); font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
h1 { margin: 0 0 1.25rem; font-size: clamp(1.7rem, 7vw, 2.3rem); line-height: 1.15; }
p { line-height: 1.6; }
/* Links follow the theme: accent blended with text reads on light and dark surfaces. */
a { color: color-mix(in srgb, var(--dl-primary, #187447) 78%, var(--dl-text, #17231e)); font-weight: 650; }
a:hover { color: var(--dl-accent, #176d43); }
form { display: grid; gap: 1rem; margin-top: 1.5rem; }
label { display: grid; gap: .4rem; font-size: .94rem; font-weight: 650; }
input { width: 100%; min-height: 2.9rem; padding: .7rem .8rem; border: 1px solid var(--dl-border, #afc1b4); border-radius: var(--dl-button-radius, .45rem); font: inherit; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #66b98b; outline-offset: 2px; }
button, .button-link { min-height: 2.9rem; padding: .7rem 1rem; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--dl-button-radius, .45rem); background: var(--dl-primary, #187447); color: var(--dl-surface, #fff); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
button.secondary { background: var(--dl-accent-soft, #e8f1eb); color: var(--dl-text, #174e32); }
.error { padding: .7rem; border-radius: .4rem; background: var(--dl-danger-soft, #fff0ef); color: color-mix(in srgb, #8d241d 82%, var(--dl-text, #17231e)); }
.success { padding: .7rem; border-radius: .4rem; background: color-mix(in srgb, var(--dl-primary, #187447) 13%, var(--dl-surface, #fff)); color: var(--dl-text, #17231e); }
select { width: 100%; min-height: 2.9rem; padding: .7rem .8rem; border: 1px solid var(--dl-border, #afc1b4); border-radius: var(--dl-button-radius, .45rem); background: #fff; font: inherit; }
select:focus-visible { outline: 3px solid #66b98b; outline-offset: 2px; }
.panel-wide { width: min(100%, 55rem); }
.ticket-list { display: grid; gap: .55rem; padding-left: 1.2rem; }
.ticket-list .empty-state { padding: .85rem; border: 1px dashed color-mix(in srgb, var(--dl-border, #b8cdbd) 80%, transparent); border-radius: .55rem; background: color-mix(in srgb, var(--dl-primary, #187447) 4%, var(--dl-surface, #fff)); list-style: none; }
.product-list { display: grid; gap: .8rem; margin-block: 1rem; }
.product-row { padding: 1rem; border: 1px solid var(--dl-border, #dce7df); border-radius: var(--dl-card-radius, .65rem); background: var(--dl-surface, #fff); }
.product-row h2 { margin-top: 0; font-size: 1.1rem; }
.empty-state { border-style: dashed; background: color-mix(in srgb, var(--dl-primary, #187447) 4%, var(--dl-surface, #fff)); }
.empty-state a:not(.button-link) { color: var(--dl-accent, #176d43); font-weight: 700; }
.empty-state-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .75rem; }
.ticket-detail { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--dl-border, #dce7df); }
.ticket-message { margin: .75rem 0; padding: .8rem; border: 1px solid var(--dl-border, #dce7df); border-radius: .5rem; overflow-wrap: anywhere; }
.invoice-table { width: 100%; margin: 1rem 0; border-collapse: collapse; text-align: left; }
.invoice-table th, .invoice-table td { padding: .65rem; border-bottom: 1px solid var(--dl-border, #dce7df); }
.workspace { width: min(100%, var(--dl-container-width, 74rem)); margin: 0 auto; padding: calc(1rem * var(--dl-space-scale, 1)) 0 calc(2rem * var(--dl-space-scale, 1)); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-header h1 { margin-bottom: .5rem; }
.signout { margin: 0; }
.filter-form { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.filter-form label { flex: 1 1 12rem; }
.product-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .75rem; margin: 1rem 0; }
.product-card { min-width: 0; padding: 1rem; border: 1px solid var(--dl-border, #dce7df); border-radius: var(--dl-card-radius, .75rem); background: var(--dl-surface, #fff); }
.product-card h2 { margin: .25rem 0; font-size: 1.5rem; }
.product-card a { color: var(--dl-accent, #176d43); font-weight: 700; }
.cart-line-actions { display: flex; gap: .5rem; margin: .35rem 0; }
.ticket-new { margin-top: 1rem; }
.status { display: inline-block; padding: .2rem .55rem; border-radius: 2rem; background: var(--dl-accent-soft, #e8f1eb); color: var(--dl-text, #174e32); font-size: .75rem; vertical-align: middle; }
.product-row.unread { border-color: var(--dl-accent, #176d43); }
@media (max-width: 40rem) { .page-header { align-items: flex-start; } .filter-form { align-items: stretch; flex-direction: column; } .filter-form label { flex-basis: auto; } }
@media (max-width: 24rem) { body { padding: .75rem; } .panel { border-radius: var(--dl-card-radius, .7rem); } }
@media print {
    @page { margin: 15mm; }
    body { display: block; padding: 0; background: var(--dl-surface, #fff); }
    .workspace { width: auto; margin: 0; padding: 0; }
    .workspace > :not(.invoice-print), .invoice-screen-only { display: none !important; }
    .workspace .invoice-print { width: 100%; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
    .invoice-table { font-size: 10pt; }
    .invoice-table th, .invoice-table td { padding: .4rem; }
}
.portal-nav {
    position: sticky;
    top: 0;
    z-index: 60;
    background: color-mix(in srgb, var(--dl-surface, #fff) 94%, transparent);
    backdrop-filter: blur(.55rem);
    border-bottom: 1px solid var(--dl-border, #dce7df);
}
.portal-nav-inner { width: min(100%, var(--dl-container-width, 74rem)); margin: 0 auto; display: flex; align-items: center; gap: .9rem; padding: .5rem .25rem; }
/* Official brand asset (public/assets/brand/logo-master.png, untouched artwork).
   The small lockup is shown with the portal scope as a separate caption; the
   white plate keeps the artwork visible on dark published themes. */
.portal-brand { flex-shrink: 0; display: inline-flex; align-items: center; gap: .55rem; line-height: 1.15; text-decoration: none; }
.portal-brand-logo { height: 2.15rem; width: auto; display: block; background: #fff; border-radius: .35rem; padding: .12rem .25rem; }
.portal-brand-scope { font-size: .64rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--dl-primary, #187447); }
@media (max-width: 46rem) { .portal-brand-logo { height: 1.9rem; } }
.portal-nav-list { display: flex; align-items: center; gap: .1rem; margin: 0; padding: 0 .35rem; list-style: none; overflow-x: auto; flex: 1 1 auto; min-width: 0; scrollbar-width: thin; }
.portal-nav-list li { display: flex; }
.portal-nav-list a { display: inline-block; padding: .38rem .62rem; border-radius: .45rem; color: color-mix(in srgb, var(--dl-text, #17231e) 72%, var(--dl-background, #f2f6f3)); text-decoration: none; font-size: .83rem; font-weight: 650; white-space: nowrap; }
.portal-nav-list a:hover { background: color-mix(in srgb, var(--dl-primary, #187447) 10%, var(--dl-surface, #fff)); color: var(--dl-text, #17231e); }
.portal-nav-list a[aria-current="page"] { background: var(--dl-primary, #187447); color: var(--dl-surface, #fff); font-weight: 700; }
.portal-user { flex-shrink: 0; display: flex; align-items: center; gap: .55rem; margin-left: auto; }
.portal-user-link { color: var(--dl-accent, #176d43); font-size: .83rem; font-weight: 700; text-decoration: none; }
.portal-user-link:hover { text-decoration: underline; }
.portal-signout { margin: 0; }
.portal-signout button { min-height: 2.15rem; padding: .3rem .7rem; font-size: .78rem; border-radius: calc(var(--dl-button-radius, .45rem) * .9); }

/* Dark-published themes: derive soft fills from tokens so cards, chips and
   buttons stay legible instead of falling back to light-theme colors. */
:root {
    --dl-accent-soft: color-mix(in srgb, var(--dl-accent, #187447) 13%, var(--dl-surface, #fff));
    --dl-danger-soft: color-mix(in srgb, #a83226 12%, var(--dl-surface, #fff));
}
.panel { background: var(--dl-surface, #fff); box-shadow: var(--dl-shadow-strength, 0 1rem 2.5rem rgba(23, 61, 40, .06)); }
select, textarea { background: var(--dl-surface, #fff); }
button.secondary { background: var(--dl-accent-soft, #e8f1eb); color: var(--dl-text, #17231e); }
button.secondary:hover { background: color-mix(in srgb, var(--dl-accent, #187447) 22%, var(--dl-surface, #fff)); }
.status { background: var(--dl-accent-soft, #e8f1eb); color: var(--dl-text, #17231e); border: 1px solid color-mix(in srgb, var(--dl-border, #dce7df) 70%, transparent); }
.error { background: var(--dl-danger-soft, #fff0ef); }
.success { background: color-mix(in srgb, var(--dl-primary, #187447) 13%, var(--dl-surface, #fff)); color: var(--dl-text, #17231e); }
.internal-note { border-color: color-mix(in srgb, #c9962e 55%, var(--dl-surface, #fff)); background: color-mix(in srgb, #c9962e 13%, var(--dl-surface, #fff)); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline-color: color-mix(in srgb, var(--dl-primary, #187447) 70%, #fff); }

/* Workspace rhythm */
.workspace > .page-header { padding: 1.4rem .1rem .3rem; }
.workspace a { color: var(--dl-accent, #176d43); }
.lead, .customer, .product-row, .ticket-row, .ticket-message, .ticket-detail, .product-card { box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.data-table th, .invoice-table th { background: color-mix(in srgb, var(--dl-primary, #187447) 8%, var(--dl-surface, #fff)); border-bottom: 2px solid color-mix(in srgb, var(--dl-primary, #187447) 30%, transparent); }
.data-table tbody tr:nth-child(even), .invoice-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--dl-primary, #187447) 4%, transparent); }
.pagination a, .page-header a { text-decoration: none; }
.pagination a:hover, .page-header a:hover { text-decoration: underline; }
@media print { .portal-nav { display: none !important; } }
@media (max-width: 46rem) {
    .portal-nav-inner { flex-wrap: wrap; gap: .45rem; }
    .portal-nav-list { order: 3; flex-basis: 100%; padding: 0 0 .25rem; }
    .portal-user { margin-left: 0; }
}


/* Two-column record lists inside the workspace halve scroll depth */
.workspace .lead-list, .workspace .customer-list, .workspace .product-list, .workspace .ticket-list {
    grid-template-columns: repeat(auto-fill, minmax(min(23rem, 100%), 1fr));
    align-items: start;
}

/* Workspace pages align to the top; only panel pages (login etc.) stay centered.
   body is display:grid with place-items:center (login choice); on workspace pages
   that made the sticky portal-nav a centered grid item sized to its max-content
   (widening the whole page beyond the viewport). Stretch grid items there. */
body:has(main.workspace) { justify-items: stretch; align-items: start; }
.workspace { align-self: start; }

/* Live chat accents */
.visitor-badge { display: inline-block; padding: .12rem .5rem; border-radius: 2rem; background: var(--dl-primary, #187447); color: var(--dl-surface, #fff); font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }

/* Official brand asset on sign-in screens */
.login-logo { display: block; height: 2.6rem; width: auto; background: #fff; border-radius: .4rem; padding: .15rem .3rem; margin-bottom: 1rem; }

/* Official brand asset on printed quotations */
.print-logo { display: block; height: 2.4rem; width: auto; margin-bottom: .6rem; }
/* ---------- Premium typography for all pages (public + portals) ---------- */
@font-face {
    font-family: "Figtree";
    src: url("assets/fonts/fig-2.woff2") format("woff2");
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+2000-206F, U+2192;
}
@font-face {
    font-family: "Figtree";
    src: url("assets/fonts/fig-1.woff2") format("woff2");
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-024F;
}
@font-face {
    font-family: "Figtree";
    src: url("assets/fonts/fig-4.woff2") format("woff2");
    font-weight: 300 900;
    font-style: italic;
    font-display: swap;
    unicode-range: U+0000-00FF;
}
body { font-family: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3, h4 { font-family: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: -.02em; }

/* AUTO_REPLY_V1: reopen notice + reply panel */
.reopen-note{background:#fff7ed;border:1px solid #fed7aa;color:#9a3412;border-radius:8px;padding:.6rem .8rem;font-size:.85rem;margin:.35rem 0 .55rem;}
.reply-panel{margin-top:.6rem;}
