:root {
  --brand: #2DA9DE;
  --brand-600: #1c8fc2;
  --brand-700: #16739d;
  --brand-50: #eaf6fc;
  --brand-100: #d2ecf8;
  --ink: #132232;
  --ink-2: #3f4f63;
  --muted: #738195;
  --line: #e3e8ee;
  --line-2: #eef2f6;
  --bg: #f4f6f9;
  --card: #ffffff;
  --green: #12804f;
  --green-bg: #e6f5ed;
  --red: #c73434;
  --red-bg: #fcebeb;
  --amber: #a86a12;
  --amber-bg: #fdf3e1;
  --violet: #6b4fc8;
  --violet-bg: #efeafc;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(19, 34, 50, .06), 0 1px 3px rgba(19, 34, 50, .05);
  --shadow-lg: 0 12px 40px rgba(19, 34, 50, .18);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { height: 16px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: #f7f9fb; border-color: #d4dbe3; text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-bg); border-color: #f1c5c5; }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* forms */
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13px; color: var(--ink-2); }
label.field .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid #d5dce4; border-radius: var(--radius-sm);
  font: inherit; color: var(--ink); background: #fff; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; flex: none; }
label.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
label.check input { margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-h h2 { font-size: 15px; }
.card-b { padding: 18px; }
.card + .card { margin-top: 16px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.blue { background: var(--brand-50); color: var(--brand-700); }
.pill.violet { background: var(--violet-bg); color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b8c2cd; display: inline-block; flex: none; }
.dot.on { background: #1fb36b; box-shadow: 0 0 0 3px rgba(31, 179, 107, .18); }
.dot.off { background: #d24b4b; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: none; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f9fbfd; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 38, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 1000; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-h h2 { flex: 1; font-size: 16px; }
.modal-b { padding: 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line-2); background: #fafbfc; border-radius: 0 0 12px 12px; }

/* toast */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 380px; animation: toastIn .18s ease-out; white-space: pre-line; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.alert { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; border: 1px solid; }
.alert.warn { background: var(--amber-bg); border-color: #f2dcb2; color: #7a4d0c; }
.alert.err { background: var(--red-bg); border-color: #f3c9c9; color: #8f2424; }
.alert.info { background: var(--brand-50); border-color: var(--brand-100); color: #135d80; }
.alert.ok { background: var(--green-bg); border-color: #bfe5cf; color: #0d5e3a; }

.spin { width: 18px; height: 18px; border: 2px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 48px; display: flex; justify-content: center; }

.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -.01em; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; flex: none; }
.logo-mark svg { width: 18px; height: 18px; }
.logo small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
