/* ============================================================
   SHODAN DASHBOARD — style type WorldMonitor (dense, sombre)
   ============================================================ */
:root {
    --bg0: #05070d;
    --bg1: #0a0e17;
    --bg2: #101624;
    --bg3: #182032;
    --line: #1f2a42;
    --txt: #dbe4f4;
    --muted: #7c8db0;
    --accent: #2ee6a8;
    --accent2: #39c0ff;
    --warn: #ffb454;
    --danger: #ff5c5c;
    --critical: #ff3b6b;
    --ok: #2ee6a8;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--bg0);
    color: var(--txt);
    font-family: var(--font);
    font-size: 14px;
    min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 18px;
    background: var(--bg1);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 900;
    flex-wrap: wrap;
}
.logo {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 1px;
    white-space: nowrap;
}
.logo .dot { color: var(--critical); }
.logo small { color: var(--muted); font-weight: 400; margin-left: 6px; }

.searchbar {
    flex: 1 1 320px;
    display: flex;
    gap: 8px;
    max-width: 720px;
}
.searchbar input {
    flex: 1;
    background: var(--bg2);
    border: 1px solid var(--line);
    color: var(--txt);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--mono);
    outline: none;
}
.searchbar input:focus { border-color: var(--accent2); }
.searchbar select {
    background: var(--bg2);
    border: 1px solid var(--line);
    color: var(--txt);
    border-radius: 6px;
    padding: 0 8px;
    font-size: 13px;
}
.btn {
    background: var(--bg3);
    border: 1px solid var(--line);
    color: var(--txt);
    padding: 9px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all .15s;
    white-space: nowrap;
}
.btn:hover { border-color: var(--accent2); color: var(--accent2); }
.btn.primary { background: var(--accent); color: #04120c; border-color: var(--accent); }
.btn.primary:hover { background: #3afab2; }
.btn.warn { background: var(--warn); color: #1a1000; border-color: var(--warn); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.preset { padding: 4px 10px; font-size: 11.5px; font-weight: 500; border-color: var(--line); color: var(--accent2); }
.preset:hover { border-color: var(--accent); background: rgba(58, 250, 178, .06); }

.top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Géolocalisation ---------- */
.geo-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 900px) { .geo-layout { grid-template-columns: 1fr; } }
.geo-map { height: 280px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); z-index: 1; }
.geo-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
@media (max-width: 900px) { .geo-meta { grid-template-columns: 1fr; } }
.geo-meta .m { font-size: 12px; }
.geo-meta .k { color: var(--muted); font-size: 11px; }
.geo-meta .v { color: var(--txt); word-break: break-word; }
.geo-btn {
    background: none; border: 1px solid var(--line); border-radius: 4px;
    cursor: pointer; font-size: 11px; padding: 1px 5px; margin-left: 5px;
    vertical-align: middle; color: var(--accent2);
}
.geo-btn:hover { border-color: var(--accent); background: rgba(58, 250, 178, .08); }
.banner-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.mini { padding: 4px 7px; border: 1px solid var(--line); background: var(--bg2); color: var(--txt); border-radius: 5px; }
.credit-gauge {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg2); border: 1px solid var(--line);
    padding: 6px 12px; border-radius: 6px; font-size: 12px; white-space: nowrap;
}
.credit-gauge .num { font-family: var(--mono); color: var(--warn); font-weight: 700; }
.credit-gauge .bar { width: 60px; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.credit-gauge .bar i { display: block; height: 100%; background: var(--accent); }

/* ---------- Layout ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 14px;
    padding: 14px 18px;
    align-items: start;
}
@media (max-width: 1100px) {
    .layout { grid-template-columns: 1fr; }
}

/* ---------- Tiles stats ---------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.tile {
    background: var(--bg1);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
}
.tile .t-num {
    font-family: var(--mono);
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}
.tile .t-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }
.tile.warn .t-num { color: var(--warn); }
.tile.danger .t-num { color: var(--critical); }
.tile.accent2 .t-num { color: var(--accent2); }

/* ---------- Carte ---------- */
.map-wrap {
    background: var(--bg1);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}
#map { height: 520px; width: 100%; background: #06090f; }
.map-legend {
    position: absolute;
    bottom: 12px; left: 12px; z-index: 500;
    background: rgba(10, 14, 23, .92);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    display: flex; flex-direction: column; gap: 4px;
}
.map-legend b { color: var(--muted); font-weight: 600; }
.map-legend .li { display: flex; align-items: center; gap: 6px; }
.map-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.map-dot.r1 { background: var(--ok); }
.map-dot.r2 { background: var(--warn); }
.map-dot.r3 { background: var(--critical); }
.map-empty {
    position: absolute; inset: 0; z-index: 400;
    display: flex; align-items: center; justify-content: center;
    background: rgba(6, 9, 15, .88); color: var(--muted);
    font-size: 13px; text-align: center; padding: 20px;
}
.map-empty.hidden { display: none; }

/* ---------- Sections ---------- */
.panel {
    background: var(--bg1);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 14px;
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--bg2);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .4px;
}
.panel-head .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.panel-body { padding: 12px 14px; }
.panel-body.no-pad { padding: 0; }

