:root {
    /* Showhome Furniture site palette (showhomefurniturevictoria.com); clay deepened for text and button contrast */
    --ink: #2c2a27; --ink-2: #5a554d; --muted: #6e685e; --faint: #857f75;
    --bg: #faf7f2; --surface: #fff; --sidebar: #f2ece2; --raised: #f7f3ec; --sand: #e8dfd2;
    --line: #e4dccf; --line-strong: #d6c9b6;
    --accent: #8a7055; --accent-hover: #7a6149; --accent-soft: #efe6da; --accent-ink: #7a6149; --clay: #b49b7e;
    --sage-soft: #e6ece7; --sage-ink: #4f6153;
    --danger: #a33b2b; --danger-soft: #f8e6e1;
    --warn: #7a5a12; --warn-soft: #f6ecd6;
    --info: #46566b; --info-soft: #e6eaf0;
    --radius: 10px; --radius-lg: 14px; --pill: 999px;
    --shadow: 0 1px 2px rgba(44, 42, 39, .04), 0 10px 30px -22px rgba(44, 42, 39, .35);
    --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --sans: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --ease: cubic-bezier(.16, 1, .3, 1);
    color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--ink); caret-color: var(--accent);
    font: 15px/1.6 var(--sans);
    -webkit-font-smoothing: antialiased; scrollbar-color: var(--line-strong) transparent;
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: .01em; }
h1 { font-size: 36px; line-height: 1.1; margin: 0 0 24px; text-wrap: balance; }
h2 { font-size: 24px; line-height: 1.2; margin: 0 0 12px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
    padding: 20px 14px; background: var(--sidebar); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-name { display: grid; gap: 5px; line-height: 1; }
.brand-name strong { font-family: var(--serif); font-size: 23px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.brand-name span { font-size: 10.5px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase; color: var(--accent-ink); }
.nav { display: grid; gap: 18px; flex: 1; align-content: start; }
.nav-group { display: grid; gap: 2px; }
.nav-label { padding: 0 12px 6px; font-size: 10.5px; font-weight: 500; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--pill);
    color: var(--ink-2); text-decoration: none; font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav a .icon { color: var(--faint); transition: color .15s var(--ease); }
.nav a:hover { background: rgba(44, 42, 39, .05); color: var(--ink); }
.nav a:hover .icon { color: var(--ink-2); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(44, 42, 39, .06); }
.nav a[aria-current="page"] .icon { color: var(--clay); }
.account { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.avatar {
    display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%;
    background: var(--sand); color: var(--ink); font-family: var(--serif); font-size: 15px; font-weight: 600;
}
.account-name { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.account-name strong { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name span { font-size: 12.5px; color: var(--muted); }
.account form { margin: 0; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; min-height: 0; padding: 0; border: 0; border-radius: var(--radius); background: none; color: var(--muted); }
.icon-button:hover { background: rgba(44, 42, 39, .06); color: var(--ink); }

.content { min-width: 0; padding: 32px clamp(24px, 3vw, 48px) 48px; }

/* Guest pages */
.guest { min-height: 100vh; display: grid; place-content: center; gap: 24px; padding: 32px 16px; }
.guest .brand { justify-self: center; }
.guest .card { width: min(400px, calc(100vw - 32px)); padding: 28px; margin: 0; }
.guest h1 { font-size: 30px; }

/* Page header */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1, .page-head h2 { margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head p { margin: 0; }
.card-head:last-child { margin-bottom: 0; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card > .table-wrap.flush { margin: 0 -24px -24px; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-lg) var(--radius-lg); box-shadow: none; }
.card > .table-wrap:not(.flush) { box-shadow: none; }
.card > .table-wrap + form { margin-top: 16px; }
.narrow { max-width: 420px; margin: 40px auto; }
.stack { display: grid; gap: 16px; align-content: start; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px 24px; }
.field-name { max-width: 480px; }
.form-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 24px 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-columns h2 { font-size: 22px; margin: 0; }
.form-columns > section + section { padding-left: 40px; border-left: 1px solid var(--line); }
@media (max-width: 1040px) { .form-columns > section + section { padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--line); } }
.card > .stack > .actions { padding-top: 20px; border-top: 1px solid var(--line); }
.actions.add-field { flex-wrap: nowrap; max-width: 640px; }
form.stack + p { margin-top: 16px; }

/* Forms */
label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
label.inline { display: flex; gap: 10px; align-items: center; font-weight: 400; color: var(--ink); }
input, select, textarea {
    font: inherit; font-weight: 400; color: var(--ink); min-height: 38px; padding: 7px 10px; width: 100%;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--clay); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
fieldset { margin: 0; padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 8px; }
legend { padding: 0 6px; font-size: 14px; font-weight: 500; color: var(--ink-2); }

/* Buttons */
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-size: 12px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; line-height: 1.2; white-space: nowrap;
    min-height: 38px; padding: 9px 20px; border: 1px solid var(--line-strong); border-radius: var(--pill);
    background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
button:hover, .button:hover { background: var(--raised); border-color: var(--ink); color: var(--ink); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: progress; transform: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
button.link { min-height: 0; border: 0; background: none; color: var(--accent-ink); padding: 0; font-size: inherit; letter-spacing: 0; text-transform: none; }
button.link:hover { background: none; color: var(--accent-hover); text-decoration: underline; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--raised); font-size: 11px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .15s var(--ease); }
tbody tr:hover { background: #fdfbf8; }
td.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
td.nowrap, td .actions { white-space: nowrap; flex-wrap: nowrap; }
td .muted { font-size: 13px; margin-top: 4px; }

/* Tabs */
.tabs { display: inline-flex; gap: 2px; padding: 4px; margin-bottom: 16px; background: var(--sidebar); border: 1px solid var(--line); border-radius: var(--pill); flex-wrap: wrap; }
.tabs a { padding: 6px 16px; border-radius: var(--pill); text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease); }
.tabs a:hover { color: var(--ink); }
.tabs a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.tabs .count { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: var(--pill); background: rgba(44, 42, 39, .07); font-size: 12px; font-weight: 600; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.tabs a.active .count { background: var(--accent); color: #fff; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .tabs { margin-bottom: 0; }
.toolbar form { width: min(280px, 100%); }
.page-tabs { margin-bottom: 20px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 0 20px; }
.settings-grid > .card { display: flex; flex-direction: column; }
.settings-grid > .card > form:last-child { margin-top: auto; }
code { font: 13px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; padding: 1px 6px; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); overflow-wrap: anywhere; }
code.url { display: block; width: fit-content; max-width: 100%; margin-top: 6px; padding: 4px 8px; user-select: all; }

/* Messages */
.flash, .errors { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 20px; font-size: 14px; }
.flash { background: var(--sage-soft); color: var(--sage-ink); border: 1px solid #cdd8cf; }
.errors { background: var(--danger-soft); color: var(--danger); border: 1px solid #efc9c0; }
.errors ul { margin: 0; padding-left: 18px; }

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; line-height: 1.4;
    padding: 2px 10px; border-radius: var(--pill); background: var(--sand); color: var(--ink-2); white-space: nowrap;
}
.badge.status { text-transform: capitalize; }
.badge.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pending_approval { background: var(--warn-soft); color: var(--warn); }
.status-queued, .status-sending { background: var(--info-soft); color: var(--info); }
.status-sent { background: var(--sage-soft); color: var(--sage-ink); }
.status-failed { background: var(--danger-soft); color: var(--danger); }
.status-skipped { background: var(--sand); color: var(--ink-2); }

.muted { color: var(--muted); }
details { margin-top: 6px; }
summary { cursor: pointer; font-size: 13px; color: var(--muted); width: fit-content; white-space: nowrap; }
summary:hover { color: var(--ink); }
details[open] summary { margin-bottom: 6px; }
pre { white-space: pre-wrap; margin: 0; font: 12.5px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: var(--ink-2); }
details pre { padding: 10px 12px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); overflow-wrap: anywhere; }

/* Queue groups */
.empty { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.queue-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px 20px; }
.queue-group + .queue-group { margin-top: 16px; }
.queue-group > summary, .queue-customer > summary { width: auto; white-space: normal; display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; }
.queue-customer > summary .actions { margin-left: auto; }
.queue-customer { margin: 12px 0 0; padding: 14px 16px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); }
.queue-items { margin-top: 10px; box-shadow: none; }
.queue-items th.num, .queue-items td.num { text-align: right; white-space: nowrap; }
.queue-items td { overflow-wrap: anywhere; }
.queue-items td .badge + .badge { margin-left: 4px; }

/* Pagination */
.pagination { display: flex; gap: 8px; list-style: none; padding: 0; margin: 16px 0 0; }
.page-link { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 18px; border: 1px solid var(--line-strong); border-radius: var(--pill); background: var(--surface); color: var(--ink); font-size: 14px; text-decoration: none; }
a.page-link:hover { background: var(--raised); color: var(--ink); }
.page-item.disabled .page-link { color: var(--faint); background: transparent; border-color: var(--line); }

/* Narrow screens: sidebar becomes a top bar */
@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
    .sidebar {
        position: sticky; height: auto; z-index: 10; flex-direction: row; flex-wrap: wrap; align-items: center;
        gap: 8px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line);
    }
    .brand { padding: 0; flex: 1; }
    .brand-name span { display: none; }
    .account { order: 2; padding: 0; border: 0; }
    .account-name { display: none; }
    .nav { order: 3; flex-basis: 100%; display: flex; gap: 2px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
    .nav-group { display: contents; }
    .nav-label { display: none; }
    .nav a { white-space: nowrap; padding: 7px 10px; }
    .content { padding: 20px 16px 40px; }
    h1 { font-size: 30px; }
    .card { padding: 18px; }
    .card > .table-wrap.flush { margin: 0 -18px -18px; }
}

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--line-strong); color: var(--ink); }
.stat-label { font-size: 12px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--serif); font-size: 34px; line-height: 1.1; }
.stat-row { display: flex; flex-wrap: wrap; gap: 12px 40px; margin-bottom: 20px; }
.stat-row > div { display: flex; flex-direction: column; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-bottom: 1px; border-bottom: 1px solid var(--line); }
.chart span { flex: 1; min-width: 2px; background: var(--clay); border-radius: 3px 3px 0 0; }
.chart span:hover { background: var(--accent); }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; margin-top: 6px; }
.health { display: grid; grid-template-columns: max-content 1fr; gap: 12px 24px; margin: 0; }
.health dt { color: var(--muted); }
.health dd { margin: 0; }
.warn-text { color: var(--warn); font-size: 13px; margin-top: 4px; }
.meter { height: 6px; max-width: 260px; margin-top: 6px; background: var(--sand); border-radius: var(--pill); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
@media (max-width: 560px) { .health { grid-template-columns: 1fr; gap: 2px 0; } .health dd { margin-bottom: 10px; } }
