:root {
    --bg: #0e1117;
    --panel: #161b24;
    --panel-2: #1c2230;
    --line: #262e3d;
    --text: #e6e9ef;
    --muted: #8b95a7;
    --accent: #7c8cff;
    --accent-soft: rgba(124, 140, 255, .15);
    --red: #ff6b6b;
    --orange: #ffb454;
    --green: #4cd08a;
    --blue: #5ab0ff;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 18px; letter-spacing: .2px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 2px; }
.nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--muted); margin-bottom: 4px; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.main { padding: 20px 28px 60px; min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 24px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.userbox form { margin: 0; }

/* ------------------------------------------------------------ controls */
.btn, button.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 13px; cursor: pointer; font: inherit; display: inline-block; }
.btn:hover { background: #232b3b; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0e18; font-weight: 600; }
.btn.small { padding: 4px 9px; font-size: 12px; }

input[type=text], input[type=email], input[type=password], select {
    background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; min-width: 0;
}
input:focus, select:focus { outline: 1px solid var(--accent); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.pills { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.pills a { padding: 7px 13px; color: var(--muted); border-right: 1px solid var(--line); }
.pills a:last-child { border-right: 0; }
.pills a.active { background: var(--accent-soft); color: var(--text); }
.pills a:hover { text-decoration: none; color: var(--text); }
.check { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.charts { grid-template-columns: 2fr 1fr 1fr 1fr; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 1200px) { .grid.charts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; display: flex; gap: 12px; align-items: center; }
    .nav { display: flex; gap: 6px; }
    .grid.charts, .grid.two { grid-template-columns: 1fr; }
    .main { padding: 16px; }
}

.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ------------------------------------------------------------ breakdown */
.bd { list-style: none; margin: 0; padding: 0; }
.bd li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-bottom: 9px; font-size: 13px; }
.bd .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.bd .bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bd .bar i { display: block; height: 100%; background: var(--accent); }
.bd li.other .bar i { background: #4b5468; }
.empty { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart rect.b { fill: var(--accent); }
.chart rect.b:hover { fill: #aab4ff; }
.chart line { stroke: var(--line); stroke-width: 1; }

/* ------------------------------------------------------------ table */
.tablecard { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .015); }
.tight td { padding: 8px 14px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.ipv { font-weight: 600; font-size: 15px; }
.scroll { overflow-x: auto; }

.tag { display: inline-block; font-size: 11px; border-radius: 6px; padding: 2px 7px; background: var(--panel-2); border: 1px solid var(--line); margin: 0 4px 4px 0; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
.tag b { color: var(--muted); font-weight: 500; margin-right: 4px; }
.tag.red { color: var(--red); border-color: rgba(255, 107, 107, .4); background: rgba(255, 107, 107, .08); }
.tag.green { color: var(--green); border-color: rgba(76, 208, 138, .4); background: rgba(76, 208, 138, .08); }
.tag.orange { color: var(--orange); border-color: rgba(255, 180, 84, .4); background: rgba(255, 180, 84, .08); }
.ctxrow { margin-bottom: 3px; }
.ctxpath { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; word-break: normal; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pager .links { display: flex; gap: 8px; }
.pager .off { opacity: .35; pointer-events: none; }

details.meta summary { cursor: pointer; color: var(--blue); font-size: 12px; }
details.meta dl { margin: 8px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 12px; }
details.meta dt { color: var(--muted); }
details.meta dd { margin: 0; word-break: break-all; }

.crumb { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ------------------------------------------------------------ login */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 360px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-size: 12px; color: var(--muted); }
.field input { width: 100%; }
.err { color: var(--red); font-size: 12px; margin-top: 5px; }
.alert-err { background: rgba(255, 107, 107, .08); border: 1px solid rgba(255, 107, 107, .4); color: var(--text); border-radius: 10px; padding: 14px 16px; }
.alert-err pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ link "+N more" & daftar target */
a.more { font-size: 12px; display: inline-block; margin-top: 2px; }
.targetlist { max-height: 360px; overflow: auto; columns: 2 420px; column-gap: 28px; }
.targetlist .ctxrow { break-inside: avoid; }

/* ------------------------------------------------------------ DataTables (tema gelap) */
.dt-wrap { position: relative; }
.dt-container { position: relative; font-size: 14px; }
.dt-layout-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; }
.dt-layout-row.dt-layout-table { padding: 0; display: block; overflow-x: auto; }
.dt-layout-cell { display: flex; align-items: center; gap: 8px; }
.dt-layout-cell.dt-layout-full { width: 100%; display: block; }
.dt-length, .dt-search { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dt-length label, .dt-search label { margin: 0; }
.dt-input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font: inherit; }
.dt-search .dt-input { min-width: 220px; }
.dt-info { color: var(--muted); font-size: 13px; }
.dt-paging nav { display: flex; gap: 4px; flex-wrap: wrap; }
.dt-paging-button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 4px 11px; cursor: pointer; font: inherit; font-size: 13px; }
.dt-paging-button:hover:not(.disabled):not(.current) { background: #232b3b; }
.dt-paging-button.current { background: var(--accent-soft); border-color: var(--accent); }
.dt-paging-button.disabled { opacity: .35; cursor: default; }
.dt-paging .ellipsis { color: var(--muted); padding: 4px 4px; }
.dt-processing { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; color: var(--text); z-index: 5; }

table.dataTable { width: 100%; }
table.dataTable thead th { position: relative; }
table.dataTable thead th.dt-orderable-asc, table.dataTable thead th.dt-orderable-desc { cursor: pointer; }
table.dataTable thead th.dt-orderable-asc:hover, table.dataTable thead th.dt-orderable-desc:hover { color: var(--text); }
.dt-column-header { display: flex; align-items: center; gap: 6px; }
.dt-column-order { font-size: 10px; line-height: 1; }
th.dt-orderable-asc .dt-column-order::after, th.dt-orderable-desc .dt-column-order::after { content: "\2195"; opacity: .35; }
th.dt-ordering-asc .dt-column-order::after { content: "\25B2"; opacity: 1; color: var(--accent); }
th.dt-ordering-desc .dt-column-order::after { content: "\25BC"; opacity: 1; color: var(--accent); }
table.dataTable tbody td.dt-empty { text-align: center; color: var(--muted); padding: 30px; }

/* lebar kolom tabel Alerts Explorer */
#alerts-table th, #alerts-table td { padding-left: 10px; padding-right: 10px; }
#alerts-table td:nth-child(4) { min-width: 190px; }
#alerts-table td:nth-child(5) { min-width: 290px; }
#alerts-table td:nth-child(6) { min-width: 220px; }
#alerts-table td:nth-child(6) .tag { max-width: 230px; }

/* ------------------------------------------------------------ aksi cabut ban */
form.inline { display: inline; margin: 0; }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 107, .45); }
.btn.danger:hover { background: rgba(255, 107, 107, .12); }
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; border: 1px solid var(--line); }
.flash.ok { color: var(--green); border-color: rgba(76, 208, 138, .4); background: rgba(76, 208, 138, .08); }
.flash.bad { color: var(--red); border-color: rgba(255, 107, 107, .4); background: rgba(255, 107, 107, .08); }

/* ------------------------------------------------------------ halaman Allowlist */
.listhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.listhead .tag { margin: 0; }
textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }
textarea:focus { outline: 1px solid var(--accent); }
.field input[type=text] { width: 100%; }
dialog.modal { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; width: min(580px, 94vw); max-height: 92vh; overflow: auto; }
dialog.modal::backdrop { background: rgba(0, 0, 0, .65); }
dialog.modal h2 { margin: 0 0 6px; font-size: 18px; }
dialog.modal .row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
dialog.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
dialog.modal [hidden] { display: none !important; }
pre.cmd { margin: 0 0 8px; padding: 10px 12px; background: #0a0d13; border: 1px solid var(--line); border-radius: 8px; color: var(--green); font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

/* Menu Sumber Log */
table th.num, table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------ ban manual, laporan, status */
.bancard summary { cursor: pointer; }
.bancard summary::-webkit-details-marker { color: var(--muted); }
.banform { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }
.banform .field { margin: 0; flex: 1 1 150px; }
.banform select { width: 100%; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars .bar { flex: 1; min-width: 6px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 4px 4px 0 0; position: relative; }
.bars .bar span { position: absolute; top: -17px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.barlabels { display: flex; gap: 6px; }
.barlabels div { flex: 1; min-width: 6px; text-align: center; font-size: 10px; color: var(--muted); margin-top: 4px; overflow: hidden; }
.meter { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
@media print { .sidebar, .topbar .userbox, .filters, .btn { display: none !important; } .app { display: block; } }
