/* ─── Threat Intelligence Dashboard ───────────────────── */
:root {
  --bg: #020617;
  --bg-card: rgba(15,23,42,.92);
  --bg-panel: rgba(15,23,42,.96);
  --border: rgba(148,163,184,.22);
  --border-hover: rgba(148,163,184,.45);
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --blue: #3b82f6;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #a855f7;
  --rose: #f43f5e;
  --radius: 14px;
  --max-w: 1320px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin:0; padding:0; font-family: system-ui, -apple-system, "Inter", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.drawer-source-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 8px 14px;
  font-size: .8rem; font-weight: 600;
  color: var(--blue); border: 1px solid var(--blue);
  border-radius: 8px; transition: background .2s, color .2s;
}
.drawer-source-link:hover {
  background: var(--blue); color: #fff; text-decoration: none;
}

/* animated grid */
.grid-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image:
    linear-gradient(rgba(148,163,184,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.06) 1px, transparent 1px);
  background-size: 72px 72px;
}
.shell { min-height: 100vh; }

/* ─── Header ──────────────────────────────────────────── */
.ti-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(18px);
  background: linear-gradient(to bottom, rgba(2,6,23,.95), rgba(2,6,23,.85), transparent);
  border-bottom: 1px solid var(--border);
}
.ti-header-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.ti-header-left { display: flex; align-items: center; gap: 14px; }
.ti-back {
  color: var(--text2); font-size: .85rem; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  transition: .2s;
}
.ti-back:hover { color: var(--text); border-color: var(--border-hover); text-decoration: none; }
.ti-divider { width: 1px; height: 22px; background: var(--border); }
.ti-title { font-size: 1.1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.ti-header-right { display: flex; align-items: center; gap: 14px; }
.ti-refresh-btn {
  font-size: .82rem; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text2);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: .2s;
}
.ti-refresh-btn:hover { color: var(--text); border-color: var(--blue); }
.ti-refresh-btn:disabled { opacity: .5; cursor: wait; }
.ti-live { font-size: .72rem; color: var(--green); display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.ti-live-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--green); box-shadow: 0 0 0 4px rgba(34,197,94,.25); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 4px rgba(34,197,94,.25); } 50%{ box-shadow: 0 0 0 8px rgba(34,197,94,.08); } }
.ti-clock { font-size: .78rem; color: var(--text3); display: flex; align-items: center; gap: 5px; }

/* ─── Summary Cards ───────────────────────────────────── */
.ti-main { max-width: var(--max-w); margin: 0 auto; padding: 24px 24px 64px; display: flex; flex-direction: column; gap: 20px; }
.ti-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.ti-card {
  padding: 18px 16px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  transition: border-color .2s, transform .2s;
}
.ti-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.ti-card-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1rem; flex-shrink: 0;
}
.ti-card-icon.red    { background: rgba(239,68,68,.15);  color: var(--red); }
.ti-card-icon.amber  { background: rgba(245,158,11,.15); color: var(--amber); }
.ti-card-icon.blue   { background: rgba(59,130,246,.15); color: var(--blue); }
.ti-card-icon.purple { background: rgba(168,85,247,.15); color: var(--purple); }
.ti-card-icon.green  { background: rgba(34,197,94,.15);  color: var(--green); }
.ti-card-icon.rose   { background: rgba(244,63,94,.15);  color: var(--rose); }
.ti-card-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.ti-card-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.ti-card-label { font-size: .72rem; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; }

/* Card expand chevron */
.ti-card-chevron {
  font-size: .65rem; color: var(--text3); transition: transform .25s, color .2s;
  position: absolute; top: 12px; right: 12px;
}
.ti-card.card-open .ti-card-chevron { transform: rotate(180deg); color: var(--blue); }

/* Card drawer */
.ti-card-drawer {
  grid-column: 1 / -1;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .35s cubic-bezier(.4,0,.2,1), opacity .25s, padding .25s;
  padding: 0 16px;
  border-top: 0 solid var(--border);
  font-size: .8rem; color: var(--text2);
}
.ti-card.card-open .ti-card-drawer {
  max-height: 600px; opacity: 1;
  padding: 14px 16px;
  border-top-width: 1px;
}

