:root {
  --bg: #0b1220; --panel: #131c2e; --panel2: #1a2540; --line: #24304a;
  --text: #e6edf7; --muted: #7d8db0; --accent: #3b82f6;
  --ok: #22c55e; --high: #eab308; --danger: #ef4444; --auto: #a855f7;
}
.theme-light {
  --bg: #eef2f8; --panel: #ffffff; --panel2: #f2f6fc; --line: #d9e2f0;
  --text: #0f1b32; --muted: #5a6b8c; --accent: #2563eb;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
#app { min-height: 100vh; }

.hdr { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo { font-size: 20px; }
.host { font-size: 12px; color: var(--muted); font-weight: 400; }
.hdr-right { display: flex; align-items: center; gap: 12px; }
.attack-badge { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: rgba(34,197,94,.15); color: var(--ok); font-weight: 600; }
.attack-badge.on { background: rgba(239,68,68,.18); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.switch { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.conn { font-size: 11px; color: var(--ok); text-transform: uppercase; letter-spacing: .5px; }
.conn.off { color: var(--danger); }
.tbtn { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 8px; cursor: pointer; }
.logout { color: var(--muted); text-decoration: none; font-size: 12px; }
.user { font-size: 12px; color: var(--text); font-weight: 600; } .user small { color: var(--muted); font-weight: 400; }
.uactions { display: flex; gap: 6px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: transparent; border: none; color: var(--muted); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; }
.tabs button.active { background: var(--accent); color: #fff; }
.pill { background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 6px; }
/* анимация слайда при переключении раздела (свайп/клик) */
.views { overflow-x: clip; }
.views.sl { animation: vslide-l .2s ease-out; }
.views.sr { animation: vslide-r .2s ease-out; }
@keyframes vslide-l { from { transform: translateX(28px); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes vslide-r { from { transform: translateX(-28px); opacity: .3; } to { transform: none; opacity: 1; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; padding: 16px; max-width: 1100px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card.wide { grid-column: span 2; }
@media (max-width: 680px) {
  .hdr { flex-wrap: wrap; gap: 8px; padding: 10px 12px; position: static; }
  .tabs { position: sticky; top: 0; z-index: 9; }   /* вкладки закреплены при прокрутке */
  .hdr-right { gap: 8px; flex-wrap: wrap; }
  .brand { font-size: 16px; }
  .grid { grid-template-columns: 1fr 1fr; padding: 10px; gap: 10px; }
  .stack { padding: 10px; gap: 10px; }
  .card.wide { grid-column: span 2; }
  .big { font-size: 30px; }
  .meter { grid-template-columns: 96px 1fr 48px; gap: 6px; }
  .meter-l { font-size: 11px; }
  /* строки в 2 линии: ключ (1-я ячейка) сверху жирным, остальное — 2-я линия мелким серым через «·» */
  table:not(.nfttable), table:not(.nfttable) tbody { display: block; }
  table:not(.nfttable) thead { display: none; }
  table:not(.nfttable) tr { display: block; padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); margin-bottom: 6px; line-height: 1.55; }
  table:not(.nfttable) td { display: inline; border: none; padding: 0; font-size: 11.5px; color: var(--muted); vertical-align: middle; }
  table:not(.nfttable) td:empty, table:not(.nfttable) td:has(.meter-bar) { display: none; }   /* пустые + бары (Доля) прячем */
  table:not(.nfttable) td:not(:first-child)::before { content: "·\00a0"; opacity: .45; margin-left: 4px; }
  table:not(.nfttable) td:nth-child(2)::before { content: none; }
  table:not(.nfttable) td:first-child { display: block; font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
  table:not(.nfttable) td:first-child::before { content: none; }
  /* кнопки (остались только в users) — отдельной строкой справа */
  table:not(.nfttable) td:has(button) { display: block; text-align: right; margin-top: 6px; padding: 0; }
  table:not(.nfttable) td:has(button)::before { content: none; }
  /* таблица nft-правил — горизонтальная прокрутка (длинный моно-текст) */
  .nfttable { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .spark-row { grid-template-columns: 46px 1fr 96px; }
  .form input, .form select { flex: 1 1 120px; min-width: 0; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
  .card.wide { grid-column: span 1; }
  .tabs button { padding: 8px 12px; font-size: 13px; }
}
.card-h { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.if-ip { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); margin-left: 7px; font-family: ui-monospace, monospace; font-size: 12px; }
.sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); }
.big { font-size: 40px; font-weight: 800; }
.big.danger { color: var(--danger); }

.rate { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 19px; font-weight: 700; }
.rate .dn, .rate .up { white-space: nowrap; }
.dn, .s-rx { color: var(--accent); } .up, .s-tx { color: var(--auto); }
.row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border: none; }
.ip { font-family: ui-monospace, monospace; }

.gauge { height: 12px; background: var(--panel2); border-radius: 8px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 8px; transition: width .5s; }
.gauge-fill.ok { background: var(--ok); } .gauge-fill.high { background: var(--high); } .gauge-fill.danger { background: var(--danger); }

.meter { display: grid; grid-template-columns: 130px 1fr 60px; align-items: center; gap: 10px; margin: 6px 0; }
.meter-l { font-size: 12px; }
.meter-bar { height: 8px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--ok); transition: width .4s; }
.meter-fill.high { background: var(--high); } .meter-fill.attack { background: var(--danger); }
.meter-v { text-align: right; font-weight: 700; font-family: ui-monospace, monospace; }
.meter-v.high { color: var(--high); } .meter-v.attack { color: var(--danger); } .meter-v small { color: var(--muted); font-weight: 400; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
tr.scanner td { background: rgba(239,68,68,.06); }
.warn { color: var(--danger); font-weight: 700; }
.geo { font-size: 12px; color: var(--muted); } .geo small { color: var(--muted); }
.nftchain { margin: 8px 0; }
.nftchain-h { font-size: 13px; margin: 6px 0 2px; }
.nfttable { width: 100%; }
.nfttable td { padding: 2px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.nftrule { font-family: ui-monospace, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.nftcnt { font-size: 11px; color: var(--muted); white-space: nowrap; text-align: right; }
.nfth { font-size: 11px; white-space: nowrap; }
.nftsets { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); white-space: nowrap; }
.tag.auto { background: rgba(168,85,247,.18); color: var(--auto); }
.tag.manual { background: rgba(59,130,246,.18); color: var(--accent); }
.tag.meter { background: rgba(125,141,176,.18); color: var(--muted); }
.tag.hot { background: rgba(239,68,68,.16); color: var(--danger); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > * { min-width: 0; }   /* иначе длинный контент (ASN) распирает карточку шире дорожки */
.grid2 .row { min-width: 0; }
.grid2 .row > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 680px) { .grid2 { grid-template-columns: 1fr; } }
.ports { display: flex; flex-wrap: wrap; gap: 6px; }
.ports .tag small { font-weight: 400; }

/* карточка «Атакуемые сервисы» (обзор) — аккуратная адаптивная сетка */
.svc-list { display: flex; flex-direction: column; }
.svc-row { display: grid; grid-template-columns: minmax(60px, 36%) 1fr auto; align-items: center; column-gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.svc-row:last-child { border-bottom: none; }
.svc-info { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.svc-port { font-family: ui-monospace, monospace; font-weight: 700; font-size: 13px; white-space: nowrap; }
.svc-port.hot { color: var(--danger); }
.svc-name { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc-bar { height: 6px; min-width: 0; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.svc-bar-f { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .4s; }
.svc-bar-f.hot { background: var(--danger); }
.svc-cnt { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; justify-self: end; }
.svc-cnt b { font-size: 15px; }
.svc-ip { font-size: 11px; color: var(--muted); }
@media (max-width: 420px) { .svc-row { grid-template-columns: minmax(52px, 42%) 1fr auto; column-gap: 8px; } .svc-cnt b { font-size: 14px; } }

.form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input, select { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn.danger { background: var(--danger); }
.mini { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
.msg { color: var(--muted); font-size: 12px; }
.sel { font-size: 12px; padding: 4px 8px; }

.spark-row { display: grid; grid-template-columns: 60px 1fr 150px; align-items: center; gap: 10px; margin: 8px 0; }
.spark-l { font-size: 12px; color: var(--muted); }
.spark { width: 100%; height: 40px; } .spark.tall { height: 60px; }
.spark path { fill: none; stroke-width: 1.5; }
.spark path.s-rx { stroke: var(--accent); } .spark path.s-tx { stroke: var(--auto); } .spark path.s-ct { stroke: var(--high); }
.spark-v { font-size: 12px; text-align: right; }
.legend { font-size: 11px; color: var(--muted); margin-top: 6px; } .legend .s-rx { color: var(--accent); } .legend .s-tx { color: var(--auto); }

.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 14px; width: 280px; }
.login-logo { font-size: 24px; font-weight: 800; text-align: center; }
.login-card button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 10px; cursor: pointer; font-weight: 600; }
.login-err { color: var(--danger); font-size: 12px; text-align: center; min-height: 16px; }

/* модалка бан/разбан (тап по карточке) + кликабельные строки */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 100%; max-width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.modal-h { font-family: ui-monospace, monospace; font-size: 20px; font-weight: 700; word-break: break-all; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 6px 0 16px; line-height: 1.5; }
.modal-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 20px; }
.modal-close { margin-top: 14px; width: 100%; }
.t-bans tbody tr, .t-banhist tbody tr, .t-off tbody tr, .t-syn tbody tr { cursor: pointer; }
.t-bans tbody tr:active, .t-banhist tbody tr:active, .t-off tbody tr:active, .t-syn tbody tr:active { filter: brightness(.93); }
