/* Shared styles for the customer portal and the management pages. */
:root {
  --navy: #0e2b4d; --navy-2: #173a63; --slate: #414b57; --ink: #16202c; --muted: #5b6673;
  --line: #dde2e8; --mist: #f4f6f8; --white: #fff; --ok: #1a7f4b; --ok-bg: #e7f5ed; --warn: #9a5b00; --warn-bg: #fdf3df;
  --bad: #b3261e; --bad-bg: #fbeae9; --info-bg: #e8eef6;
  --head: 'Montserrat', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --body: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.55 var(--body); color: var(--ink); background: var(--mist); overflow-wrap: anywhere; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--navy); }
h1, h2, h3 { font-family: var(--head); color: var(--navy); margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 3.2vw, 1.9rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: .78rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--slate); }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #5b8fd6; outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 22px; background: var(--navy); color: #fff; border: 1px solid var(--navy); border-radius: 2px; font: 600 .8rem/1.2 var(--head); letter-spacing: .1em; text-transform: uppercase; text-decoration: none; text-align: center; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--navy-2); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.line { background: #fff; color: var(--navy); border-color: #b9c3cf; }
.btn.line:hover { background: var(--mist); }
.btn.danger { background: #fff; color: var(--bad); border-color: #e2b6b3; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { min-height: 44px; padding: 8px 14px; font-size: .72rem; white-space: nowrap; }
.linkbtn { background: none; border: 0; padding: 0; min-height: 44px; font: inherit; color: var(--navy); text-decoration: underline; cursor: pointer; }

/* Top bar */
.bar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar-in { max-width: 1140px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; flex: 0 1 auto; min-height: 44px; }
.brand .mark { height: 40px; width: auto; flex: none; }
.brand .word { width: 150px; height: auto; min-width: 0; flex: 0 1 auto; }
.brand .tag { font: 600 .68rem/1 var(--head); letter-spacing: .16em; text-transform: uppercase; color: #fff; background: var(--slate); padding: 5px 8px; border-radius: 2px; flex: none; }
.tabs { background: #fff; border-bottom: 1px solid var(--line); }
.tabs-in { max-width: 1140px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs-in::-webkit-scrollbar { display: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: 48px; padding: 0 12px; font: 600 .76rem/1 var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; }
.tabs a:hover { color: var(--navy); }
.tabs a[aria-current=page] { color: var(--navy); border-bottom-color: var(--navy); }

main { max-width: 1140px; margin: 0 auto; padding: 32px 20px 80px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 24px; }
.page-head > div { min-width: 0; }
.page-head p { color: var(--muted); margin-top: 6px; }
.card { background: #fff; border: 1px solid var(--line); padding: 24px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card > h2, .card > h3 { margin-bottom: 14px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; align-items: start; }
.cols > * { min-width: 0; }
.cols > .card + .card { margin-top: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.spread { justify-content: space-between; }

.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font: 600 .72rem/1.5 var(--head); letter-spacing: .06em; text-transform: uppercase; background: var(--info-bg); color: var(--navy); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.off { background: #eceff2; color: var(--muted); }

.notice { padding: 14px 16px; border-left: 4px solid var(--navy); background: var(--info-bg); margin-bottom: 16px; }
.notice.warn { border-color: #d08a00; background: var(--warn-bg); }
.notice.bad { border-color: var(--bad); background: var(--bad-bg); }
.notice.ok { border-color: var(--ok); background: var(--ok-bg); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h2 { margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }
.skeleton { height: 120px; background: linear-gradient(90deg, #eef1f4, #f7f9fa, #eef1f4); background-size: 200% 100%; animation: sh 1.2s infinite; border: 1px solid var(--line); }
@keyframes sh { to { background-position: -200% 0; } }

/* Forms */
label { display: block; font-weight: 500; font-size: .92rem; margin-bottom: 6px; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; color: var(--ink); background: #fff; border: 1px solid #b9c3cf; border-radius: 2px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #5b8fd6; outline-offset: 0; border-color: var(--navy); }
.field { margin-bottom: 16px; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 0 16px; }
.err { color: var(--bad); font-size: .92rem; margin: 0 0 14px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 6px; }

/* Lists and tables */
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.lines li:last-child { border-bottom: 0; }
.lines .grow { min-width: 0; flex: 1 1 auto; }
.lines .sub { color: var(--muted); font-size: .88rem; }
.total { display: flex; justify-content: space-between; gap: 16px; padding-top: 14px; margin-top: 4px; border-top: 2px solid var(--navy); font: 700 1.05rem var(--head); color: var(--navy); }
.tbl-wrap { container-type: inline-size; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font: 600 .72rem/1.3 var(--head); letter-spacing: .12em; text-transform: uppercase; color: var(--slate); padding: 10px 12px 10px 0; border-bottom: 2px solid var(--navy); }
td { padding: 13px 12px 13px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:last-child, td:last-child { padding-right: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbfc; }
@container (max-width: 640px) {
  table.stackable thead { position: absolute; left: -9999px; }
  table.stackable tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.stackable td { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; border: 0; text-align: right; }
  table.stackable td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; flex: none; }
  table.stackable td:empty { display: none; }
}

/* Quantity stepper */
.qty { display: inline-flex; align-items: center; border: 1px solid #b9c3cf; border-radius: 2px; flex: none; background: #fff; }
.qty button { width: 44px; height: 44px; border: 0; background: none; font-size: 1.25rem; color: var(--navy); cursor: pointer; }
.qty button:hover { background: var(--mist); }
.qty button[disabled] { color: #b9c3cf; cursor: default; background: none; }
.qty output { min-width: 34px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.addbtn { min-width: 132px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; min-height: 44px; padding: 6px 16px; border: 1px solid var(--line); background: #fff; border-radius: 999px; font: 600 .78rem var(--head); color: var(--muted); cursor: pointer; }
.chips button[aria-pressed=true] { background: var(--navy); border-color: var(--navy); color: #fff; }
.savebar { position: sticky; bottom: 0; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--navy); padding: 14px 20px; margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; z-index: 3; }
.savebar strong { font: 700 1.1rem var(--head); color: var(--navy); }

/* Sign in */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: #fff; }
.auth-side { background: var(--navy); color: #fff; padding: 56px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; min-width: 0; }
.auth-side h1 { color: #fff; font-size: clamp(1.8rem, 3.4vw, 2.6rem); max-width: 12em; }
.auth-side p { color: #c9d4e0; margin-top: 16px; max-width: 30em; }
.auth-side ul { list-style: none; padding: 0; margin: 0; border-top: 1px solid rgba(255,255,255,.18); }
.auth-side li { padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.18); color: #c9d4e0; }
.auth-side li strong { color: #fff; font-family: var(--head); font-weight: 600; display: block; }
.auth-main { padding: 48px 24px; display: flex; align-items: center; justify-content: center; min-width: 0; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .logo { width: 150px; margin-bottom: 36px; }
.auth-box h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.auth-box > p { color: var(--muted); margin-bottom: 26px; }
.auth-box .btn { width: 100%; margin-top: 6px; }
.auth-box .switch { margin-top: 22px; text-align: center; color: var(--muted); }

/* Dialog and toast */
dialog { border: 0; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: #fff; box-shadow: 0 24px 60px rgba(14,43,77,.3); }
dialog::backdrop { background: rgba(14,43,77,.5); }
.dlg { padding: 26px; }
.dlg h2 { margin-bottom: 10px; font-size: 1.25rem; }
.dlg p { color: var(--muted); }
.dlg .row { margin-top: 24px; justify-content: flex-end; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 2px; z-index: 20; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.25); }

@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 36px 24px; }
  .auth-side ul { display: none; }
  .auth-main { align-items: flex-start; padding: 36px 24px 56px; }
}
@media (max-width: 520px) {
  main { padding: 24px 16px 72px; }
  .card { padding: 18px; }
  .brand .word { width: 110px; }
  .lines li.wrap { flex-wrap: wrap; }
  .lines li.wrap .grow { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .btn { transition: none; } }

.card + .cols, .cols + .card, .notice + .cols { margin-top: 16px; }

.totals { margin-top: 4px; }
.totals .subline { display: flex; justify-content: space-between; gap: 16px; padding-top: 10px; color: var(--muted); font-size: .95rem; }
.totals .subline:first-child { border-top: 1px solid var(--line); margin-top: 4px; }
.totals .total { margin-top: 12px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 400; margin-bottom: 8px; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 22px; flex: none; accent-color: var(--navy); }
.money-in { max-width: 130px; }
.edit-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.edit-line > * { min-width: 0; }
.edit-box { container-type: inline-size; }
@container (max-width: 520px) {
  .edit-line { grid-template-columns: minmax(0, 1fr) auto; }
  .edit-line .grow { grid-column: 1 / -1; }
}

/* Printable invoice and statement */
.doc { max-width: 820px; padding: 40px; }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px 32px; padding-bottom: 24px; border-bottom: 3px solid var(--navy); margin-bottom: 24px; }
.doc-head > div { min-width: 0; }
.doc-head img { width: 130px; margin-bottom: 10px; }
.doc-title { text-align: right; }
.doc-title h1 { font-size: 1.9rem; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 8px; }
.doc-to { margin-bottom: 26px; }
.doc-to h3, .doc > h3 { margin-bottom: 8px; }
.doc table { margin-bottom: 4px; }
.doc-sum { margin-left: auto; max-width: 320px; }
.doc-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 520px) { .doc { padding: 22px 18px; } .doc-title { text-align: left; } }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .bar, .tabs, .noprint, .toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .doc { border: 0; padding: 0; max-width: none; }
  a { color: inherit; text-decoration: none; }
}
.doc th, .doc td.num { overflow-wrap: normal; white-space: nowrap; }
@media (max-width: 520px) {
  .doc th { letter-spacing: .04em; font-size: .66rem; padding-right: 8px; }
  .doc td { padding-right: 8px; font-size: .92rem; }
}

/* Product pictures */
.thumb { display: grid; place-items: center; flex: none; width: 56px; height: 56px; background: #fff; border: 1px solid var(--line); color: #9aa6b3; font: 600 1.1rem var(--head); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.lg { width: 160px; height: 160px; font-size: 2.4rem; }
.thumb.sm { width: 40px; height: 40px; font-size: .9rem; }
.with-thumb { display: flex; align-items: center; gap: 14px; min-width: 0; }
.with-thumb > div { min-width: 0; }
.photo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin-bottom: 18px; }

/* Google sign-in */
.google-box { margin-bottom: 20px; }
.google-slot { min-height: 44px; display: flex; justify-content: center; }
.google-box .or { display: flex; align-items: center; gap: 14px; margin: 20px 0 0; color: var(--muted); font-size: .88rem; }
.google-box .or::before, .google-box .or::after { content: ""; flex: 1 1 0; height: 1px; background: var(--line); }
