:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d232b; --muted: #6b7480; --line: #e3e6ea;
  --accent: #2f5bea; --accent-ink: #fff; --danger: #c93636; --ok: #1f8a4c; --warn: #b7791f;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --card: #1c2027; --text: #e7eaee; --muted: #9aa3ad; --line: #2c323b; --accent: #5b82ff; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "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: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); }
.logo { color: var(--accent); }
.topbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topbar nav a:not(.btn) { color: var(--text); }
.container { max-width: 960px; margin: 2rem auto; padding: 0 1.25rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.center { text-align: center; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.field { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .3rem; }
.field label { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }
.hint { color: var(--muted); }
.err { color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1.4fr; gap: 0 1rem; }
@media (max-width: 680px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 220px; margin-bottom: 0; }
.check { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
fieldset.when { border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
fieldset.when legend { font-weight: 600; padding: 0 .3rem; }
.radios { display: flex; gap: 1.5rem; margin-bottom: .75rem; }
.radios ul { list-style: none; display: flex; gap: 1.5rem; padding: 0; margin: 0; }
details { margin-bottom: 1rem; }
summary { cursor: pointer; color: var(--accent); margin-bottom: .5rem; }

.btn { display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn-sm { padding: .3rem .7rem; font-size: .9rem; color: var(--accent-ink) !important; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }
button.link { background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 0; }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.actions .right { margin-left: auto; }
form.inline { display: inline; margin: 0; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #e8f6ee; border-color: #b4e2c6; color: #145c33; }
.flash-error { background: #fdecec; border-color: #f2b8b8; color: #8a1f1f; }
.flash-warning { background: #fdf5e6; border-color: #f0d49c; color: #7a5212; }
.flash-info, .flash-message { background: #eaf0fe; border-color: #bccdfb; color: #1e3a8a; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.count { background: var(--line); border-radius: 999px; padding: 0 .45rem; font-size: .78rem; margin-left: .2rem; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 3rem; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; text-transform: capitalize; }
.badge-pending, .badge-sending { background: #eaf0fe; color: #1e3a8a; }
.badge-sent { background: #e8f6ee; color: #145c33; }
.badge-failed { background: #fdecec; color: #8a1f1f; }
.badge-cancelled { background: #eef0f2; color: #555; }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0 0 1rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; word-break: break-word; }
pre.body { white-space: pre-wrap; word-wrap: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin: 0; font-family: inherit; }
pre.body.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.qr { text-align: center; margin: 1rem 0; }
.qr img { background: #fff; border-radius: 8px; }
.secret { word-break: break-all; }
.steps { padding-left: 1.2rem; }
.secret.big { font-size: 1.25rem; letter-spacing: .08em; padding: .4rem .7rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; display: inline-block; }
ul.checks { list-style: none; padding: 0; margin: 0; columns: 2; }
ul.checks li { margin: .2rem 0; }
