:root {
  --bg: #f7f7f8; --surface: #fff; --text: #1d1d1f; --muted: #6e6e73; --border: #e3e3e6;
  --accent: #4f46e5; --accent-text: #fff; --ok: #e8f6ec; --warn: #fdf5dc; --bad: #fdeaea; --none: #f2f2f4;
  --ok-text: #1b6b34; --bad-text: #a21d1d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416; --surface: #1d1d20; --text: #ececf0; --muted: #9a9aa2; --border: #303036;
    --accent: #8b85ff; --accent-text: #111; --ok: #17311f; --warn: #3a3214; --bad: #3d1a1a; --none: #232327;
    --ok-text: #7fd69a; --bad-text: #ff9a9a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 .75rem; }
.top { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; color: var(--text); }
.top nav { display: flex; gap: 1rem; flex-wrap: wrap; flex: 1; }
.top nav a { color: var(--muted); }
.top nav a.active { color: var(--text); font-weight: 600; }
.logout { display: flex; gap: .75rem; align-items: center; margin: 0; }
main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }
.muted { color: var(--muted); }
.flash { background: var(--ok); color: var(--ok-text); padding: .6rem .9rem; border-radius: 8px; }
.error { background: var(--bad); color: var(--bad-text); padding: .6rem .9rem; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.active td:first-child { box-shadow: inset 3px 0 #2fa35a; }
tr.expiring td:first-child { box-shadow: inset 3px 0 #d6a51c; }
tr.expired td:first-child { box-shadow: inset 3px 0 #d64545; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .8rem; background: var(--none); }
.badge.active, .badge.sent, .badge.done { background: var(--ok); color: var(--ok-text); }
.badge.expiring, .badge.pending { background: var(--warn); }
.badge.expired, .badge.failed, .badge.blocked { background: var(--bad); color: var(--bad-text); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.card .value { font-size: 1.75rem; font-weight: 600; }
.card .label { color: var(--muted); font-size: .85rem; }
form { margin: 0; }
label { display: block; margin-bottom: .75rem; font-size: .9rem; color: var(--muted); }
input, textarea, select { display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
textarea { min-height: 12rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
button { padding: .5rem 1rem; font: inherit; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
button.secondary { background: var(--none); color: var(--text); border: 1px solid var(--border); }
button.link { background: none; color: var(--accent); padding: 0; }
.inline { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.inline label { margin: 0; }
.inline input, .inline select { width: auto; }
.filters { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.filters a.active { font-weight: 600; color: var(--text); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-size: .85rem; }
.login { max-width: 360px; margin: 10vh auto; background: var(--surface); padding: 2rem; border: 1px solid var(--border); border-radius: 12px; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }
@media (max-width: 700px) {
  .hide-sm { display: none; }
  main { padding: 1rem; }
  .top { padding: .75rem 1rem; gap: .5rem 1rem; }
  .top nav { flex-basis: 100%; order: 3; gap: .25rem .9rem; }
  /* Wide tables scroll sideways inside themselves instead of widening the page. */
  table { display: block; overflow-x: auto; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  pre, code { word-break: break-word; }
}
/* Utility classes (inline style attributes are blocked by the Content Security Policy). */
.mt0 { margin-top: 0; }
.mt { margin-top: .75rem; }
.mt-small { margin-top: .4rem; }
.grow { flex: 1; }
.grow input { width: 100%; }
.search { margin-bottom: 1rem; }
.w6 { width: 6rem !important; }
.narrow { max-width: 640px; }
.hint { font-size: .85rem; }
.field-error { display: block; margin-top: .3rem; }
textarea.short { min-height: 6rem; }
pre.preview { font-family: inherit; font-size: .95rem; }
