:root {
  --ink: #0d0f3f;
  --ink-2: #1a1d5c;
  --blue: #0b5fe0;
  --blue-soft: #e8f0fd;
  --line: #dde3ee;
  --bg: #f4f6fb;
  --text: #1b1f3b;
  --muted: #667089;
  --ok: #0f8a5f;
  --danger: #c93a3a;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Figtree", system-ui, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid #7fb0ff; outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #cfd5f5; padding: 24px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: block; padding: 0 10px 22px; }
.side .brand img { width: 150px; filter: brightness(0) invert(1); }
.side nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 8px; color: #cfd5f5; font-weight: 500; }
.side nav a:hover { background: var(--ink-2); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--blue); color: #fff; }
.side nav .sep { height: 1px; background: #2a2e75; margin: 14px 8px; }
.side .badge { background: #ffb020; color: #3a2600; border-radius: 99px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.side .out { margin-top: 18px; padding: 0 4px; }
.side .out button { width: 100%; }

.main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1100px; width: 100%; }
.main h1 { font-size: 26px; margin: 0 0 4px; color: var(--ink); }
.main .lead { color: var(--muted); margin: 0 0 24px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 28px; }
.stat { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: var(--text); }
.stat:hover { border-color: var(--blue); text-decoration: none; }
.stat b { display: block; font-size: 34px; color: var(--ink); line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f9fafd; font-size: 13px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.actions { white-space: nowrap; text-align: right; }
.unread td { font-weight: 600; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 8px; padding: 10px 16px; background: var(--blue); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: #094db8; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #f0c9c9; }
.btn.danger:hover { background: #fdeeee; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.side .btn { background: var(--ink-2); }

label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=url], input[type=number], input[type=date], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #c8d0e2; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid #cfe0fc; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.thumb { max-width: 180px; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: 8px; }
.form-card { max-width: 720px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 20px 20px 4px; margin: 0 0 20px; background: #fff; }
legend { font-weight: 700; padding: 0 8px; color: var(--ink); }

.flash { background: #e6f6ee; color: #0b5f41; border: 1px solid #b6e3cd; padding: 11px 14px; border-radius: 8px; margin-bottom: 18px; }
.err { color: var(--danger); font-size: 13px; margin-top: 4px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.pill.on { background: #e6f6ee; color: var(--ok); }
.pill.off { background: #eef0f6; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #1a2a8a 0, var(--ink) 55%); }
.login .card { width: 100%; max-width: 400px; padding: 32px; }
.login img { width: 200px; margin-bottom: 20px; }
.login h1 { font-size: 22px; margin: 0 0 20px; }

.msg-body { white-space: pre-wrap; background: #f9fafd; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 12px; }
dl.meta { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; margin: 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .side nav .sep { display: none; }
}
