/* Client portal. Same look as the landing page: light slate background,
   white cards, the brand blue-to-indigo buttons, Plus Jakarta Sans. */

:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --line: #e2e8f0;
    --heading: #0f172a;
    --text: #334155;
    --muted: #64748b;
    --blue: #2563eb;
    --indigo: #4f46e5;
    --cyan: #06b6d4;
    --blue-wash: #eff6ff;
    --green: #047857;
    --green-wash: #ecfdf5;
    --red: #be123c;
    --red-wash: #fff1f2;
    --amber-wash: #fffbeb;
    --radius: 16px;
    --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

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

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 15.5px/1.6 var(--font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--blue); text-underline-offset: 2px; }
h1 { margin: 0 0 6px; font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; color: var(--heading); }
h2 { margin: 0 0 12px; font-size: 18px; line-height: 1.3; font-weight: 700; color: var(--heading); }
h3 { margin: 20px 0 6px; font-size: 14px; font-weight: 700; color: var(--heading); }
p { margin: 0 0 14px; }

:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; border-radius: 6px; }

.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.lead { margin: 0; color: var(--muted); max-width: 64ch; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.crumb { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.crumb a::before { content: "‹ "; }

/* ---------- Icons ---------- */
.ic { width: 20px; height: 20px; flex-shrink: 0; }
.ic-lg { width: 24px; height: 24px; }
.ico-mask { display: inline-block; background-color: currentColor; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; -webkit-mask-size: contain; mask-size: contain; }

/* ---------- Header ---------- */
.p-wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }

.p-header { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.p-header-in { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 84px; }

.p-logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--heading); flex-shrink: 0; }
.p-logo img { height: 56px; width: auto; max-width: min(260px, 50vw); object-fit: contain; display: block; }
.p-logo-tile { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(45deg, var(--blue), var(--cyan)); color: #fff; }
.p-logo-name { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.p-logo-name b { color: var(--blue); font-weight: 800; }

.p-nav { display: flex; align-items: center; gap: 4px; }
.p-nav form { margin: 0 0 0 8px; }
.p-nav a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; color: #475569; font-size: 14.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.p-nav a:hover { color: var(--blue); background: var(--blue-wash); }
.p-nav a.is-active { color: var(--blue); background: var(--blue-wash); }
.p-signout { padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #475569; font: 600 14px var(--font); cursor: pointer; white-space: nowrap; }
.p-signout:hover { border-color: #94a3b8; color: var(--heading); }
.p-menu-btn { display: none; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--heading); font: 600 14px var(--font); cursor: pointer; }
.p-badge { display: inline-block; min-width: 20px; padding: 0 7px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }

.p-main { flex: 1; padding-top: 36px; padding-bottom: 64px; }

.p-footer { border-top: 1px solid var(--line); background: #fff; font-size: 13.5px; color: var(--muted); }
.p-footer .p-wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; padding-top: 18px; padding-bottom: 18px; }

/* ---------- Page pieces ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-head .btn, .page-head .status { flex-shrink: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 4px 20px -6px rgba(15, 23, 42, 0.06); }
.card > :last-child { margin-bottom: 0; }
.card-flush { padding: 6px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head a { font-size: 14px; font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }

.flash { margin: 0 0 20px; padding: 12px 16px; border-radius: 12px; border: 1px solid; font-weight: 600; font-size: 14.5px; }
.flash-ok { background: var(--green-wash); border-color: #a7f3d0; color: var(--green); }
.flash-error { background: var(--red-wash); border-color: #fecdd3; color: var(--red); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-top: 1px solid #eef2f6; }
.rows li:first-child { border-top: 0; }
.rows-main { display: flex; flex-direction: column; min-width: 0; text-decoration: none; color: var(--text); font-size: 14.5px; }
.rows-main strong { color: var(--heading); font-weight: 700; }
a.rows-main:hover strong { color: var(--blue); }
.rows-wide .rows-main span { overflow-wrap: anywhere; }

.total-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.total-line strong { font-size: 22px; font-weight: 800; color: var(--heading); }
.card h2 + .total-line { margin-top: 0; padding-top: 0; border-top: 0; margin-bottom: 14px; }
.preview { overflow-wrap: anywhere; }

.status { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: #f1f5f9; color: #475569; }
.status-lg { padding: 7px 16px; font-size: 14px; }
.status-new { background: var(--blue-wash); color: #1d4ed8; }
.status-review, .status-quoted { background: var(--amber-wash); color: #b45309; }
.status-confirmed, .status-progress { background: #eef2ff; color: #4338ca; }
.status-done { background: var(--green-wash); color: var(--green); }
.status-cancelled { background: #f1f5f9; color: #64748b; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--heading); font: 700 14.5px/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #94a3b8; }
.btn-primary { border: 0; padding: 12px 22px; background: linear-gradient(90deg, var(--blue), var(--indigo)); color: #fff; box-shadow: 0 6px 16px -6px rgba(37, 99, 235, 0.55); }
.btn-primary:hover { background: linear-gradient(90deg, #1d4ed8, #4338ca); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-danger { color: var(--red); border-color: #fecdd3; }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-wide { width: 100%; padding: 14px 22px; }

/* ---------- Forms ---------- */
.form { margin-top: 18px; }
.form-inline { margin: 0 0 18px; }
.field { margin: 0 0 16px; min-width: 0; }
.field label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 700; color: var(--heading); }
.req { color: var(--red); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"], textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
    color: var(--heading);
    font: 400 15px/1.45 var(--font);
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px #dbeafe; }
.has-error input, .has-error textarea { border-color: var(--red); }
.help { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }
.field-error { margin: 6px 0 0; font-size: 13.5px; font-weight: 600; color: var(--red); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 18px; }
.form-actions form { margin: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Sign in / register ---------- */
body.guest { display: block; padding: 6vh 16px 40px; background: radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.10) 0%, rgba(6, 182, 212, 0.05) 45%, transparent 75%), var(--bg); }
.guest-card { width: 100%; max-width: 440px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 32px 34px 26px; box-shadow: 0 20px 50px -20px rgba(15, 23, 42, 0.18); }
.guest-card.is-wide { max-width: 620px; }
.guest-card h1 { font-size: 25px; }
.guest-card .lead { margin-bottom: 18px; }
.guest-brand { margin-bottom: 22px; }
.guest-alt { margin: 14px 0 0; font-size: 14.5px; }
.guest-alt a { font-weight: 700; }
.guest-back { margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13.5px; }

/* ---------- Products ---------- */
.group-title { margin: 30px 0 12px; font-size: 13px; font-weight: 700; color: var(--blue); }
.group-title:first-of-type { margin-top: 0; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.product { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; box-shadow: 0 4px 20px -8px rgba(15, 23, 42, 0.06); }
.product:hover { border-color: #bfdbfe; }
.product input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.product:has(input:checked) { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue), 0 10px 26px -12px rgba(37, 99, 235, 0.35); }
.product:has(input:focus-visible) { outline: 3px solid #93c5fd; outline-offset: 3px; }
.product-tile { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px; background: #f1f5f9; }
.product-title { font-size: 18px; font-weight: 700; color: var(--heading); line-height: 1.3; }
.product-title em { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--green-wash); color: var(--green); vertical-align: middle; }
.product-text { font-size: 14px; color: var(--text); }
.product-points { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.product-points span::before { content: "✓ "; color: var(--blue); font-weight: 700; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 14px; border-top: 1px solid #eef2f6; }
.product-price { font-weight: 700; color: var(--heading); font-size: 14.5px; }
.product-pick { padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line); font-size: 13.5px; font-weight: 700; color: var(--heading); }
.product-pick .when-on { display: none; }
.product:has(input:checked) .product-pick { background: var(--blue); border-color: var(--blue); color: #fff; }
.product:has(input:checked) .when-on { display: inline; }
.product:has(input:checked) .when-off { display: none; }

.order-box { margin-top: 28px; }
.order-box #orderSummary { font-weight: 600; }

/* ---------- Messenger ---------- */
.chat { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 20px -6px rgba(15, 23, 42, 0.06); overflow: hidden; }
.chat-log { display: flex; flex-direction: column; gap: 10px; height: min(56vh, 560px); min-height: 280px; overflow-y: auto; padding: 22px; background: #f8fafc; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 34ch; }
.chat-msg { display: flex; flex-direction: column; max-width: min(78%, 560px); }
.chat-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.is-theirs { align-self: flex-start; align-items: flex-start; }
.chat-bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }
.is-mine .chat-bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.is-theirs .chat-bubble { background: #fff; color: var(--heading); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg time, .chat-note time { margin-top: 3px; font-size: 11.5px; color: #94a3b8; }
.chat-note { align-self: center; text-align: center; max-width: 90%; font-size: 13px; color: var(--muted); }
.chat-note span { display: inline-block; padding: 5px 12px; border-radius: 12px; background: #eef2f6; }
.chat-note time { display: block; }
.chat-form { display: flex; align-items: flex-end; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; max-height: 160px; }
.chat-error { margin: 0; padding: 0 16px 12px; color: var(--red); font-size: 14px; font-weight: 600; }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
    .p-menu-btn { display: inline-block; }
    .p-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 2px; padding: 10px 16px 16px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 16px 30px -18px rgba(15, 23, 42, 0.3); }
    .p-nav.is-open { display: flex; }
    .p-nav form { margin: 8px 0 0; }
    .p-signout { width: 100%; }
    .split { grid-template-columns: minmax(0, 1fr); }
    .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
    .page-head .status { align-self: flex-start; }
    h1 { font-size: 25px; }
    .p-main { padding-top: 24px; }
}

@media (max-width: 560px) {
    .field-row { grid-template-columns: minmax(0, 1fr); }
    .guest-card { padding: 26px 20px 22px; border-radius: 18px; }
    .card { padding: 18px; }
    .card-flush { padding: 4px 18px; }
    .chat-log { padding: 14px; height: 58vh; }
    .chat-msg { max-width: 88%; }
    .product-grid { grid-template-columns: minmax(0, 1fr); }
}
