:root {
  --bg: #f4f5f7; --surface: #fff; --surface-2: #fafbfc; --line: #e2e5ea; --line-2: #eef0f3;
  --ink: #14181f; --muted: #4a5260; --accent: #1f5fd1; --accent-ink: #fff; --accent-hover: #174a9f;
  --ok-bg: #e3f2e8; --ok: #1e6b3a; --warn-bg: #fcebdc; --warn: #8a3300; --info-bg: #e1ebfb; --info: #174a9f;
  --neutral-bg: #eceef1; --neutral: #3a414d; --hl-bg: #fff4cc; --hl: #5a4300;
  --radius: 12px; --font: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.2; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 15px; }
a { color: var(--accent); } a:hover { color: var(--accent-hover); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid #c9ced6; background: var(--surface); color: var(--ink); font: 600 14px var(--font);
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--warn); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; text-decoration: underline; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #9cbcf2; outline-offset: 1px; }

label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
input, select, textarea { font: 400 14px var(--font); color: var(--ink); background: #fff; border: 1px solid #c9ced6;
  border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }

.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; background: var(--neutral-bg); color: var(--neutral); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.hl { background: var(--hl-bg); color: var(--hl); }
.badge.net { background: #ddf1ee; color: #0b5a53; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; transition: all .2s;
  pointer-events: none; z-index: 1000; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--warn); }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; }
.toast-btn { border: 0; background: none; color: #9cbcf2; font: 700 14px var(--font); cursor: pointer; padding: 6px 4px; min-height: 32px; text-decoration: underline; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(20, 24, 31, 0.45); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dlg-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.empty { border: 2px dashed #c9ced6; border-radius: 10px; padding: 24px; text-align: center; color: var(--muted); }
.sig-img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
