:root {
  --navy: #1f3a5f;
  --navy-dark: #152a46;
  --accent: #e8792b;
  --brand-green: #33cc98;
  --brand-green-dark: #1a7a59;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e7ee;
  --text: #1b2430;
  --muted: #64748b;
  --danger: #c0392b;
  --success: #1e8e5a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
button, input { font: inherit; }

/* ---------- Auth screens ---------- */
.auth-header { position: absolute; top: 0; left: 0; padding: 22px 28px; }
.auth-header .logo { height: 52px; width: auto; display: block; }
@media (max-width: 600px) {
  .auth-header { position: static; padding: 18px 16px 0; }
  .auth-header .logo { height: 40px; }
}
.center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: #ffffff;
}
.center-screen .spinner { border-color: rgba(51, 204, 152, .25); border-top-color: var(--brand-green); }

/* Sign-in box: Duggan website green (#33CC98, as used on the website's forms) */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--brand-green);
  color: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 12px 36px rgba(16, 24, 40, .14);
}
.auth-card .brand-mark { background: #fff; color: var(--brand-green-dark); }
.auth-card .brand-name { color: #fff; }
.auth-card .brand-sub,
.auth-card p.lead,
.auth-card .note,
.auth-card ol.steps { color: rgba(255, 255, 255, .92); }
.auth-card ol.steps strong { color: #fff; }
.auth-card label { color: #fff; }
.auth-card input[type=email],
.auth-card input[type=password],
.auth-card input[type=text] { border-color: #fff; }
.auth-card input:focus { outline: 3px solid rgba(255, 255, 255, .6); outline-offset: 1px; border-color: #fff; }
.auth-card .btn { background: #fff; color: var(--brand-green-dark); }
.auth-card .btn:hover { background: #eafaf4; }
.auth-card .link-btn { color: #fff; }
.auth-card .error:not(:empty) {
  background: #fff; color: var(--danger);
  border-radius: 6px; padding: 8px 10px; font-weight: 500;
}
.auth-card .secret { background: rgba(255, 255, 255, .2); color: #fff; }
.auth-card .qr-box { border-color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-name { font-weight: 700; font-size: 17px; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 13px; }
.auth-card .brand-sub { color: rgba(255, 255, 255, .92); }
.auth-card h1 { font-size: 20px; margin: 0 0 6px; }
.auth-card p.lead { color: rgba(255, 255, 255, .95); margin: 0 0 20px; font-size: 14px; }

label { display: block; font-weight: 500; font-size: 14px; margin: 14px 0 6px; }
input[type=email], input[type=password], input[type=text], input[type=tel], input[type=number], input[type=date], input[type=url] {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
}
input:focus { outline: 2px solid var(--navy); outline-offset: 1px; border-color: var(--navy); }
input.code {
  text-align: center; font-size: 24px; letter-spacing: 10px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 8px; padding: 11px 16px;
  font-weight: 600; cursor: pointer;
  background: var(--navy); color: #fff;
}
.btn:hover { background: var(--navy-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; margin-top: 20px; }
.btn.ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn.ghost:hover { background: #eef1f5; color: var(--text); }

.link-btn { background: none; border: 0; color: var(--navy); cursor: pointer; padding: 0; font-size: 14px; text-decoration: underline; }
.auth-footer { margin-top: 16px; text-align: center; }
.error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 1em; }
.note { color: var(--muted); font-size: 13px; margin-top: 12px; }

.qr-box {
  display: grid; place-items: center;
  padding: 14px; margin: 8px 0 4px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.qr-box img, .qr-box svg { width: 190px; height: 190px; }
.secret {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px; background: #f1f4f8; border-radius: 6px;
  padding: 8px 10px; word-break: break-all; text-align: center;
}
ol.steps { padding-left: 20px; margin: 0 0 8px; color: var(--muted); font-size: 14px; }
ol.steps li { margin: 4px 0; }

/* ---------- App shell (white + Duggan green, logo top-left) ---------- */
body { background: #ffffff; }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: #ffffff; color: var(--text);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { height: 46px; width: auto; display: block; margin: 2px 8px 26px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 2px;
  color: #3b4654; text-decoration: none; font-weight: 500; font-size: 14px;
}
.nav a:hover { background: #effbf6; color: var(--brand-green-dark); }
.nav a.active { background: var(--brand-green); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 8px 0; font-size: 13px; }
.sidebar-foot .who { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .secure { color: var(--brand-green-dark); display: flex; align-items: center; gap: 6px; margin: 2px 0 10px; }
.sidebar-foot .btn.ghost { color: var(--muted); padding: 6px 0; }
.sidebar-foot .btn.ghost:hover { background: none; color: var(--text); }

.main { padding: 28px 32px; min-width: 0; background: #ffffff; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 22px; }
.topbar .logo { display: none; height: 36px; width: auto; }
.menu-btn { display: none; }

/* Buttons and accents follow the website: green with white text */
.btn { background: var(--brand-green); color: #fff; }
.btn:hover { background: #2bb585; }
input:focus { outline-color: var(--brand-green); border-color: var(--brand-green); }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.grid .card { border-top: 3px solid var(--brand-green); }
.dash-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1400px) { .dash-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .dash-grid { grid-template-columns: 1fr; } }
.stat-card { padding: 18px 20px; }
.dash-heading { font-size: 16px; margin: 28px 0 12px; color: var(--text); }
a.stat-card.acct { text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
a.stat-card.acct:hover { box-shadow: 0 6px 20px rgba(16, 24, 40, .12); transform: translateY(-1px); }
a.stat-card.acct .stat-period { color: var(--brand-green-dark); }
.grid .card.acct.prospect { border-top-color: #2f4fd1; }
.grid .card.acct.cold { border-top-color: #9aa4b2; }
.grid .card.acct.lapsed { border-top-color: #e59a2b; }
.accounts-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .accounts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .accounts-grid { grid-template-columns: 1fr; } }
.stat-title { font-weight: 700; font-size: 16px; }
.stat-period { color: var(--muted); font-size: 13px; margin: 2px 0 14px; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.stat-row:first-child { border-top: 0; }
.stat-row span { color: var(--muted); font-size: 14px; }
.stat-row strong { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

.placeholder { text-align: center; padding: 48px 24px; }
.placeholder h2 { margin: 0 0 8px; font-size: 18px; }
.placeholder p { color: var(--muted); margin: 0 auto; max-width: 480px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.chip { background: #effbf6; color: var(--brand-green-dark); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 500; }

/* ---------- Customers ---------- */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input.search {
  width: 100%; padding: 14px 16px 14px 44px; font-size: 16px;
  border: 1.5px solid var(--border); border-radius: 10px; background: #fff;
}
input.search:focus { outline: 3px solid rgba(51, 204, 152, .25); border-color: var(--brand-green); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #f2f4f7; border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 7px; font-weight: 500; font-size: 14px; color: #3b4654; cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.seg .count { color: var(--muted); font-weight: 400; margin-left: 2px; }
a.btn { text-decoration: none; }

.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fdfb; cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a { color: var(--text); font-weight: 600; text-decoration: none; }
.table a:hover { color: var(--brand-green-dark); text-decoration: underline; }
.table mark { background: #c9f2e3; color: inherit; border-radius: 3px; padding: 0 1px; }
.row-actions { text-align: right; }
.table td.acct-no { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; white-space: nowrap; }
.table .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.acct-badge { display: inline-block; vertical-align: middle; font-size: 13px; font-weight: 600; color: var(--muted); background: #f2f4f7; border-radius: 6px; padding: 2px 8px; margin-left: 6px; letter-spacing: .02em; }
.table .center, .table th.center { text-align: center; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: #cfd5dd; border-radius: 999px; transition: background .15s; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .slider { background: var(--brand-green); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 3px solid rgba(51, 204, 152, .4); outline-offset: 2px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty a { color: var(--brand-green-dark); font-weight: 600; }
.muted { color: var(--muted); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f5; color: #3b4654; text-transform: capitalize; }
.pill.small { font-size: 11px; padding: 2px 8px; margin-left: 6px; vertical-align: 1px; }
.pill.prospect { background: #e8efff; color: #2f4fd1; }
.pill.cold { background: #eef1f5; color: #5b6676; }
.pill.active { background: #ddf7ed; color: var(--brand-green-dark); }
.pill.lapsed { background: #fff2dc; color: #a15c00; }
.pill.q-draft { background: #eef1f5; color: #5b6676; }
.pill.q-sent { background: #e8efff; color: #2f4fd1; }
.pill.q-accepted { background: #ddf7ed; color: var(--brand-green-dark); }
.pill.q-declined { background: #fdecea; color: #b42318; }
.pill.q-expired { background: #fff2dc; color: #a15c00; }
.pill.o-confirmed, .pill.o-approved { background: #e8efff; color: #2f4fd1; }
.pill.o-artwork, .pill.o-proof_sent { background: #f3e8ff; color: #7a2fd1; }
.pill.o-in_production, .pill.o-dispatched { background: #fff2dc; color: #a15c00; }
.pill.o-delivered, .pill.o-invoiced, .pill.o-paid { background: #ddf7ed; color: var(--brand-green-dark); }
.pill.o-cancelled { background: #fdecea; color: #b42318; }
.table tr.is-cancelled td { color: var(--muted); }
.table tr.is-cancelled td:first-child { text-decoration: line-through; }

.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 10px; }
.back:hover { color: var(--brand-green-dark); }
.section-title { margin: 0 0 16px; font-size: 20px; }
.cust-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.cust-name { margin: 0; font-size: 24px; }
.cust-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.cust-meta a { color: var(--muted); text-decoration: none; }
.cust-meta a:hover { color: var(--brand-green-dark); text-decoration: underline; }
a.visit { font-weight: 500; font-size: 13px; color: var(--brand-green-dark); margin-left: 6px; text-decoration: none; }
a.visit:hover { text-decoration: underline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pill-select { appearance: none; border: 0; border-radius: 999px; padding: 7px 30px 7px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
.pill-select.prospect { background-color: #e8efff; color: #2f4fd1; }
.pill-select.cold { background-color: #eef1f5; color: #5b6676; }
.pill-select.active { background-color: #ddf7ed; color: var(--brand-green-dark); }
.pill-select.lapsed { background-color: #fff2dc; color: #a15c00; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--brand-green-dark); border-bottom-color: var(--brand-green); font-weight: 600; }

.form-card { padding: 22px; margin-bottom: 16px; }
.form-title { margin: 0 0 6px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.field label { margin-top: 12px; }
select, textarea { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
textarea { resize: vertical; }
select:focus, textarea:focus { outline: 2px solid var(--brand-green); outline-offset: 1px; border-color: var(--brand-green); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-green); }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.form-actions .error { margin: 0; }
.btn.ghost.danger { color: var(--danger); }
.btn.ghost.danger:hover { background: #fdecea; }
.link-btn { color: var(--brand-green-dark); }

@media (max-width: 1200px) { .hide-md { display: none; } }
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px 12px; }
}

/* ---------- Store products ---------- */
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.compact-select { width: auto; min-width: 200px; padding: 8px 10px; }
.small { font-size: 13px; }
.thumb-cell { width: 64px; padding-right: 0 !important; }
.thumb-cell img { width: 48px; height: 48px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--border); display: block; }
.table th.internal, .table td.internal { background: #fbf7ee; }
.table thead th.internal { color: #8a6d2b; }
.load-more-wrap { text-align: center; margin-top: 12px; }
.progress { margin-bottom: 14px; }
.progress .bar { height: 8px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--brand-green); transition: width .3s; }
.progress-text { font-size: 13px; color: var(--muted); margin-top: 6px; }
.progress.failed .bar span { background: var(--danger); }
.progress.failed .progress-text { color: var(--danger); }
.product-head { display: flex; gap: 24px; align-items: flex-start; margin: 6px 0 16px; flex-wrap: wrap; }
.product-img { width: 220px; height: 220px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.product-meta { flex: 1; min-width: 260px; }
.lead-time { margin: 10px 0; }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 10px 0 14px; font-size: 14px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }
.supplier-form { max-width: 420px; margin: 8px 0 12px; }
.supplier-form .inline { display: flex; gap: 8px; }
.internal-tag { font-size: 11px; font-weight: 600; color: #8a6d2b; background: #fbf0d9; border-radius: 4px; padding: 1px 6px; margin-left: 4px; }
.product-desc { color: #3b4654; max-width: 900px; }
.price-card { margin-bottom: 14px; }
.price-head { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--border); background: #fafbfc; }

/* ---------- Misc ---------- */
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .main { padding: 16px; }
  .topbar { flex-wrap: wrap; }
  .topbar .logo { display: block; order: 0; }
  .menu-btn { display: inline-flex; order: 1; background: #fff; color: var(--text); border: 1px solid var(--border); padding: 8px 12px; }
  .menu-btn:hover { background: #effbf6; }
  .topbar h1 { order: 2; width: 100%; font-size: 20px; margin-top: 8px; }
  .topbar > span { display: none; }
}