/* Card interactive state */
.ti-card[data-context] { cursor: pointer; position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; flex-wrap: wrap; }
.ti-card[data-context]:hover { border-color: var(--border-hover); }
.ti-card.card-open { border-color: var(--blue); box-shadow: 0 0 0 1px rgba(59,130,246,.15), 0 4px 20px rgba(0,0,0,.25); }

/* Drawer content styles */
.drawer-desc { margin: 0 0 10px; color: var(--text2); line-height: 1.5; font-size: .78rem; }
.drawer-subtitle { margin: 10px 0 6px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); }
.drawer-dim { color: var(--text3); font-size: .75rem; }
.drawer-detail { color: var(--text2); font-size: .75rem; line-height: 1.4; }
.drawer-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }

/* Drawer bar chart */
.drawer-bars { display: flex; flex-direction: column; gap: 6px; }
.drawer-bar-row { display: grid; grid-template-columns: 100px 1fr 36px; align-items: center; gap: 8px; }
.drawer-bar-label { font-size: .72rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-bar-track { height: 6px; border-radius: 3px; background: rgba(148,163,184,.1); overflow: hidden; }
.drawer-bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.drawer-bar-fill.red-fill { background: var(--red); }
.drawer-bar-val { font-size: .72rem; color: var(--text3); text-align: right; font-weight: 600; }

/* Drawer tags */
.drawer-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.drawer-tag {
  padding: 3px 9px; border-radius: 6px; font-size: .72rem;
  background: rgba(148,163,184,.08); border: 1px solid rgba(148,163,184,.12); color: var(--text2);
}
.drawer-tag strong { color: var(--text); margin-left: 3px; }
.malware-tag { background: rgba(168,85,247,.1); border-color: rgba(168,85,247,.2); color: #c084fc; }

/* Drawer list */
.drawer-list { display: flex; flex-direction: column; gap: 8px; }
.drawer-list-item {
  padding: 8px 10px; border-radius: 8px;
  background: rgba(15,23,42,.5); border: 1px solid rgba(148,163,184,.08);
  line-height: 1.45;
}
.drawer-list-item:hover { border-color: var(--border-hover); }

/* Drawer gauge */
.drawer-gauge { margin: 8px 0 4px; }
.drawer-gauge-bar { height: 8px; border-radius: 4px; background: rgba(34,197,94,.15); overflow: hidden; }
.drawer-gauge-fill.danger-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--amber), var(--red)); }
.drawer-gauge-label { font-size: .7rem; color: var(--red); margin-top: 3px; display: block; font-weight: 600; }

/* ─── Source status bar ───────────────────────────────── */
.ti-source-bar {
  display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 16px;
  border-radius: 10px; background: var(--bg-card); border: 1px solid var(--border);
  font-size: .78rem; color: var(--text3);
}
.ti-source { display: flex; align-items: center; gap: 6px; }
.ti-source i { font-size: 8px; }
.ti-source.source-ok i { color: var(--green); }
.ti-source.source-down i { color: var(--red); }

