/* Clutch NOC — operatör arayüzü (dark, Keenetic/NOC esinli) */
:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c2230; --line: #2a3140;
  --txt: #e6edf3; --muted: #8b98a9; --accent: #3b82f6; --accent2: #f97316;
  --ok: #22c55e; --warn: #f59e0b; --err: #ef4444;
  --radius: 10px; --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--txt); display: flex; min-height: 100vh; font-size: 14px;
}

/* sidebar */
.sidebar {
  width: 230px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; flex-shrink: 0;
}
.brand { display: flex; gap: 11px; align-items: center; margin-bottom: 26px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 9px; background: #0b1f3a;
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 4px 14px rgba(249, 115, 22, .35); flex: 0 0 auto;
}
.brand .logo img { width: 82%; height: 82%; object-fit: contain; }
.brand b { display: block; font-size: 15px; }
.brand .sub { display: block; font-size: 11px; color: var(--muted); }
nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: none; border: none; color: var(--muted); text-align: left;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--panel2); color: var(--txt); }
.nav-item.active { background: var(--accent); color: #fff; }
.badge {
  background: var(--accent2); color: #fff; border-radius: 10px; font-size: 11px;
  padding: 1px 7px; font-weight: 700;
}
.badge.warn { background: var(--warn); }
.nav-item.active .badge { background: rgba(255,255,255,.25); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.switch-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.lang { background: var(--panel2); border: 1px solid var(--line); color: var(--txt); border-radius: 7px; padding: 6px 10px; cursor: pointer; width: fit-content; }

/* main */
.main { flex: 1; padding: 22px 26px; overflow: auto; }
.conn-warn { background: rgba(239,68,68,.12); border: 1px solid var(--err); color: #fecaca; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
h2 { margin: 0 0 16px; font-size: 18px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.s-label { color: var(--muted); font-size: 12px; }
.s-val { font-size: 26px; font-weight: 700; }
.s-val.ok { color: var(--ok); }
.s-val.warn { color: var(--warn); }

/* toolbar */
.toolbar { margin-bottom: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar #search { flex: 1; }
#fleet-bulk-toggle.active { border-color: var(--accent2); color: var(--accent2); }
/* Toplu firmware seçim sütunu — yalnız bulk modda görünür */
.fleet-sel { display: none; width: 34px; text-align: center; }
#fleet-table.bulk .fleet-sel { display: table-cell; }
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
  padding: 10px 14px; background: rgba(249,115,22,.06); border: 1px solid rgba(249,115,22,.3); border-radius: 8px;
}
.bulk-bar input {
  flex: 1; min-width: 200px; background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 12px; border-radius: 7px; font-size: 13px;
}
.bulk-bar input:focus { outline: none; border-color: var(--accent2); }
.bulk-bar select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 12px; border-radius: 7px; font-size: 13px; min-width: 220px;
}
.bulk-bar select:focus { outline: none; border-color: var(--accent2); }
.fw-upload {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 18px;
  padding: 12px 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
}
.fw-upload input[type="text"] {
  flex: 1; min-width: 180px; background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 12px; border-radius: 7px; font-size: 13px;
}
.fw-upload input[type="text"]:focus { outline: none; border-color: var(--accent2); }
#search {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  color: var(--txt); padding: 10px 14px; border-radius: 8px; font-size: 14px;
}
#search:focus { outline: none; border-color: var(--accent); }
#anom-type {
  background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 12px; border-radius: 8px; font-size: 14px;
}
#anom-type:focus { outline: none; border-color: var(--accent); }

/* anomali şiddet rozetleri */
.sev { padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.sev-crit { background: rgba(239,68,68,.16); color: #fecaca; }
.sev-warn { background: rgba(245,158,11,.16); color: #fde68a; }
.sev-info { background: rgba(139,152,169,.16); color: var(--muted); }
.sev-ok { background: rgba(34,197,94,.16); color: #bbf7d0; }
.tag-cand {
  background: var(--warn); color: #1a1206; border-radius: 5px;
  font-size: 10px; font-weight: 700; padding: 1px 6px; margin-left: 4px; text-transform: uppercase;
}
#anom-body tr[data-anom-dev] { cursor: pointer; }
#anom-body tr[data-anom-dev]:hover { background: var(--panel2); }

/* altyapı yoğunluk paneli */
.byline { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.byline:empty { display: none; }
.byline-title { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.byline-bars { display: flex; flex-direction: column; gap: 7px; }
.byline-row { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 10px; }
.byline-k { font-size: 13px; }
.byline-bar { background: var(--panel2); border-radius: 5px; height: 10px; overflow: hidden; }
.byline-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--warn)); border-radius: 5px; }
.byline-v { text-align: right; font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* drill-down trend sparkline */
.spark { background: var(--panel2); border-radius: 8px; padding: 8px; margin-bottom: 6px; }

/* kök neden rozetleri */
.cause { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.cause-congestion { background: rgba(245,158,11,.16); color: #fde68a; }
.cause-line       { background: rgba(239,68,68,.16); color: #fecaca; }
.cause-wifi       { background: rgba(59,130,246,.16); color: #bfdbfe; }
.cause-router_load{ background: rgba(139,92,246,.16); color: #ddd6fe; }
.cause-unknown    { background: rgba(139,152,169,.14); color: var(--muted); }
.cause-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.cause-dot.cause-congestion { background: var(--warn); }
.cause-dot.cause-line { background: var(--err); }
.cause-dot.cause-wifi { background: var(--accent); }
.cause-dot.cause-router_load { background: #8b5cf6; }
.cause-dot.cause-unknown { background: var(--muted); }

/* Çözülebilirlik (fixability) rozetleri — operatör hangi sorun yazılımla/kullanıcı/ISS */
.fixb { padding: 1px 7px; border-radius: 20px; font-size: 10px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.fixb-soft   { background: rgba(34,197,94,.14); color: #bbf7d0; border-color: rgba(34,197,94,.3); }
.fixb-user   { background: rgba(245,158,11,.14); color: #fde68a; border-color: rgba(245,158,11,.3); }
.fixb-isp    { background: rgba(239,68,68,.14); color: #fecaca; border-color: rgba(239,68,68,.3); }
.fixb-invest { background: rgba(139,152,169,.14); color: var(--muted); border-color: rgba(139,152,169,.3); }
.fix-note { margin: 10px 0 4px; padding: 10px 12px; border-radius: 8px; font-size: 12px; line-height: 1.5; border-left: 3px solid; }
.fix-note.fixb-user   { background: rgba(245,158,11,.08); border-color: var(--warn); }
.fix-note.fixb-isp    { background: rgba(239,68,68,.08); border-color: var(--err); }
.fix-note.fixb-invest { background: rgba(139,152,169,.08); border-color: var(--muted); }

/* iki panelli yoğunluk ızgarası (kök neden + altyapı) */
.byline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.byline-grid .byline { margin-bottom: 0; }
@media (max-width: 860px) { .byline-grid { grid-template-columns: 1fr; } }

/* table */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover { background: var(--panel2); }

/* Anomali seçim sütunu — yalnız seç modunda görünür */
.sel-col { display: none; width: 1%; text-align: center; }
table.selecting .sel-col { display: table-cell; }
table.selecting tbody tr[data-anom-dev] { cursor: default; }
.sel-col input { cursor: pointer; }
.mono { font-family: var(--mono); }
.small { font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* status dot */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 7px var(--ok); }
.dot.off { background: #4b5563; }

/* action buttons */
.actions { display: flex; gap: 6px; white-space: nowrap; }
.ic {
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer; display: grid; place-items: center;
}
.ic:hover { color: var(--txt); border-color: var(--accent); }
.ic.danger:hover { color: var(--err); border-color: var(--err); }
.btn-sm {
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 12px;
}
.btn-sm:hover { border-color: var(--accent); }
.btn-sm.danger:hover { color: var(--err); border-color: var(--err); }

/* detail slide-over */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.detail.open ~ .backdrop, .backdrop.show { opacity: 1; }
.detail {
  position: fixed; top: 0; right: 0; height: 100vh; width: 540px; max-width: 92vw;
  background: var(--panel); border-left: 1px solid var(--line); z-index: 50;
  transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.detail.open { transform: translateX(0); }
.detail.open + #detail-backdrop, body:has(.detail.open) #detail-backdrop { opacity: 1; pointer-events: auto; }
.detail-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.detail-head h3 { margin: 0; font-size: 16px; }
.x { background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.x:hover { color: var(--txt); }
.detail-body { padding: 18px 20px; overflow: auto; }
.detail-body h4 { margin: 20px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--txt); padding: 8px 13px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.danger:hover { color: var(--err); border-color: var(--err); }
table.kv { width: 100%; }
table.kv td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.kv td:first-child { color: var(--muted); width: 38%; }
table.kv.params td { font-size: 12px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 12px 20px; border-radius: 9px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }

@media (max-width: 920px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 64px; }
  .brand div, .nav-item span:not(.badge), .switch-row span { display: none; }
}

/* ---- .btn.primary (turuncu marka aksanı) ---- */
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #1a1207; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); border-color: var(--accent2); }

/* ---- Session login ekranı (router paneli deseni) ---- */
.noc-login[hidden] { display: none; }
.noc-login {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(249,115,22,.10), transparent), var(--bg);
}
.login-card {
  width: 340px; max-width: 92vw; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand img { width: 42px; height: 42px; object-fit: contain; }
.login-brand b { display: block; font-size: 16px; }
.login-brand span { display: block; color: var(--muted); font-size: 12px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 8px; }
.login-card input {
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 10px 12px; border-radius: 8px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent2); }
.login-card .btn.primary { justify-content: center; margin-top: 16px; padding: 11px; }
.login-error { color: var(--err); font-size: 12.5px; margin: 10px 0 0; }
.login-foot { color: var(--muted); font-size: 11px; text-align: center; margin: 18px 0 0; }
.foot-row { display: flex; gap: 8px; }

/* ---- Asistan sohbeti (WhatsApp-vari) ---- */
.view-chat { height: calc(100vh - 44px); }
.chat-wrap {
  display: flex; flex-direction: column; height: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
/* Üst bar — asistan kimliği */
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  background: var(--panel2); border-bottom: 1px solid var(--line);
}
.chat-head-av {
  width: 40px; height: 40px; border-radius: 50%; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line);
}
.chat-head-av img { width: 100%; height: 100%; object-fit: cover; }
.chat-head-meta { display: flex; flex-direction: column; line-height: 1.25; margin-right: auto; }
.chat-head-meta b { font-size: 14.5px; }
.chat-head-status { font-size: 11.5px; color: var(--muted); }
.chat-head-clear { padding: 6px 12px; font-size: 12px; }
/* Mesaj alanı — kaydırmalı, hafif dokulu zemin */
.chat-log {
  flex: 1; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 18px 16px;
  background:
    radial-gradient(circle at 15% 20%, rgba(249,115,22,.05), transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(59,130,246,.05), transparent 40%),
    var(--bg);
}
.chat-empty { margin: auto; max-width: 360px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
/* Satır + balon */
.chat-row {
  display: flex; align-items: flex-end; gap: 8px; max-width: 82%;
  animation: chatIn .28s cubic-bezier(.22,.68,.36,1) both;
}
@keyframes chatIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-row { animation: none; } }
.chat-row-assistant { align-self: flex-start; }
.chat-row-user { align-self: flex-end; flex-direction: row-reverse; }
.chat-av {
  width: 30px; height: 30px; border-radius: 50%; flex: none; margin-bottom: 2px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line);
}
.chat-av img { width: 100%; height: 100%; object-fit: cover; }
.chat-msg {
  position: relative; padding: 8px 12px 6px; border-radius: 12px; font-size: 13.5px; line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-time { display: block; text-align: right; font-size: 10px; margin-top: 3px; opacity: .65; }
.chat-user { background: var(--accent2); color: #1a1207; border-bottom-right-radius: 3px; }
.chat-assistant { background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.chat-err { border-color: var(--err) !important; color: #fecaca; }
.chat-thinking .chat-text { animation: chatPulse 1.1s ease-in-out infinite; }
@keyframes chatPulse { 0%,100% { opacity: .35; } 50% { opacity: .9; } }
/* Sepet — mesaj alanı ile composer arasında */
.chat-cart {
  background: rgba(34,197,94,.06); border-top: 1px solid rgba(34,197,94,.3); padding: 10px 14px;
}
.chat-cart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.chat-cart-actions { display: flex; gap: 8px; }
.chat-cart-actions .btn { padding: 5px 12px; font-size: 12px; }
.chat-cart-items { display: flex; flex-direction: column; gap: 6px; max-height: 26vh; overflow-y: auto; }
.chat-cart-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.chat-cart-row .ic { margin-left: auto; }
/* Composer — alta sabit */
.chat-form { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--panel2); border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--txt);
  padding: 11px 16px; border-radius: 22px; font-size: 14px;
}
.chat-form input:focus { outline: none; border-color: var(--accent2); }
.chat-send {
  width: 42px; height: 42px; padding: 0; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.chat-send svg { margin-left: -1px; }

/* ---- uyandırma sinyalleri (alarm bandı) ---- */
.alarm-band { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--warn); background: rgba(245,158,11,.08); }
.alarm-band.sev-crit { border-color: var(--err); background: rgba(239,68,68,.10); }
.alarm-band-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.alarm-band-head b { font-size: 14px; }
.alarm-count { background: var(--err); color: #fff; border-radius: 11px; min-width: 20px; text-align: center; font-size: 12px; font-weight: 700; padding: 1px 7px; }
.alarm-band.sev-warn .alarm-count { background: var(--warn); color: #1a1206; }
.alarm-band-head .btn.small { margin-left: auto; padding: 4px 10px; font-size: 12px; }
.alarm-list { display: flex; flex-direction: column; gap: 6px; }
.alarm-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.alarm-item .alarm-kind { font-size: 13px; }
.alarm-dev { color: var(--accent); cursor: pointer; text-decoration: none; }
.alarm-dev:hover { text-decoration: underline; }
.alarm-note { color: var(--muted); font-size: 13px; flex: 1; min-width: 160px; }
.alarm-item .x { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.alarm-item .x:hover { color: var(--txt); }

/* ---- near-miss paneli (self-heal kurtarmaları) ---- */
.nearmiss { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.nearmiss-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.nearmiss-head b { font-size: 14px; }
.nearmiss-metric { color: var(--muted); font-size: 12px; }
.nearmiss-metric strong { color: var(--txt); font-family: var(--mono); font-size: 15px; margin-right: 3px; }
.nearmiss-rows { display: flex; flex-direction: column; gap: 6px; }
.nearmiss-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.nearmiss-row:first-child { border-top: none; }
.nm-dev { color: var(--accent); cursor: pointer; font-family: var(--mono); font-size: 13px; }
.nm-dev:hover { text-decoration: underline; }
.nm-count { background: var(--panel2); border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.nm-count.hot { background: rgba(239,68,68,.16); color: #fecaca; }
.nm-reasons { color: var(--muted); font-size: 12px; flex: 1; }
.nm-last { color: var(--muted); font-size: 12px; }
