/* Blue Book panel — dizayn tizimi */
:root {
  --brand: #324dc7;
  --brand-600: #2940a8;
  --brand-700: #22358a;
  --brand-50: #eef1fc;
  --brand-100: #dde3fa;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;

  --side: #0c0e14;
  --side-2: #161a24;
  --side-line: #1f2430;
  --side-text: #a3a9b7;

  --green: #15803d;   --green-bg: #dcfce7;  --green-dot: #22c55e;
  --red: #b91c1c;     --red-bg: #fee2e2;    --red-dot: #ef4444;
  --yellow: #92400e;  --yellow-bg: #fef3c7; --yellow-dot: #f59e0b;
  --blue: #2940a8;    --blue-bg: #e0e7ff;   --blue-dot: #324dc7;
  --gray: #4b5563;    --gray-bg: #f1f2f4;   --gray-dot: #9ca3af;
  --purple: #6d28d9;  --purple-bg: #ede9fe; --purple-dot: #8b5cf6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .22);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --side-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.danger-text { color: var(--red); font-weight: 600; }
.ok-text { color: var(--green); }
[hidden] { display: none !important; }
.mt { margin-top: 10px; }
.mt-s { margin-top: 6px; }
.no-mt { margin-top: 0 !important; }
.break { overflow-wrap: anywhere; word-break: break-word; }

.ico { width: 18px; height: 18px; flex: 0 0 auto; }
.logo { width: 32px; height: 32px; flex: 0 0 auto; display: block; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; z-index: 50; border-right: 1px solid var(--side-line);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; color: #fff; text-decoration: none !important; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; font-size: 11.5px; color: var(--side-text); margin-top: 1px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--side-text);
  font-size: 13.5px; font-weight: 500; text-decoration: none !important; border: 0; background: none; width: 100%;
  cursor: pointer; font-family: inherit; text-align: left; position: relative;
}
.nav-item:hover { background: var(--side-2); color: #e5e7eb; }
.nav-item.active { background: rgba(50, 77, 199, .22); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #6b84ff; }
.nav-item.active .ico { color: #9fb0ff; }
.sidebar-foot { border-top: 1px solid var(--side-line); padding: 12px 10px 14px; }
.sidebar-foot form { margin: 0; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 12px 10px; color: #e5e7eb; font-weight: 550; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: 0 0 auto; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout:hover { color: #fca5a5; }

.main { margin-left: var(--side-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 18px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: #fff; white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--gray-dot); }
.live.on i { background: var(--green-dot); box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.live.err i { background: var(--red-dot); }
.live.err { color: var(--red); }
.icon-btn { display: none; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border); background: #fff; align-items: center; justify-content: center; color: var(--text); cursor: pointer; flex: 0 0 auto; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }
.scrim { display: none; }

.kill-banner { background: #b91c1c; color: #fff; padding: 11px 28px; font-size: 13.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kill-banner a { color: #fff; text-decoration: underline; font-weight: 600; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head .sub { color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 2px; }
.card-body { padding: 16px 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.span-2 { grid-column: span 2; }
.card.danger-zone { border-color: #fecaca; }
.card.danger-zone .card-head { background: #fff5f5; border-radius: var(--radius) var(--radius) 0 0; border-bottom-color: #fecaca; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: flex-start; text-decoration: none !important; color: inherit; transition: border-color .15s, box-shadow .15s; min-width: 0; }
a.stat:hover { border-color: var(--brand-100); box-shadow: var(--shadow-md); }
.stat-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; }
.stat-ico .ico { width: 20px; height: 20px; }
.stat-ico.green { background: var(--green-bg); color: var(--green); }
.stat-ico.blue { background: var(--blue-bg); color: var(--blue); }
.stat-ico.red { background: var(--red-bg); color: var(--red); }
.stat-ico.yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-ico.gray { background: var(--gray-bg); color: var(--gray); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; color: var(--faint); font-weight: 500; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 20px; background: var(--gray-bg); color: var(--gray); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gray-dot); }
.badge.nodot::before { display: none; }
.badge.green { background: var(--green-bg); color: var(--green); } .badge.green::before { background: var(--green-dot); }
.badge.red { background: var(--red-bg); color: var(--red); } .badge.red::before { background: var(--red-dot); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); } .badge.yellow::before { background: var(--yellow-dot); }
.badge.blue { background: var(--blue-bg); color: var(--blue); } .badge.blue::before { background: var(--blue-dot); }
.badge.purple { background: var(--purple-bg); color: var(--purple); } .badge.purple::before { background: var(--purple-dot); }
.badge.gray { background: var(--gray-bg); color: var(--gray); }
.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--gray-bg); color: var(--text-2); font-size: 12px; font-weight: 550; white-space: nowrap; }
.code-chip { font-family: var(--mono); font-size: 12px; font-weight: 600; background: var(--brand-50); color: var(--brand-700); padding: 1px 7px; border-radius: 6px; letter-spacing: .02em; white-space: nowrap; }

/* ---------- 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(--border-strong); background: #fff; color: var(--text);
  font: 550 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .12s, border-color .12s, box-shadow .12s; user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: #c4c8d0; }
.btn:focus-visible, .input:focus-visible, .nav-item:focus-visible, .chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.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 { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-danger-outline { color: #b91c1c; border-color: #fecaca; }
.btn-danger-outline:hover { background: #fff5f5; border-color: #fca5a5; }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--gray-bg); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; justify-content: stretch; }
.btn-icon { height: 26px; width: 26px; padding: 0; border-radius: 6px; vertical-align: middle; margin-left: 4px; }
.btn-icon .ico { width: 15px; height: 15px; }
.name-line { white-space: nowrap; display: flex; align-items: center; }
.tbl .w-name { min-width: 180px; }
.tbl .w-link { min-width: 150px; }
.tbl .w-now { min-width: 220px; }
.tbl .w-list { min-width: 170px; }
input[type=file].input { height: auto; padding: 6px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.input {
  height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff;
  font: 400 14px var(--font); color: var(--text); width: 100%; min-width: 0; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.45; }
select.input { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath d='M5.5 7.5 10 12l4.5-4.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 18px; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(50, 77, 199, .15); outline: none; }
.input.mono { font-family: var(--mono); letter-spacing: .04em; }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > .input { flex: 1 1 160px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; flex: 0 0 auto; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.radio-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; flex-wrap: wrap; }
.radio-group label { position: relative; display: inline-flex; align-items: center; padding: 0 12px; height: 34px; font-size: 13px; font-weight: 550; cursor: pointer; border-right: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.radio-group label:last-child { border-right: 0; }
.radio-group input { position: absolute; opacity: 0; pointer-events: none; }
.radio-group label:has(input:checked) { background: var(--brand-50); color: var(--brand-700); }
.radio-group label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: -2px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: #d1d5db; position: relative; transition: background .15s; flex: 0 0 auto; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch .sw-text b { display: block; font-weight: 600; font-size: 13.5px; }
.switch .sw-text small { display: block; color: var(--muted); font-size: 12.5px; }

.setting-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row:first-child { padding-top: 0; }
.setting-row .sr-text b { display: block; font-weight: 600; }
.setting-row .sr-text small { color: var(--muted); font-size: 12.5px; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* ---------- Toolbar & tables ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search { max-width: 380px; flex: 1 1 240px; padding-left: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 10px center; background-size: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font: 550 12.5px var(--font); color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.chip .n { font-variant-numeric: tabular-nums; opacity: .7; }

.bulkbar { display: flex; align-items: center; gap: 8px; padding: 10px 18px; background: var(--brand-50); border-bottom: 1px solid var(--brand-100); flex-wrap: wrap; }
.bulkbar .sel { font-weight: 650; color: var(--brand-700); margin-right: 6px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th { background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .arr { display: inline-block; width: 10px; margin-left: 3px; color: var(--brand); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.selected, .tbl tr.selected:hover { background: var(--brand-50); }
.tbl .cb { width: 36px; padding-right: 0; }
.tbl .cb input { width: 16px; height: 16px; accent-color: var(--brand); margin: 2px 0 0; cursor: pointer; }
.tbl .primary { font-weight: 600; color: var(--text); }
.tbl .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl.compact td { padding: 8px 14px; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 4px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }

.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); align-items: end; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-tag { display: flex; align-items: center; gap: 8px; padding: 10px 18px; background: var(--brand-50); border-bottom: 1px solid var(--brand-100); font-size: 13px; flex-wrap: wrap; }

/* ---------- Key-value ---------- */
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.kv > div { padding: 12px 18px; border-bottom: 1px solid var(--border); min-width: 0; }
.kv dt { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.kv .full-row { grid-column: 1 / -1; }
.bot-banner { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: var(--radius); flex-wrap: wrap; }
.bot-banner .bot-name { font-size: 22px; font-weight: 750; color: var(--brand-700); letter-spacing: -.01em; overflow-wrap: anywhere; }
.bot-banner .bot-text { color: var(--text-2); font-size: 13.5px; }

.device-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 18px; flex-wrap: wrap; }
.device-head h2 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.device-head .note { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 18px 18px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 550; }

.state-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 16px 18px; }
.state-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; margin: 0; }
.state-box dt { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.state-box dd { margin: 3px 0 0; font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.low { color: var(--red); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex: 0 0 auto; }
.feed .dot.warn { background: var(--yellow-dot); } .feed .dot.bad { background: var(--red-dot); } .feed .dot.ok { background: var(--green-dot); }
.feed .f-main { flex: 1; min-width: 0; }
.feed .f-title { font-weight: 600; overflow-wrap: anywhere; }
.feed .f-sub { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.feed .f-time { color: var(--faint); font-size: 12px; white-space: nowrap; }

.sysrow { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.sysrow:last-child { border-bottom: 0; }
.sysrow > span:last-child { text-align: right; }

/* ---------- Config page ---------- */
.test-row { display: grid; grid-template-columns: minmax(0, 1.1fr) auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.test-row:last-child { border-bottom: 0; }
.test-row .t-title { font-weight: 600; }
.test-row .t-meta { color: var(--muted); font-size: 12.5px; }
.savebar { position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; background: rgba(255, 255, 255, .97); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); flex-wrap: wrap; }
.savebar .dirty { color: var(--yellow); font-weight: 600; }

.kill-card { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.kill-state { display: flex; align-items: center; gap: 12px; }
.kill-state .big { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto; }
.kill-state .big.on { background: var(--red-bg); color: var(--red); }
.kill-state .big.off { background: var(--green-bg); color: var(--green); }
.kill-state .big .ico { width: 22px; height: 22px; }

.progress { height: 8px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

.preview { white-space: pre-wrap; background: #eef3f8; border: 1px solid #dbe4ee; border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.55; max-width: 420px; margin: 0; font-family: var(--font); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s ease-out; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; animation: pop .14s ease-out; }
.modal-head { padding: 18px 20px 6px; display: flex; gap: 12px; align-items: flex-start; }
.modal-head h3 { font-size: 16px; font-weight: 650; margin-top: 7px; }
.modal-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: var(--brand-50); color: var(--brand); }
.modal-ico.danger { background: var(--red-bg); color: var(--red); }
.modal-body { padding: 8px 20px 4px; color: var(--text-2); display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 16px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #111827; color: #fff; padding: 11px 14px 11px 12px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; animation: pop .15s ease-out; transition: opacity .2s, transform .2s; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green-dot); margin-top: 6px; flex: 0 0 auto; }
.toast.error::before { background: var(--red-dot); }
.toast.warn::before { background: var(--yellow-dot); }
.toast.hide { opacity: 0; transform: translateY(4px); }

/* ---------- Auth ---------- */
body.auth { background: radial-gradient(1200px 600px at 10% -10%, #dfe5fa 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e9ecf8 0, transparent 60%), var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 20px; margin-top: 6px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .logo { width: 40px; height: 40px; }
.auth-brand b { display: block; font-size: 16px; }
.auth-brand small { display: block; color: var(--muted); font-size: 12.5px; }
.auth-foot { color: var(--faint); font-size: 12px; text-align: center; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-actions { grid-column: 1 / -1; }
  .state-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .hide-lg { display: none; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 45; }
  .main { margin-left: 0; }
  .icon-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 40px; }
  .kill-banner { padding: 10px 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-md { display: none; }
  .test-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; gap: 10px; }
  .stat-ico { display: none; }
  .stat-value { font-size: 22px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 14px 16px; }
  .form-grid, .form-grid.two, .checks { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .state-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 14px 16px; }
  .toolbar, .card-head, .card-body, .bulkbar, .pager, .card-foot, .actions, .device-head, .test-row, .feed li, .kv > div, .filter-tag { padding-left: 16px; padding-right: 16px; }
  .search { max-width: none; }
  .hide-sm { display: none; }
  .tbl th, .tbl td { padding-left: 10px; padding-right: 10px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; max-width: none; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 90vh; }
  .modal-foot .btn { flex: 1; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .setting-row { flex-direction: column; }
  .page-title { font-size: 16px; }
  .btn-lg { width: 100%; }
  .live span { display: none; }
}