/* ─── Panels ──────────────────────────────────────────── */
.ti-panel {
  border-radius: var(--radius); background: var(--bg-panel);
  border: 1px solid var(--border); overflow: hidden;
}
.ti-panel-head {
  padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border);
}
.ti-panel-head h2 { font-size: 1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.ti-panel-sub { font-size: .8rem; color: var(--text3); margin: 4px 0 0; }
.ti-panel-sub a { color: var(--blue); font-size: .75rem; }
.ti-search {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(15,23,42,.6); color: var(--text); font-size: .82rem;
  width: 240px; max-width: 100%;
  transition: border-color .2s;
}
.ti-search::placeholder { color: var(--text3); }
.ti-search:focus { outline: none; border-color: var(--blue); }

/* ─── Tables ──────────────────────────────────────────── */
.ti-table-wrap { overflow-x: auto; }
.ti-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.ti-table thead { background: rgba(15,23,42,.7); }
.ti-table th {
  text-align: left; padding: 10px 14px; font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ti-table td { padding: 10px 14px; border-bottom: 1px solid rgba(148,163,184,.08); color: var(--text2); }
.ti-table tbody tr:hover { background: rgba(59,130,246,.04); }
.ti-table-footer { padding: 10px 16px; font-size: .72rem; color: var(--text3); border-top: 1px solid var(--border); }

.cve-link { font-weight: 600; font-family: "SF Mono", "Fira Code", monospace; font-size: .8rem; }
.ioc-cell { font-family: "SF Mono", "Fira Code", monospace; font-size: .78rem; word-break: break-all; max-width: 280px; }

.ti-loading, .ti-error, .ti-empty { text-align: center; padding: 32px; color: var(--text3); }
.ti-error { color: var(--red); }

/* ─── Badges / Tags ───────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.sev-critical { background: rgba(239,68,68,.18); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); }
.sev-high     { background: rgba(245,158,11,.16); color: #fcd34d; border: 1px solid rgba(245,158,11,.3); }
.sev-medium   { background: rgba(59,130,246,.16); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
.sev-low      { background: rgba(34,197,94,.14);  color: #86efac; border: 1px solid rgba(34,197,94,.3); }

.badge-ransomware { background: rgba(239,68,68,.2); color: #fca5a5; border: 1px solid rgba(239,68,68,.4); }
.badge-unknown    { background: rgba(100,116,139,.2); color: var(--text3); border: 1px solid rgba(100,116,139,.3); }
.badge-online     { background: rgba(239,68,68,.2); color: #fca5a5; border: 1px solid rgba(239,68,68,.4); }
.badge-offline    { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.3); }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: .68rem;
  background: rgba(148,163,184,.1); color: var(--text3); border: 1px solid rgba(148,163,184,.15);
  margin: 1px;
}

/* ─── Live Threat Map ─────────────────────────────────── */
.ti-map {
  height: 440px;
  width: 100%;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.ti-map-meta {
  display: flex; align-items: center; gap: 16px;
  font-size: .82rem; color: var(--text2);
}
.ti-map-count { display: flex; align-items: center; gap: 5px; }
.ti-map-count i { color: var(--red); font-size: .75rem; }
.ti-map-legend {
  padding: 10px 16px; font-size: .75rem; color: var(--text3);
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.legend-title { font-weight: 600; color: var(--text2); margin-right: 4px; }
.legend-item {
  padding: 2px 8px; border-radius: 6px;
  background: rgba(148,163,184,.08); border: 1px solid rgba(148,163,184,.12);
}
.legend-item strong { color: var(--text); }

/* Leaflet dark popup */
.dark-popup .leaflet-popup-content-wrapper {
  background: rgba(15,23,42,.95); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.dark-popup .leaflet-popup-tip { background: rgba(15,23,42,.95); }
.map-popup { font-size: .8rem; line-height: 1.5; }
.map-popup strong { font-family: "SF Mono", "Fira Code", monospace; font-size: .82rem; color: var(--red); }
.map-popup-loc { color: var(--text2); font-size: .75rem; }
.map-popup-threat { color: var(--amber); font-size: .75rem; font-weight: 600; }
.map-popup-tags { margin: 4px 0 2px; }
.map-popup-status { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.status-online { color: var(--red); }
.status-offline { color: var(--green); }

/* ─── Attribution ─────────────────────────────────────── */
.ti-attribution {
  border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border); padding: 24px;
}
.ti-attribution h3 { font-size: .9rem; margin: 0 0 14px; }
.ti-attr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ti-attr-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border-radius: 10px; border: 1px solid var(--border); background: rgba(15,23,42,.5);
  transition: border-color .2s, transform .2s; color: var(--text);
}
.ti-attr-card:hover { border-color: var(--blue); transform: translateY(-2px); text-decoration: none; }
.ti-attr-card i { font-size: 1.1rem; color: var(--blue); margin-bottom: 4px; }
.ti-attr-card strong { font-size: .85rem; }
.ti-attr-card span { font-size: .72rem; color: var(--text3); }
.ti-disclaimer { font-size: .72rem; color: var(--text3); margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .ti-header-inner { padding: 10px 14px; }
  .ti-title { font-size: .95rem; }
  .ti-main { padding: 14px 10px 48px; }
  .ti-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .ti-search { width: 100%; }
  .ti-panel-head { flex-direction: column; }
}
@media (max-width: 600px) {
  .ti-cards { grid-template-columns: 1fr 1fr; }
  .ti-card { padding: 12px; }
  .ti-card-value { font-size: 1.2rem; }
}
