:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f9fafb;
  --card: #ffffff;
  --brand: #1f2937;
  --ok: #047857;
  --bad: #b91c1c;
  --warn: #b45309;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 Arial, Helvetica, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 12px; }
header.bar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
header.bar strong { font-size: 16px; }
header.bar .spacer { flex: 1; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--muted); }
nav.tabs button.active { background: var(--bg); color: var(--ink); font-weight: bold; }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 420px; margin: 80px auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; background: #fff; color: var(--ink); }
textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
button.primary, button.secondary, button.danger { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--brand); font: inherit; cursor: pointer; }
button.primary { background: var(--brand); color: #fff; }
button.secondary { background: #fff; color: var(--brand); }
button.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
button.small { padding: 4px 9px; font-size: 13px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
td small { display: block; color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #e5e7eb; }
.badge.sent { background: #d1fae5; color: var(--ok); }
.badge.failed { background: #fee2e2; color: var(--bad); }
.badge.sending { background: #fef3c7; color: var(--warn); }
.msg { font-size: 14px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--bad); }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 10px 12px; font-size: 14px; margin-bottom: 16px; }
.note.good { background: #ecfdf5; border-color: #a7f3d0; }
pre { margin: 0; white-space: pre-wrap; font: inherit; }
.overlay { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 10; }
.modal { position: relative; background: #fff; border-radius: 8px; padding: 20px; width: 100%; max-width: 720px; }
.modal.wide { max-width: 860px; }
iframe.preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* Collapsible panels (Settings) */
.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; user-select: none; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; flex: none; }
.panel[open] > summary::before { transform: rotate(45deg); }
.panel > summary h2 { margin: 0; }
.panel[open] > summary { margin-bottom: 14px; }
.panel > summary:focus-visible { outline: 2px solid var(--muted); outline-offset: 4px; border-radius: 4px; }

.sig-editor { min-height: 110px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; font: 15px/1.5 Arial, Helvetica, sans-serif; color: #374151; overflow: auto; }
.sig-editor:focus { outline: 2px solid #1f2937; outline-offset: 0; }
.sig-editor img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
.sig-toolbar { margin-bottom: 6px; }
.sig-source { min-height: 140px; font-family: monospace; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.mode-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-size: 12px; font-weight: bold; letter-spacing: .03em; }
button.mode-badge { cursor: pointer; }
.mode-badge.stub { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.mode-badge.live { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.mode-badge.off { background: #e5e7eb; color: #4b5563; border-color: #d1d5db; }
.sig-ctl { width: auto; padding: 4px 6px; font-size: 13px; }
.sig-colorwrap { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 13px; font-weight: bold; color: var(--ink); cursor: pointer; }
.sig-color { width: 30px; height: 28px; padding: 0; border: 1px solid #d1d5db; border-radius: 6px; background: none; cursor: pointer; }
.painter { display: inline-flex; align-items: center; }
.painter.on { background: #fef3c7; border-color: #fcd34d; }
.sig-editor.painting { cursor: crosshair; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-weight: bold; color: var(--ink); cursor: pointer; }
.inline-check { width: 18px; height: 18px; margin: 0; }
.sig-view { max-width: 640px; overflow: auto; font: 15px/1.5 Arial, Helvetica, sans-serif; color: #374151; }
.sig-view img { max-width: 100%; height: auto; }
.sig-view a { color: #1d4ed8; }
.sig-view pre { margin: 0; white-space: pre-wrap; font: inherit; }
.delivery { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.delivery ul { margin: 6px 0 0 18px; padding: 0; }
.badge.scanning { background: #dbeafe; color: #1e40af; animation: pulse 1.6s ease-in-out infinite; }
.badge.scan_failed { background: #fee2e2; color: var(--bad); }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .badge.scanning { animation: none; } }
label.check { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
label.check input { width: auto; margin: 0; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.table-head select { width: auto; }
.table-scroll { overflow-x: auto; }
tr.latest td { background: #f0fdf4; }
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: 12px; align-items: end; margin: 14px 0 8px; }
.filters .f-end { align-self: end; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters .f-search { grid-column: span 2; } }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
.report-table td { white-space: nowrap; font-size: 13px; }
.row-actions select { width: auto; }
