:root {
    color-scheme: light;
    --bg: #f4f6fa;
    --surface: #fff;
    --ink: #171c29;
    --muted: #5c6477;
    --line: #e1e5ed;
    --accent: #224be3;
    --accent-hover: #1940cb;
    --accent-tint: #eaf0ff;
    --error: #9a2a26;
    font: 16px/1.5 system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, dl, dd { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.shell { width: min(1144px, calc(100% - 64px)); margin-inline: auto; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; gap: 32px; min-height: 72px; align-items: center; }
.brand { display: inline-flex; gap: 10px; align-items: center; font-size: 19px; font-weight: 700; letter-spacing: -.035em; }
.brand-mark {
    display: grid; width: 36px; height: 36px; place-items: center;
    border-radius: 10px; background: var(--accent); color: #fff;
}
.brand-mark svg { width: 23px; height: 23px; }
nav { display: flex; align-self: stretch; align-items: stretch; gap: 24px; }
nav a { display: flex; align-items: center; position: relative; font-size: 14px; font-weight: 550; color: var(--muted); }
nav a[aria-current="page"] { color: var(--accent); }
nav a[aria-current="page"]::after { position: absolute; inset: auto 0 -1px; height: 2px; background: var(--accent); content: ''; }
.signout { margin-left: auto; }

.main { padding: 44px 0 64px; }
.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-heading { margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: clamp(27px, 5vw, 36px); line-height: 1.18; letter-spacing: -.047em; }
h2 { font-size: 23px; line-height: 1.24; letter-spacing: -.032em; }
h3 { font-size: 16px; }

.button {
    display: inline-flex; justify-content: center; align-items: center; gap: 7px;
    min-height: 40px; padding: 7px 14px; border: 1px solid transparent;
    border-radius: 8px; white-space: nowrap; font-size: 14px; font-weight: 620;
}
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-hover); }
.button-outline { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button-outline:hover, .button-quiet:hover { background: var(--bg); }
.button-quiet { background: transparent; color: var(--muted); }
.plus { font-size: 18px; line-height: 1; }

.table-card, .empty-state { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.table-card { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
thead { background: #f9faff; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--line); font-size: 14px; text-align: left; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcff; }
.campaign-table td:last-child { width: 1%; text-align: right; }
.campaign-table th:first-child { width: 28%; }
.row-title { font-weight: 640; }
.row-title:hover { color: var(--accent); text-decoration: underline; }
code, .mono { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: .875rem; }
.url { display: block; overflow-wrap: anywhere; }
.empty-state { display: grid; place-content: center; justify-items: center; gap: 12px; min-height: 245px; font-weight: 560; }
.empty-state svg { width: 40px; height: 40px; color: var(--accent); background: var(--accent-tint); padding: 4px; border-radius: 10px; }
.error-state { display: inline-block; color: var(--error); background: #fff0ee; border-radius: 6px; padding: 4px 8px; }
.pagination { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.logs-filter {
    display: grid; grid-template-columns: minmax(0, 290px) minmax(0, 200px) auto;
    align-items: end; gap: 12px; margin-bottom: 16px;
}
.logs-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.logs-filter-actions .button { min-height: 42px; }
.logs-table time, .logs-table td:nth-child(3) { white-space: nowrap; }
.logs-table td:nth-child(3) { width: 1%; text-align: center; }
.log-job { color: var(--accent); overflow-wrap: anywhere; }
.log-job:hover { text-decoration: underline; }
.log-reason { display: block; margin-top: 4px; color: var(--muted); }
.warning-state { display: inline-block; padding: 4px 8px; border-radius: 6px; color: #855010; background: #fff4de; }

.dialog {
    width: min(680px, calc(100% - 28px)); max-height: calc(100% - 32px); padding: 0;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line);
    border-radius: 16px; box-shadow: 0 20px 64px #12193333;
}
.dialog::backdrop { background: #131d3955; backdrop-filter: blur(2px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.close {
    display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto;
    border: none; border-radius: 8px; background: transparent; color: var(--muted); font-size: 25px; line-height: 1;
}
.close:hover { background: var(--bg); color: var(--ink); }
.dialog-form { display: flex; min-height: 0; flex-direction: column; }
.dialog-body { display: grid; gap: 16px; padding: 22px 24px; }
.dialog-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 15px 24px; border-top: 1px solid var(--line); }
.dialog[open] { display: flex; flex-direction: column; }
.dialog-header, .dialog-footer { flex: 0 0 auto; }
.dialog-body { overflow-y: auto; }

.field, .rule label { display: grid; gap: 6px; min-width: 0; }
label { font-size: 14px; font-weight: 590; }
input, select, textarea {
    width: 100%; min-width: 0; color: var(--ink); border: 1px solid #cbd2df;
    border-radius: 8px; background: var(--surface); padding: 9px 10px; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #224be366; outline-offset: 1px; border-color: var(--accent); }
.routes { display: grid; gap: 11px; border-top: 1px solid var(--line); padding-top: 14px; }
.rules { display: grid; gap: 10px; }
.rules:empty { display: none; }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) minmax(64px, 125px) 36px; align-items: end; gap: 8px; }
.rule-remove { height: 42px; }
.validation, .notice { padding: 9px 12px; border-radius: 7px; font-size: 14px; overflow-wrap: anywhere; }
.validation { background: #fff0ed; color: var(--error); }
.notice { background: var(--accent-tint); color: #193da9; }
.main > .notice { margin-bottom: 16px; }
.delivery-info { display: grid; gap: 8px; }
.delivery-info div { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; font-size: 14px; }
.delivery-info dt { color: var(--muted); }
.delivery-info dd { overflow-wrap: anywhere; }

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: min(100%, 388px); background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; padding: 30px; box-shadow: 0 12px 36px #182e6410;
}
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { font-size: 28px; margin-bottom: 16px; }
.form-stack { display: grid; gap: 8px; }
.form-stack input { margin-bottom: 6px; }
.form-stack .button { margin-top: 9px; }

@media (max-width: 630px) {
    .shell { width: calc(100% - 28px); }
    .topbar-inner { gap: 0 14px; flex-wrap: wrap; padding-top: 9px; }
    .brand-mark { width: 32px; height: 32px; }
    nav { order: 3; flex-basis: 100%; min-height: 46px; gap: 20px; }
    .logs-filter { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .logs-filter-actions { grid-column: 1 / -1; }
    .main { padding-top: 27px; }
    .dialog-header, .dialog-body, .dialog-footer { padding-inline: 15px; }
    th, td { padding-inline: 10px; }
}
