:root {
    color-scheme: light;
    --ink: #172126;
    --muted: #68777f;
    --paper: #f4f5f2;
    --surface: #ffffff;
    --line: #dce1dd;
    --accent: #d9542f;
    --accent-dark: #a93a1d;
    --green: #26775c;
    --amber: #9b6a16;
    --shadow: 0 18px 45px rgba(23, 33, 38, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 12px max(24px, calc((100vw - 1180px) / 2));
    background: #172126;
    color: white;
}

.site-header .brand { color: white; font-weight: 800; letter-spacing: -.02em; }
.site-header nav { display: flex; gap: 22px; flex: 1; }
.site-header nav a { color: #dbe3e0; }
.site-header form { margin: 0; }

.page-shell { max-width: 1180px; margin: 0 auto; padding: 46px 24px 80px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.page-heading.compact { align-items: flex-start; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.page-actions form { margin: 0; }
h1, h2 { letter-spacing: -.035em; line-height: 1.1; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); margin: 4px 0 10px; }
h2 { margin: 0 0 6px; }
.eyebrow { margin: 0; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .11em; font-size: .75rem; }
.muted { color: var(--muted); }

.button {
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 15px;
    background: var(--accent);
    color: white;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.button:hover { background: var(--accent-dark); text-decoration: none; }
.button-secondary { background: transparent; border-color: #9ca8a3; color: inherit; }
.site-header .button-secondary { color: white; border-color: #65736e; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.metric-card, .panel, .form-card, .search-card, .auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.metric-card { padding: 24px; display: flex; flex-direction: column; }
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong { font-size: 2.6rem; line-height: 1; margin: 12px 0 7px; }
.panel { padding: 24px; }
.panel + .panel { margin-top: 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
.actions { text-align: right; }
.tag { display: inline-block; background: #edf0ed; border-radius: 999px; padding: 3px 9px; margin: 2px 3px 2px 0; font-size: .85rem; }

.search-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.search-card { padding: 22px; }
.search-card.is-paused { opacity: .72; }
.search-card-heading { display: flex; justify-content: space-between; gap: 18px; }
.search-card-heading h2 { margin-top: 12px; }
.search-card-heading p { margin: 0; color: var(--muted); }
.search-details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0; }
.search-details div { border-top: 1px solid var(--line); padding-top: 10px; }
.search-details dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; }
.search-details dd { margin: 3px 0 0; }
.card-actions, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.card-actions form { margin: 0; }

.status { display: inline-block; border-radius: 999px; padding: 4px 9px; background: #ecefed; font-size: .78rem; font-weight: 800; }
.status-active, .status-succeeded, .status-sent { color: var(--green); background: #e2f1eb; }
.status-paused, .status-queued, .status-unverified, .status-pending { color: var(--amber); background: #f7ecd5; }
.status-failed, .status-removed { color: #a12727; background: #f8dede; }
.status-partial, .status-unknown, .status-skipped { color: #7a5612; background: #f7ecd5; }

.listing-grid { display: grid; gap: 16px; }
.listing-card {
    display: grid;
    grid-template-columns: 190px 1fr;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.listing-card img { width: 100%; height: 100%; min-height: 190px; object-fit: cover; background: #edf0ed; }
.listing-body { padding: 22px; }
.listing-body h2 { margin: 12px 0 10px; }
.listing-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.listing-price { display: block; margin-bottom: 8px; font-size: 1.45rem; }
.pagination { display: flex; justify-content: center; gap: 18px; margin-top: 24px; }

.form-card { max-width: 760px; padding: 28px; }
.stacked-form { display: grid; gap: 20px; }
.field { display: grid; gap: 7px; }
.field > label { font-weight: 750; }
.field input:not([type="checkbox"]), .field select, .field textarea {
    width: 100%;
    border: 1px solid #bfc8c3;
    border-radius: 8px;
    padding: 11px 12px;
    background: white;
    color: var(--ink);
    font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid rgba(217, 84, 47, .18); border-color: var(--accent); }
.field small { color: var(--muted); }
.field .errorlist { color: #a12727; margin: 0; padding-left: 20px; }
.checkbox-fieldset ul { margin: 0; padding: 0; display: flex; gap: 18px; list-style: none; }
.checkbox-fieldset label { font-weight: 500; }

.messages { display: grid; gap: 8px; margin-bottom: 20px; }
.message { padding: 12px 14px; border-radius: 8px; background: #e8efec; }
.message-error { background: #f8dede; color: #8a2020; }
.message-success { background: #e2f1eb; color: #205f49; }
.message-warning { background: #f7ecd5; color: #76500e; }
.message-info { background: #e5edf2; color: #244d64; }
.empty-state { text-align: center; color: var(--muted); padding: 42px 24px; }
.auth-card { max-width: 430px; margin: 8vh auto 0; padding: 34px; }

@media (max-width: 760px) {
    .site-header { flex-wrap: wrap; gap: 14px; }
    .site-header nav { order: 3; width: 100%; }
    .page-shell { padding-top: 32px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .page-actions { width: 100%; }
    .metric-grid, .search-grid { grid-template-columns: 1fr; }
    .search-details { grid-template-columns: 1fr; }
    .listing-card { grid-template-columns: 1fr; }
    .listing-card img { max-height: 260px; }
}
