:root {
  --red: #df1b16;
  --red-dark: #b71410;
  --ink: #17191d;
  --muted: #68707d;
  --line: #e2e5ea;
  --soft: #f3f4f6;
  --white: #fff;
  --green: #27ae72;
  --shadow: 0 18px 48px rgba(17, 19, 23, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #eff1f4; color: var(--ink); }
body { min-width: 320px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Preview access screen. The deployed NameHero build replaces this demo check with PHP sessions. */
.login-screen { min-height: 100svh; display: grid; place-items: center; padding: 24px; overflow: hidden; position: relative; background: #111317; }
.login-screen::before { content: ""; position: absolute; inset: auto -22vw -38vw auto; width: 92vw; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(223,27,22,.22), transparent 68%); }
.login-screen::after { content: ""; position: absolute; inset: -28vw auto auto -38vw; width: 78vw; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.06), transparent 65%); }
.login-panel { position: relative; z-index: 1; width: min(100%, 460px); padding: 30px 24px 25px; border: 1px solid rgba(255,255,255,.12); border-radius: 22px; background: rgba(25,28,33,.96); box-shadow: 0 28px 70px rgba(0,0,0,.36); color: white; }
.login-logo { display: block; width: 270px; max-width: 82%; height: auto; margin: 0 auto 28px; }
.login-copy { text-align: center; }
.eyebrow { margin: 0 0 8px; color: #ff6b65; font-size: 11px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.login-copy h1 { margin: 0; font-size: clamp(26px, 8vw, 37px); line-height: 1.08; letter-spacing: -.035em; }
.login-copy > p:last-child { margin: 13px auto 27px; max-width: 350px; color: #b8bdc5; font-size: 14px; line-height: 1.55; }
.login-form { display: grid; gap: 13px; }
.login-form label { display: grid; gap: 7px; }
.login-form label span { font-size: 12px; font-weight: 750; color: #e7e9ec; }
.login-form input { height: 50px; border-color: rgba(255,255,255,.2); background: #0f1114; color: white; }
.login-button { min-height: 50px !important; font-size: 14px !important; }
.preview-note { margin: 0; color: #8f96a0; font-size: 11px; text-align: center; }
.preview-note strong { color: #d7dbe0; }
.login-error { min-height: 16px; margin: -4px 0 0; color: #ff8e89; font-size: 12px; text-align: center; }
.login-footer { position: absolute; z-index: 1; bottom: 13px; margin: 0; color: #777e88; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }

.app-shell { min-height: 100svh; }
.sidebar { position: fixed; z-index: 10; inset: auto 0 0; height: calc(68px + env(safe-area-inset-bottom)); padding: 7px 7px env(safe-area-inset-bottom); background: #111317; color: white; box-shadow: 0 -7px 24px rgba(17,19,23,.15); }
.brand, .sidebar-footer { display: none; }
.nav { height: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.nav-button { min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; padding: 5px 2px; border: 0; border-radius: 9px; background: transparent; color: #aeb4bd; font-weight: 700; font-size: 10px; }
.nav-button.active { color: white; background: var(--red); }
.nav-icon { font-size: 20px; line-height: 1; }

.workspace { min-width: 0; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
.mobile-header { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 16px; background: #111317; color: white; }
.mobile-header img { width: 150px; height: auto; }
.mobile-header span { font-size: 11px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.view-root { width: 100%; max-width: 1260px; margin: 0 auto; padding: 14px 12px 30px; }

.card { background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.03); overflow: hidden; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 13px; padding: 17px 16px 14px; border-bottom: 1px solid var(--line); }
.card-header h2, .modal-header h2 { margin: 0; font-size: 16px; }
.card-header p, .modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.card-body { padding: 16px; }
.stack, .builder-main { display: grid; gap: 13px; }
.two-column { display: grid; gap: 13px; align-items: start; }
.quote-summary { order: initial; }

.setup-banner, .locked-banner { display: grid; gap: 12px; padding: 15px 16px; border: 1px solid #f0c5c2; border-radius: 12px; background: #fff6f5; }
.setup-banner strong, .locked-banner strong { display: block; font-size: 14px; }
.setup-banner span, .locked-banner span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.locked-banner { border-color: #c8dfd4; background: #f2faf6; }

.form-grid { display: grid; gap: 14px; }
.form-grid label, .field, .search-field { display: grid; gap: 7px; min-width: 0; }
.form-grid label > span, .field > span, .search-field > span { color: #344054; font-size: 12px; font-weight: 750; }
.form-grid em { color: #8b929d; font-style: normal; font-weight: 500; }
input, textarea, select { width: 100%; border: 1px solid #cbd1d9; border-radius: 9px; background: white; color: var(--ink); outline: none; }
input, select { min-height: 46px; padding: 0 12px; }
textarea { min-height: 106px; padding: 11px 12px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(223,27,22,.10); }
input:disabled, textarea:disabled { background: #f3f4f6; color: #68707d; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 44px; padding: 10px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 760; font-size: 13px; }
.button.primary { color: white; background: var(--red); border-color: var(--red); }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { color: #344054; background: white; border-color: #d0d5dd; }
.button.secondary:hover { background: #f8f9fa; }
.button.small { min-height: 38px; padding: 7px 11px; font-size: 12px; }
.button:disabled { cursor: wait; opacity: .62; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 9px; background: transparent; color: #667085; font-size: 26px; }

.items-empty { display: grid; place-items: center; min-height: 170px; padding: 28px 18px; border: 1px dashed #cbd0d8; border-radius: 11px; text-align: center; }
.items-empty strong { font-size: 15px; }
.items-empty p { max-width: 420px; margin: 6px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.items-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 13px; }
.items-toolbar small { color: var(--muted); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 9px; background: #17191d; color: white; text-align: left; font-size: 10px; letter-spacing: .045em; text-transform: uppercase; }
td { padding: 11px 9px; border-bottom: 1px solid var(--line); font-size: 12px; vertical-align: middle; }
td.numeric, th.numeric { text-align: right; white-space: nowrap; }
td.actions { text-align: right; }
.item-title, .history-customer { font-weight: 760; }
.item-subtitle { margin-top: 3px; color: var(--muted); font-size: 11px; }
.text-button { min-height: 38px; padding: 5px 7px; border: 0; background: transparent; color: #475467; font-weight: 750; font-size: 12px; }
.text-button:hover { color: var(--red); }

.summary-logo { display: block; width: 235px; max-width: 85%; margin: 0 auto 19px; }
.summary-list { display: grid; gap: 10px; margin: 5px 0 16px; }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.summary-row strong { color: var(--ink); font-size: 13px; text-align: right; }
.summary-total { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; padding: 16px 0; border-top: 2px solid #111; }
.summary-total span { font-weight: 800; }
.summary-total strong { color: var(--red); font-size: 24px; }
.summary-actions { display: grid; gap: 9px; }
.help-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.history-toolbar { margin-bottom: 15px; }
.empty-state { padding: 50px 18px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); font-size: 16px; }
.empty-state p { max-width: 500px; margin: 7px auto 18px; font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { padding: 15px; }
.metric span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 6px; font-size: 22px; }
.catalog-manufacturers { display: flex; flex-wrap: wrap; gap: 7px; }
.manufacturer-chip { padding: 8px 10px; border: 1px solid #e0e3e8; border-radius: 999px; background: #fafafa; font-size: 12px; font-weight: 700; }
.catalog-update { display: grid; gap: 17px; }
.catalog-update h3 { margin: 0; font-size: 15px; }
.catalog-update p { margin: 6px 0 0; max-width: 760px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.modal { width: 100vw; max-width: none; height: 100svh; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: white; }
.modal::backdrop { background: rgba(15,18,23,.62); backdrop-filter: blur(2px); }
.modal-card { height: 100%; max-height: 100%; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; padding: 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: auto; padding: 13px 16px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: white; }
.search-field input { min-height: 49px; font-size: 16px; }
.search-summary { min-height: 30px; padding: 10px 0 6px; color: var(--muted); font-size: 12px; }
.catalog-results-header { display: none; }
.catalog-results { display: grid; gap: 8px; }
.catalog-result { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: white; text-align: left; }
.catalog-result:hover { border-color: #efaaa7; background: #fffafa; }
.catalog-result strong { font-size: 14px; }
.catalog-result span { grid-column: 1; color: var(--muted); font-size: 12px; }
.catalog-result .add-mark { grid-column: 2; grid-row: 1 / span 4; color: var(--red); font-size: 23px; font-weight: 800; }
.manual-link { margin-top: 12px; padding: 12px 0; border: 0; background: transparent; color: var(--red); font-weight: 750; font-size: 12px; }
.item-form-grid { padding: 18px 16px; }
.toast { position: fixed; z-index: 30; inset: auto 12px calc(80px + env(safe-area-inset-bottom)); max-width: 440px; padding: 13px 15px; border-radius: 10px; background: #17191d; color: white; box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b42318; }

@media (max-width: 699px) {
  .items-table thead, .history-table thead { display: none; }
  .items-table, .items-table tbody, .items-table tr, .items-table td,
  .history-table, .history-table tbody, .history-table tr, .history-table td { display: block; width: 100%; }
  .items-table tr, .history-table tr { margin-bottom: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; }
  .items-table td, .history-table td { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; border: 0; text-align: right; }
  .items-table td::before, .history-table td::before { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; text-align: left; }
  .items-table td:nth-child(1)::before { content: "Qty"; }
  .items-table td:nth-child(2)::before { content: "Tire"; }
  .items-table td:nth-child(3)::before { content: "Compound"; }
  .items-table td:nth-child(4)::before { content: "Unit Price"; }
  .items-table td:nth-child(5)::before { content: "Extended"; }
  .items-table td.actions { justify-content: flex-end; margin-top: 5px; padding-top: 8px; border-top: 1px solid var(--line); }
  .items-table td.actions::before { display: none; }
  .history-table td:nth-child(1)::before { content: "Customer"; }
  .history-table td:nth-child(2)::before { content: "Date"; }
  .history-table td:nth-child(3)::before { content: "Items"; }
  .history-table td:nth-child(4)::before { content: "Total"; }
  .history-table td.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; margin-top: 6px; padding-top: 9px; border-top: 1px solid var(--line); }
  .history-table td.actions::before { display: none; }
  .history-table .text-button { border: 1px solid var(--line); border-radius: 7px; }
}

@media (min-width: 700px) {
  .view-root { padding: 22px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: 1 / -1; }
  .setup-banner, .locked-banner { grid-template-columns: 1fr auto; align-items: center; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .catalog-update { grid-template-columns: 1fr auto; align-items: center; }
  .modal { width: min(880px, calc(100vw - 38px)); height: auto; max-height: calc(100svh - 38px); margin: auto; border-radius: 16px; box-shadow: var(--shadow); }
  .modal-card { max-height: calc(100svh - 38px); }
  .modal-header { padding: 20px 22px; }
  .modal-body { padding: 20px 22px; }
  .modal-footer { display: flex; justify-content: flex-end; padding: 15px 22px; }
  .catalog-results-header, .catalog-result { display: grid; grid-template-columns: 120px 130px minmax(180px,1fr) 90px 28px; gap: 12px; }
  .catalog-results-header { align-items: center; padding: 9px 13px; border-radius: 8px; background: #17191d; color: white; }
  .catalog-results-header span { font-size: 10px; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
  .catalog-results { max-height: 430px; overflow-y: auto; }
  .catalog-result { align-items: center; padding: 12px 13px; }
  .catalog-result span, .catalog-result .add-mark { grid-column: auto; grid-row: auto; }
  .item-modal { width: min(680px, calc(100vw - 38px)); }
  .toast { right: 22px; left: auto; bottom: 22px; }
}

@media (min-width: 960px) {
  .app-shell { display: grid; grid-template-columns: 248px minmax(0,1fr); }
  .sidebar { position: sticky; inset: 0 auto auto; width: 248px; height: 100vh; padding: 24px 16px; display: flex; flex-direction: column; box-shadow: none; }
  .brand { display: block; padding: 0 10px 27px; border-bottom: 1px solid rgba(255,255,255,.1); text-align: center; }
  .brand img { display: block; width: 198px; max-width: 100%; margin: 0 auto; }
  .brand span { display: block; margin-top: 10px; color: white; font-size: 12px; font-weight: 850; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
  .nav { height: auto; display: grid; grid-template-columns: 1fr; gap: 7px; padding-top: 21px; }
  .nav-button { width: 100%; min-height: 44px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; border-radius: 9px; font-size: 13px; text-align: left; }
  .nav-icon { width: 22px; text-align: center; font-size: 19px; }
  .sidebar-footer { margin-top: auto; display: flex; align-items: flex-start; gap: 10px; padding: 14px 10px 2px; color: #d5d8dd; }
  .sidebar-footer strong, .sidebar-footer small { display: block; }
  .sidebar-footer strong { font-size: 13px; }
  .sidebar-footer small { margin-top: 3px; color: #8e949e; font-size: 11px; }
  .offline-dot { margin-top: 4px; width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(39,174,114,.12); }
  .workspace { padding-bottom: 0; }
  .mobile-header { display: none; }
  .view-root { padding: 28px 32px 52px; }
  .two-column { grid-template-columns: minmax(0,1fr) 350px; gap: 18px; }
  .builder-main { gap: 18px; }
  .quote-summary { position: sticky; top: 28px; }
  .card-header { padding: 20px 22px 17px; }
  .card-body { padding: 22px; }
}

@media (min-width: 1180px) {
  .two-column { grid-template-columns: minmax(0,1fr) 365px; }
}
