:root {
  --bg: #f5f7fa;
  --panel: #fff;
  --ink: #172026;
  --muted: #66737f;
  --line: #d8e0e7;
  --accent: #0f766e;
  --danger: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; font-weight: 700; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 24px; }
.topbar nav { display: flex; align-items: center; gap: 10px; }
.topbar form { margin: 0; }
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 24px; background: #eef3f7; border-bottom: 1px solid var(--line); }
.admin-nav a { border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 8px 11px; }
.admin-nav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.admin-shell { width: min(1280px, 100%); margin: 0 auto; padding: 24px; }
.admin-shell.narrow { width: min(760px, 100%); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card, .card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: 0 12px 30px rgba(23, 32, 38, .08); }
.card + .card { margin-top: 16px; }
.auth-card { width: min(420px, 100%); }
h1, h2 { margin-top: 0; }
label { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); font-weight: 700; }
label.inline { display: flex; align-items: center; color: var(--ink); }
label.inline input { width: auto; min-height: auto; }
input, button, .button, select { min-height: 42px; border-radius: 8px; border: 1px solid var(--line); padding: 0 12px; font: inherit; }
input, select { width: 100%; background: #fff; color: var(--ink); }
textarea { width: 100%; border-radius: 8px; border: 1px solid var(--line); padding: 10px 12px; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); background: #fff; resize: vertical; }
button, .button { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; border-color: var(--accent); cursor: pointer; }
button.danger { background: var(--danger); border-color: var(--danger); }
.link-button { display: inline; min-height: 0; border: 0; border-radius: 0; padding: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.inline-form { display: inline; margin: 0; }
.inline-form button { min-height: 34px; padding: 0 10px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.button.secondary { background: #fff; color: var(--accent); }
.alert { padding: 12px; border: 1px solid #f5b5ae; background: #fff0ee; color: var(--danger); border-radius: 8px; margin-bottom: 14px; }
.muted { color: var(--muted); }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef3f7; font-size: 13px; color: var(--muted); }
.settings-card th { width: 280px; }
.pill { display: inline-flex; min-height: 24px; align-items: center; border-radius: 999px; background: #e6f4f1; color: var(--accent); padding: 0 9px; font-size: 12px; font-weight: 800; }
.pill-processed { background: #e6f4f1; color: #0f766e; }
.pill-pending, .pill-processing { background: #fff7df; color: #946200; }
.pill-failed { background: #fff0ee; color: var(--danger); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.metric strong { display: block; font-size: 26px; }
.metric span { color: var(--muted); }
.system-health-card { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(460px, 1.2fr); gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.system-health-card h2 { margin-bottom: 8px; }
.system-health-card p { margin: 6px 0; }
.health-counts { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 8px; min-width: 460px; }
.health-counts span { display: block; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; padding: 10px; color: var(--muted); }
.health-counts strong { display: block; color: var(--ink); font-size: 22px; }
.health-action { position: relative; }
.health-action .inline-form { display: block; margin-top: 8px; }
.mini-button { min-height: 28px; border-radius: 7px; padding: 0 9px; font-size: 12px; }
.health-detail { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; }
.health-detail h3 { margin: 0 0 6px; font-size: 16px; }
.drilldown { margin-top: 10px; }
.drilldown summary { color: var(--accent); cursor: pointer; font-weight: 800; }
.compact-table { margin-top: 10px; font-size: 13px; }
.compact-table th, .compact-table td { padding: 8px; }
.webhook-error { border-left: 3px solid var(--danger); background: #fff0ee; color: var(--danger); padding: 8px 10px; border-radius: 6px; }
.public-link-card { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.public-link-card > div:first-child { flex: 1; min-width: 0; }
.public-link-card h2 { margin-bottom: 6px; }
.copy-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); }
.export-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.export-card h2 { margin-bottom: 6px; }
.export-card p { margin: 4px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.filters a { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; color: var(--ink); }
.filters a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
code { background: #edf2f7; padding: 2px 5px; border-radius: 4px; }
@media (max-width: 820px) {
  .topbar, .topbar nav { align-items: stretch; flex-direction: column; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .system-health-card { grid-template-columns: 1fr; }
  .health-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; width: 100%; }
  .public-link-card { align-items: stretch; flex-direction: column; }
  .export-card { align-items: stretch; flex-direction: column; }
  table { display: block; overflow-x: auto; }
}
