:root {
    --ink: #111827;
    --ink-soft: #344054;
    --muted: #667085;
    --bg: #f4f7fb;
    --surface: #fff;
    --line: #dfe5ee;
    --line-strong: #cbd5e1;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --teal: #0f9f8f;
    --nav: #111827;
    --nav-soft: #1f2937;
    --ok: #087a55;
    --ok-bg: #dff7ec;
    --bad: #b42318;
    --bad-bg: #fee4e2;
    --warn: #9a6700;
    --warn-bg: #fff0c2;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 22px; margin: 0; border-bottom: 1px solid rgba(255, 255, 255, .1); font-size: 19px; font-weight: 800; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: #fff; color: var(--nav); font-size: 13px; font-weight: 900; }
.nav { padding-top: 18px; display: flex; flex: 1; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin: 0; border-radius: 7px; color: #d0d5dd; font-weight: 650; transition: background .15s, color .15s; }
.nav a:hover { background: var(--nav-soft); color: #fff; text-decoration: none; }
.nav a.active { background: #263b66; color: #fff; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: #64748b; flex: 0 0 auto; }
.nav a.active .nav-dot { background: #60a5fa; box-shadow: 0 0 0 3px rgba(96, 165, 250, .18); }
.nav-exit { margin-top: auto !important; }
.content { min-width: 0; padding: 24px 28px 42px; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin: 0 0 20px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 25px; margin: 0; line-height: 1.25; }
.top-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.menu-toggle { display: none; }
h1, h2, h3 { letter-spacing: 0; }
h2 { font-size: 18px; margin: 0 0 16px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.grid .card { margin: 0; }
.metric { font-size: 27px; line-height: 1.15; font-weight: 800; margin-top: 8px; color: var(--ink); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.row > .card { margin-bottom: 0; }
label { display: block; font-size: 12px; font-weight: 750; color: var(--ink-soft); margin: 12px 0 6px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); font: inherit; outline: none; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #7aa7f8; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
input[readonly] { background: #f8fafc; color: var(--ink-soft); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 16px; padding: 0; accent-color: var(--accent); flex: 0 0 auto; }
button, .btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 6px; padding: 8px 13px; background: var(--accent); color: #fff; font: inherit; font-weight: 750; line-height: 1; cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.secondary { background: #fff; border-color: var(--line-strong); color: var(--ink-soft); }
.btn.secondary:hover { background: #f8fafc; color: var(--ink); }
.btn.bad { background: var(--bad); }
.btn.bad:hover { background: #912018; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #066548; }
.actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.actions form { margin: 0; }
.actions b { overflow-wrap: anywhere; }
.table-scroll { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.table-scroll table { border: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 720px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 11px; text-transform: uppercase; font-weight: 800; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdff; }
.pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; background: #eef2f6; color: #475467; }
.pill.active { background: var(--ok-bg); color: var(--ok); }
.pill.blocked { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.flash { padding: 12px 14px; border: 1px solid #a6e7cf; border-radius: 7px; margin-bottom: 16px; background: #ecfdf5; color: #05603a; }
.flash.err { border-color: #f8b4b0; background: #fff4f3; color: #9c1c13; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: radial-gradient(circle at 15% 10%, #e8f1ff 0, transparent 32%), var(--bg); }
.login .card { width: min(440px, 100%); padding: 28px; }
.login h1 { font-size: 25px; margin: 0 0 4px; }
.integration-banner { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 14px 16px; border: 1px solid #a6e7cf; border-left: 4px solid var(--teal); background: #f0fdf9; border-radius: 7px; margin-bottom: 16px; }
.integration-banner strong { display: block; }
.code-field { display: flex; gap: 8px; align-items: center; }
.code-field input { font-family: Consolas, monospace; }
.code-field .btn { flex: 0 0 auto; }
.status-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.config-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-bottom: 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.config-summary > div { padding: 12px 14px; background: #f8fafc; }
.config-summary span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 700; }
.config-summary strong { display: block; font-family: Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.config-alert { display: flex; flex-direction: column; gap: 2px; padding: 11px 13px; margin-bottom: 14px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 7px; }
.config-alert.success { border-color: #a6e7cf; border-left-color: var(--ok); background: #f0fdf9; color: #05603a; }
.config-alert.error { border-color: #f8b4b0; border-left-color: var(--bad); background: #fff4f3; color: #9c1c13; }
.form-actions { margin-top: 18px; }
.test-message-form { display: grid; grid-template-columns: minmax(220px, 420px) auto; gap: 10px; align-items: end; padding: 14px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; }
.test-message-form label { margin-top: 0; }
.test-message-form button { min-height: 40px; }

@media (max-width: 1100px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .content { padding: 22px; }
    .top-meta { display: none; }
}

@media (max-width: 760px) {
    .layout { display: block; }
    .sidebar { position: fixed; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0, 0, 0, .2); }
    body.nav-open .sidebar { transform: translateX(0); }
    .content { padding: 16px; }
    .top { align-items: center; }
    .top h1 { font-size: 22px; }
    .menu-toggle { display: inline-flex; background: #fff; border-color: var(--line-strong); color: var(--ink); min-width: 42px; }
    .row { grid-template-columns: 1fr; }
    .grid { grid-template-columns: 1fr 1fr; }
    .card { padding: 15px; }
    .integration-banner { align-items: flex-start; flex-direction: column; }
    .code-field { align-items: stretch; flex-direction: column; }
    .code-field .btn { width: 100%; }
    .config-summary { grid-template-columns: 1fr; }
    .test-message-form { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
    .grid { grid-template-columns: 1fr; }
    .content { padding: 12px; }
    .top { margin-bottom: 14px; }
    .login { padding: 14px; }
    .login .card { padding: 21px; }
    .actions { align-items: stretch; }
    .actions form, .actions .btn, .actions button { width: 100%; }
}