/* ---------- Tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
    text-align: left; color: var(--muted); font-weight: 600;
    padding: 7px 10px; border-bottom: 1px solid var(--line);
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    position: sticky; top: 0; background: var(--bg1);
}
.tbl td { padding: 7px 10px; border-bottom: 1px solid rgba(31, 42, 66, .5); vertical-align: top; }
.tbl tr:hover td { background: rgba(24, 32, 50, .5); }
.tbl .mono { font-family: var(--mono); font-size: 12px; }
.tbl .num { font-family: var(--mono); text-align: right; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600;
}
.badge.port { background: var(--bg3); color: var(--accent2); font-family: var(--mono); margin: 1px 2px 1px 0; }
.badge.risk1 { background: rgba(46, 230, 168, .12); color: var(--ok); }
.badge.risk2 { background: rgba(255, 180, 84, .12); color: var(--warn); }
.badge.risk3 { background: rgba(255, 92, 92, .15); color: var(--critical); }
.badge.kind { background: rgba(57, 192, 255, .12); color: var(--accent2); }

/* ---------- Feed ---------- */
.feed { max-height: 420px; overflow-y: auto; }
.feed .item {
    display: flex; gap: 10px; padding: 9px 14px;
    border-bottom: 1px solid rgba(31, 42, 66, .5);
    font-size: 12.5px;
}
.feed .item:last-child { border-bottom: none; }
.feed .time { font-family: var(--mono); color: var(--muted); font-size: 11px; white-space: nowrap; }
.feed .item .q { font-family: var(--mono); color: var(--accent); }
.feed .item.error { border-left: 3px solid var(--critical); }

/* ---------- Host detail ---------- */
.host-detail {
    background: var(--bg1);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 14px;
}
.host-detail h3 { font-size: 15px; margin-bottom: 10px; font-family: var(--mono); }
.host-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-bottom: 12px; }
.host-meta .m { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.host-meta .m .k { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.host-meta .m .v { font-size: 13px; margin-top: 2px; word-break: break-all; }

/* ---------- Formulaire watch / saves ---------- */
.watch-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.watch-form input, .watch-form select {
    background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
    border-radius: 6px; padding: 8px 10px; font-size: 13px; outline: none;
}
.watch-form input:focus { border-color: var(--accent2); }
.watch-form input[type=text] { flex: 1 1 160px; font-family: var(--mono); }

/* ---------- Briefs ---------- */
.brief-content {
    background: var(--bg0);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    font-family: var(--font);
    max-height: 480px;
    overflow-y: auto;
}
.brief-content h2 { color: var(--accent); font-size: 14px; margin: 10px 0 6px; }
.brief-content h3 { color: var(--accent2); font-size: 13px; margin: 8px 0 4px; }

/* ---------- Alertes / toasts ---------- */
#toast {
    position: fixed; top: 64px; right: 18px; z-index: 1200;
    display: flex; flex-direction: column; gap: 8px; max-width: 420px;
}
.toast-item {
    background: var(--bg2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
    border-radius: 6px; padding: 10px 14px; font-size: 13px;
    box-shadow: 0 6px 24px rgba(0,0,0,.5);
    animation: slidein .2s ease;
}
.toast-item.err { border-left-color: var(--critical); }
.toast-item.warn { border-left-color: var(--warn); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Spinner ---------- */
.spin {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid var(--line); border-top-color: var(--accent);
    border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -2px;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; background: var(--bg1); }
.tabs button {
    background: none; border: none; color: var(--muted);
    padding: 10px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
    border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.tabview { display: none; }
.tabview.active { display: block; }

/* ---------- Grid 2 cols ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Divers ---------- */
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.mt10 { margin-top: 10px; }
.mb10 { margin-bottom: 10px; }
.hidden { display: none !important; }

/* Leaflet dark fixes */
.leaflet-container { background: #06090f; font-family: var(--font); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg2); color: var(--txt); }
.leaflet-popup-content { font-size: 12px; }
.leaflet-control-zoom a { background: var(--bg2) !important; color: var(--txt) !important; border-color: var(--line) !important; }
.leaflet-bar { border-color: var(--line) !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg0); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--line); }
