:root {
  --navy: #071a36;
  --navy-2: #0b2851;
  --blue: #0d6efd;
  --cyan: #14b8d4;
  --green: #0f9f6e;
  --red: #d93852;
  --violet: #7857d8;
  --amber: #cc8613;
  --ink: #14213a;
  --muted: #667085;
  --line: #dce4ef;
  --surface: #ffffff;
  --bg: #f3f7fc;
  --shadow: 0 16px 40px rgba(7, 26, 54, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: #075fc8; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 30;
  display: flex; flex-direction: column; padding: 24px 18px;
  color: #fff; background:
    radial-gradient(circle at 20% 0%, rgba(20,184,212,.25), transparent 28%),
    linear-gradient(160deg, var(--navy-2), var(--navy));
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.12rem; }
.brand small { color: #a8bedc; font-size: .78rem; }
.brand-mark {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 42px; height: 42px; border-radius: 14px;
  background: linear-gradient(135deg, #16c4de, #0876ef);
  color: white; font-weight: 900; box-shadow: 0 8px 20px rgba(20,184,212,.25);
}
.brand-mark.large { width: 64px; height: 64px; border-radius: 20px; font-size: 1.5rem; }
.nav { display: grid; gap: 5px; overflow-y: auto; padding-right: 2px; }
.nav a {
  display: flex; align-items: center; min-height: 42px; padding: 9px 13px;
  border-radius: 11px; color: #cbd9eb; font-size: .92rem; font-weight: 600;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { color: #fff; background: linear-gradient(90deg, rgba(13,110,253,.65), rgba(20,184,212,.35)); }
.sidebar-footer { margin-top: auto; padding: 20px 9px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer a { display: block; overflow: hidden; color: #dce9f9; font-size: .78rem; text-overflow: ellipsis; }
.link-button { padding: 7px 0 0; border: 0; color: #9fb3ce; background: none; font-size: .8rem; }
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 18px;
  min-height: 92px; padding: 18px clamp(20px, 4vw, 50px);
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.82);
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 0; font-size: clamp(1.45rem, 2.4vw, 2rem); letter-spacing: -.03em; }
.eyebrow { margin: 0 0 2px; color: #1685a5; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.private-badge { margin-left: auto; padding: 7px 12px; border: 1px solid #cde2f7; border-radius: 999px; color: #1f5c94; background: #eef7ff; font-size: .78rem; font-weight: 800; }
.menu-toggle { display: none; border: 0; background: transparent; color: var(--navy); font-size: 1.5rem; }
.content { display: grid; gap: 22px; padding: 30px clamp(20px, 4vw, 50px) 50px; }
.footer { padding: 18px 30px 28px; color: #8490a2; text-align: center; font-size: .78rem; }
.flash { margin: 22px clamp(20px, 4vw, 50px) 0; padding: 13px 16px; border-radius: 12px; font-weight: 650; }
.flash-success { color: #087553; background: #e9fbf4; border: 1px solid #bcebd8; }
.flash-error { color: #a32439; background: #fff0f2; border: 1px solid #f2c7ce; }
.panel {
  min-width: 0; padding: clamp(20px, 3vw, 28px);
  border: 1px solid rgba(220,228,239,.9); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 18px; letter-spacing: -.025em; }
.panel h3 { margin: 24px 0 10px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-head h2 { margin: 0; }
.panel-head.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 22px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.detail-grid { grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); }
.align-start { align-items: start; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; }
.stat-card {
  position: relative; overflow: hidden; min-height: 128px; padding: 22px;
  border: 1px solid rgba(255,255,255,.3); border-radius: 17px; color: white;
  box-shadow: var(--shadow);
}
.stat-card::after { content:""; position:absolute; width: 110px; height:110px; right:-35px; bottom:-45px; border: 24px solid rgba(255,255,255,.12); border-radius:50%; }
.stat-card span, .stat-card strong { display:block; position:relative; z-index:1; }
.stat-card span { opacity:.86; font-size:.82rem; font-weight:700; }
.stat-card strong { margin-top:12px; font-size:2.35rem; line-height:1; }
.stat-card.blue { background: linear-gradient(135deg,#1164d7,#159cc3); }
.stat-card.red { background: linear-gradient(135deg,#c83250,#ef6c68); }
.stat-card.green { background: linear-gradient(135deg,#07805c,#27b78a); }
.stat-card.violet { background: linear-gradient(135deg,#6544c5,#9c72ed); }
.health-list, .compact-list { display: grid; gap: 10px; }
.health-list > div { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid #edf1f6; }
.compact-list > div { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px; padding:11px 0; border-bottom:1px solid #edf1f6; }
.compact-list small { color:var(--muted); text-align:right; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background:#a8b1bf; box-shadow:0 0 0 4px rgba(168,177,191,.15); }
.status-dot.large { display:inline-block; width:17px; height:17px; box-shadow:0 0 0 7px rgba(168,177,191,.15); }
.status-dot.ok { background:var(--green); box-shadow:0 0 0 4px rgba(15,159,110,.15); }
.status-dot.warn { background:var(--amber); box-shadow:0 0 0 4px rgba(204,134,19,.15); }
.status-dot.bad { background:var(--red); box-shadow:0 0 0 4px rgba(217,56,82,.15); }
.quick-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:12px; }
.quick-grid a { display:grid; place-items:center; min-height:74px; padding:12px; border:1px solid #d7e5f4; border-radius:13px; color:#114f8d; background:#f5faff; font-weight:750; text-align:center; }
.quick-grid a:hover { border-color:#8fc5f1; background:#eaf6ff; text-decoration:none; }
.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:.88rem; }
th { padding:10px 12px; color:#718096; font-size:.7rem; letter-spacing:.08em; text-align:left; text-transform:uppercase; border-bottom:1px solid var(--line); }
td { padding:14px 12px; vertical-align:middle; border-bottom:1px solid #edf1f6; }
td small { display:block; margin-top:3px; color:var(--muted); }
tbody tr:hover { background:#f8fbff; }
.badge { display:inline-flex; align-items:center; padding:4px 9px; border-radius:999px; color:#475467; background:#eef2f6; font-size:.68rem; font-weight:800; text-transform:uppercase; white-space:nowrap; }
.severity-critical, .status-failed { color:#a9233a; background:#ffe7eb; }
.severity-important, .status-retry, .status-queued, .status-scheduled { color:#985e06; background:#fff3d4; }
.severity-info, .status-new, .status-draft { color:#175b98; background:#e8f3ff; }
.status-sent, .status-published, .status-won, .status-connected { color:#087553; background:#dff8ee; }
.status-read, .status-archived, .status-lost { color:#596579; background:#edf0f4; }
.status-publishing, .status-sending, .status-qualified, .status-contacted { color:#6040ac; background:#efe9ff; }
.button {
  display:inline-flex; align-items:center; justify-content:center; min-height:42px; padding:9px 16px;
  border:1px solid transparent; border-radius:11px; font-weight:750; text-decoration:none;
  transition:transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform:translateY(-1px); text-decoration:none; }
.button.primary { color:#fff; background:linear-gradient(135deg,#0879e8,#10a7c4); box-shadow:0 8px 18px rgba(13,110,253,.18); }
.button.secondary { color:#284866; border-color:#ccdae8; background:#f4f8fc; }
.button.success { color:#fff; background:var(--green); }
.button.danger { color:#a32439; border-color:#efc5cc; background:#fff3f5; }
.button.tiny { min-height:32px; padding:5px 10px; border-radius:8px; font-size:.74rem; }
.button.wide { width:100%; }
.actions { display:flex; align-items:center; flex-wrap:wrap; gap:9px; }
.actions.centered { justify-content:center; }
.inline-form { display:flex; gap:8px; }
.form-stack { display:grid; gap:15px; }
.form-stack.compact { margin-top:15px; gap:11px; }
label { display:grid; gap:6px; color:#37475b; font-size:.82rem; font-weight:750; }
label small { color:var(--muted); font-weight:500; }
input, select, textarea {
  width:100%; min-height:44px; padding:10px 12px; border:1px solid #cdd8e5; border-radius:10px;
  outline:none; color:var(--ink); background:#fff;
}
textarea { resize:vertical; }
input:focus, select:focus, textarea:focus { border-color:#52a8e9; box-shadow:0 0 0 3px rgba(13,110,253,.1); }
input[readonly] { color:#526276; background:#f4f7fa; }
fieldset { display:flex; align-items:center; flex-wrap:wrap; gap:14px; margin:0; padding:14px; border:1px solid var(--line); border-radius:11px; }
legend { padding:0 7px; color:#526276; font-size:.76rem; font-weight:800; }
.check { display:flex; grid-template-columns:auto 1fr; align-items:center; gap:7px; }
.check input { width:auto; min-height:auto; }
.form-grid { gap:14px; }
.toggle-row { display:flex; flex-wrap:wrap; gap:18px; margin-top:20px; }
.switch { display:flex; grid-template-columns:auto 1fr; align-items:center; gap:9px; }
.switch input { width:18px; min-height:18px; accent-color:var(--blue); }
.field-switch { align-self:end; min-height:44px; }
.settings-form { display:grid; gap:22px; }
.sticky-save { position:sticky; bottom:14px; z-index:10; display:flex; justify-content:flex-end; padding:12px; border:1px solid rgba(220,228,239,.8); border-radius:15px; background:rgba(255,255,255,.9); backdrop-filter:blur(10px); box-shadow:var(--shadow); }
.notice { margin-top:20px; padding:14px 16px; border-radius:12px; }
.notice strong, .notice p { display:block; margin:0; }
.notice p { margin-top:4px; font-size:.84rem; }
.notice.warning { color:#80550c; border:1px solid #f0d496; background:#fff8e7; }
.notice.success { color:#0a7253; border:1px solid #bee8d8; background:#ebfaf4; }
.steps { display:grid; gap:14px; padding:0; list-style:none; counter-reset:steps; }
.steps li { position:relative; display:grid; gap:2px; min-height:45px; padding-left:52px; counter-increment:steps; }
.steps li::before { content:counter(steps); position:absolute; left:0; display:grid; place-items:center; width:36px; height:36px; border-radius:12px; color:#fff; background:linear-gradient(135deg,#0d6efd,#16adc7); font-weight:900; }
.steps span { color:var(--muted); font-size:.85rem; }
.center { text-align:center; }
.connection-state { display:grid; justify-items:center; gap:7px; padding:15px; }
.connection-state h2 { margin:10px 0 0; text-transform:capitalize; }
.connection-state p { margin:0; }
.qr-frame { width:min(100%,390px); margin:12px auto 22px; padding:14px; border:1px solid #dce4ef; border-radius:18px; background:#fff; box-shadow:0 12px 32px rgba(7,26,54,.1); }
.qr-frame img { display:block; width:100%; }
.hidden { display:none !important; }
.generated-box { margin-top:20px; padding:16px; border:1px dashed #77b8df; border-radius:12px; background:#f1f9ff; }
.generated-box h3 { margin-top:0; }
.lead-list { display:grid; gap:11px; max-height:850px; overflow:auto; }
.lead-card { border:1px solid var(--line); border-radius:12px; background:#fbfdff; }
.lead-card summary { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:14px; cursor:pointer; }
.lead-card summary span:first-child { display:grid; }
.lead-card summary small { color:var(--muted); }
.lead-card form { padding:0 14px 16px; }
.details { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.details > div { padding:12px; border:1px solid #e2e8f0; border-radius:10px; background:#fafcff; }
.details dt { color:var(--muted); font-size:.7rem; font-weight:800; text-transform:uppercase; }
.details dd { margin:4px 0 0; overflow-wrap:anywhere; font-weight:650; }
.message-box { padding:16px; border-left:4px solid var(--cyan); border-radius:0 10px 10px 0; background:#f2f9fc; }
.json { overflow:auto; max-height:460px; padding:16px; border-radius:12px; color:#cfddf2; background:#091a31; font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace; white-space:pre-wrap; word-break:break-word; }
.copy-field { margin:15px 0; }
.copy-field > div { display:grid; grid-template-columns:1fr auto; gap:8px; }
.back-row { margin-bottom:-8px; }
.muted { color:var(--muted); }
.error-text { color:#b12a40 !important; }
.empty { padding:24px; color:#8290a4; text-align:center; }
.narrow { max-width:650px; }
.error-panel { display:grid; justify-items:start; max-width:720px; }
.error-code { color:#c8d9eb; font-size:5rem; font-weight:950; line-height:1; }
.login-body {
  display:grid; min-height:100vh; place-items:center; padding:24px;
  background:radial-gradient(circle at 30% 10%,rgba(20,184,212,.28),transparent 30%),linear-gradient(145deg,#061831,#0a2e5b);
}
.login-card { width:min(100%,450px); padding:36px; border:1px solid rgba(255,255,255,.5); border-radius:24px; background:rgba(255,255,255,.97); box-shadow:0 30px 80px rgba(0,0,0,.28); }
.login-brand { margin-bottom:25px; text-align:center; }
.login-brand .brand-mark { margin:auto; }
.login-brand h1 { margin:12px 0 5px; font-size:2rem; letter-spacing:-.04em; }
.login-brand p:last-child { margin:0; color:var(--muted); }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns:repeat(2,1fr); }
  .grid.detail-grid { grid-template-columns:1fr; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:fixed; left:-280px; width:260px; transition:left .2s ease; box-shadow:18px 0 50px rgba(0,0,0,.2); }
  .sidebar.open { left:0; }
  .menu-toggle { display:block; }
  .grid.two { grid-template-columns:1fr; }
  .topbar { min-height:78px; }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns:1fr; }
  .content { padding:20px 14px 40px; }
  .topbar { padding:15px 14px; }
  .private-badge { display:none; }
  .panel { padding:18px; border-radius:15px; }
  .details { grid-template-columns:1fr; }
  .quick-grid { grid-template-columns:1fr; }
  .login-card { padding:25px; }
}
