/* BotBlocker dashboard — light theme.
   Tokens follow the chart-chrome roles: page plane, card surface, ink
   hierarchy, hairlines, one interactive accent. */

:root {
  --plane: #f9f9f7;          /* page background */
  --surface: #fcfcfb;        /* cards, tables */
  --ink: #0b0b0b;            /* primary text */
  --ink-2: #52514e;          /* secondary text */
  --muted: #898781;          /* labels, footers */
  --hairline: #e1e0d9;       /* gridlines, dividers */
  --ring: rgba(11, 11, 11, .10);
  --accent: #2a78d6;         /* interactive + chart hue */
  --accent-deep: #1c5cab;
  --danger: #d03b3b;
  --good: #006300;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .05), 0 4px 16px rgba(11, 11, 11, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar ---------------------------------------------------------- */

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #1a1a19; color: #fff;
  padding: 0 28px; height: 54px;
}
.topbar nav { display: flex; gap: 16px; align-items: center; }
.topbar .muted { color: #c3c2b7; font-size: 13px; }
.brand {
  color: #fff; text-decoration: none; font-weight: 650; font-size: 15px;
  letter-spacing: .01em; display: flex; align-items: center; gap: 8px;
}

main { max-width: 1080px; margin: 32px auto 64px; padding: 0 20px; }
footer { text-align: center; padding: 28px; color: var(--muted); font-size: 12.5px; }

/* ---- type ------------------------------------------------------------- */

h1 { font-size: 21px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 18px; }
h1 .muted { font-weight: 400; font-size: 14px; }
h2 { font-size: 15px; font-weight: 600; margin: 32px 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 14px; color: var(--ink-2);
     text-transform: uppercase; letter-spacing: .05em; }
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
code {
  background: #f0efec; border: 1px solid var(--hairline);
  padding: 1px 6px; border-radius: 5px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
pre {
  background: #1a1a19; color: #e7e6df; padding: 16px 18px;
  border-radius: var(--radius); overflow-x: auto;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}
pre code { background: none; border: 0; color: inherit; padding: 0; }

.alert {
  background: #fbe7e7; color: #a32c2c; border: 1px solid #f3cdcd;
  padding: 10px 14px; border-radius: 8px; font-size: 13.5px;
}
.success {
  background: #e6f4e6; color: var(--good); border: 1px solid #cfe8cf;
  padding: 10px 14px; border-radius: 8px; font-size: 13.5px;
}

/* ---- site nav --------------------------------------------------------- */

.site-nav {
  display: flex; gap: 4px; align-items: center;
  margin: -6px 0 24px; padding: 4px;
  background: #f0efec; border-radius: 999px; width: max-content;
}
.site-nav a {
  padding: 6px 14px; border-radius: 999px; color: var(--ink-2);
  font-size: 13px; font-weight: 500;
}
.site-nav a:hover { text-decoration: none; color: var(--ink); }
.site-nav a.active {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 2px rgba(11, 11, 11, .08); border: 1px solid var(--ring);
}
.site-nav a.back { color: var(--muted); margin-right: 4px; }

/* ---- tables ----------------------------------------------------------- */

table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
th, td {
  text-align: left; padding: 10px 14px; vertical-align: middle;
  border-bottom: 1px solid var(--hairline); font-size: 13.5px;
}
th {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface);
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: #f7f7f4; }
table.compact th, table.compact td { padding: 7px 12px; font-size: 12.5px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.trunc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disabled-row td { opacity: .45; }
.row-actions { white-space: nowrap; text-align: right; }
td.empty, td.muted { color: var(--muted); }

/* ---- buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: 7px 16px; border-radius: 8px; cursor: pointer;
  font: 500 13.5px/1.2 inherit; text-decoration: none;
  transition: background .12s;
}
.btn:hover { background: var(--accent-deep); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-sm { padding: 4px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(208, 59, 59, .35); }
.btn-danger:hover { background: #fbe7e7; }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .25); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: var(--ring); }
.btn-quiet:hover { background: #f0efec; }
.inline { display: inline; }

/* ---- forms ------------------------------------------------------------ */

label { display: block; margin: 12px 0 5px; font-weight: 500; font-size: 13px; color: var(--ink-2); }
label.check { display: flex; gap: 8px; align-items: baseline; font-weight: 400; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], select {
  width: 100%; max-width: 420px; padding: 8px 11px;
  border: 1px solid var(--hairline); border-radius: 8px;
  font: 13.5px/1.4 inherit; background: var(--surface); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form-row { display: flex; gap: 8px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.form-row input, .form-row select { width: auto; }
.rule-form, .settings-form {
  background: var(--surface); border: 1px solid var(--ring);
  padding: 6px 22px 22px; border-radius: var(--radius);
  max-width: 660px; box-shadow: var(--shadow);
}
.rule-form .btn, .settings-form .btn { margin-top: 18px; }

.auth-card {
  background: var(--surface); border: 1px solid var(--ring);
  max-width: 360px; margin: 9vh auto; padding: 30px 34px 26px;
  border-radius: 14px; box-shadow: var(--shadow);
}
.auth-card h1 { margin-bottom: 6px; }
.auth-card input { width: 100%; max-width: none; }
.auth-card .btn { width: 100%; margin-top: 18px; padding: 9px; }
.auth-card p.muted { font-size: 13px; }

/* ---- cards & layout --------------------------------------------------- */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.card.wide { grid-column: 1 / -1; }
.card table { border: 0; box-shadow: none; border-radius: 0; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 820px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius); padding: 14px 18px 12px; box-shadow: var(--shadow);
}
.tile .label { font-size: 11.5px; font-weight: 600; color: var(--muted);
               text-transform: uppercase; letter-spacing: .06em; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--ink-2); }
.tile.bad .value { color: var(--danger); }

/* ---- bar chart rows (magnitude → one hue, thin marks, rounded data-end) */

.bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.bar-label { width: 118px; font-size: 12.5px; color: var(--ink-2); flex-shrink: 0; }
.bar { flex: 1; background: #f0efec; border-radius: 4px; height: 10px; }
.bar-fill {
  background: var(--accent); height: 100%;
  border-radius: 0 4px 4px 0; min-width: 3px;
}
.bar-n { width: 52px; text-align: right; font-size: 12px; color: var(--ink-2);
         font-variant-numeric: tabular-nums; }

/* ---- tags ------------------------------------------------------------- */

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 550; letter-spacing: .01em;
  background: #f0efec; color: var(--ink-2); border: 1px solid transparent;
}
.cat-search_engine { background: #e6f4e6; color: #006300; border-color: #cfe8cf; }
.cat-good_bot      { background: #e3eefb; color: #1c5cab; border-color: #cbdff6; }
.cat-fake_bot      { background: #fbe7e7; color: #a32c2c; border-color: #f3cdcd; }
.cat-scraper       { background: #fdeee6; color: #8f451c; border-color: #f6d9c8; }
.cat-headless      { background: #eceafa; color: #4a3aa7; border-color: #d9d4f2; }
.cat-suspected_bot { background: #fdf3d9; color: #7d5c00; border-color: #f2e2b0; }
.cat-human         { background: #f0efec; color: #52514e; border-color: #e1e0d9; }
.cat-verdict       { background: #fbe7e7; color: #a32c2c; border-color: #f3cdcd; }

.act-block, .act-blackhole { background: #fbe7e7; color: #a32c2c; border-color: #f3cdcd; }
.act-redirect              { background: #fdf3d9; color: #7d5c00; border-color: #f2e2b0; }
.act-allow                 { background: #e6f4e6; color: #006300; border-color: #cfe8cf; }
.act-log                   { background: #e3eefb; color: #1c5cab; border-color: #cbdff6; }

/* ---- charts (Chart.js canvases) --------------------------------------- */

.chart-box { position: relative; width: 100%; }
.chart-box-donut { height: 150px; width: 150px; flex-shrink: 0; }
.swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 5px; vertical-align: -1px;
}

/* ---- donut legend (identity + drill-down links live here, not in canvas) */

.donut-wrap { display: flex; gap: 20px; align-items: center; }
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: 12.5px; min-width: 0; flex: 1; }
.donut-legend li {
  display: flex; align-items: center; gap: 7px; padding: 3px 0;
  white-space: nowrap; overflow: hidden;
}
.donut-legend li a, .donut-legend li > span:first-of-type { overflow: hidden; text-overflow: ellipsis; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.donut-legend .muted { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.donut-legend .swatch { flex-shrink: 0; margin-right: 0; }

/* ---- contained tables & filter chips ---------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table-wrap > table { min-width: 640px; }
.card .table-wrap > table { min-width: 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--ring);
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px;
  box-shadow: var(--shadow);
}
.chip a { color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1; }
.chip a:hover { color: var(--danger); }
.chip-clear { color: var(--ink-2); }
.delete-events { margin-left: auto; }
.filter-bar .inline-check { margin: 0; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.summary-card { margin-bottom: 16px; }
.summary-card h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* quick-block: tiny ⊘ button beside IPs / ASNs / countries */
.quick-block { display: inline; margin-left: 6px; }
.block-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 13px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .1s, color .1s, background .1s;
  vertical-align: middle;
}
tr:hover .block-btn, .bar-row:hover .block-btn { opacity: 1; }
.block-btn:hover {
  color: var(--danger); background: #fbe7e7; border-color: rgba(208, 59, 59, .35);
}
.block-btn:focus-visible { opacity: 1; outline: 2px solid var(--danger); outline-offset: 1px; }

/* ---- simple-datatables theme overrides -------------------------------- */

.datatable-wrapper .datatable-top { padding: 0 0 10px; display: flex; justify-content: space-between; gap: 10px; }
.datatable-wrapper .datatable-bottom { padding: 10px 0 0; display: flex; justify-content: space-between; align-items: center; }
.datatable-wrapper .datatable-container { border: 0; }
.datatable-input, .datatable-selector {
  padding: 6px 10px; border: 1px solid var(--hairline); border-radius: 8px;
  font: 13px/1.4 inherit; background: var(--surface); color: var(--ink);
}
.datatable-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.datatable-info { color: var(--muted); font-size: 12.5px; }
.datatable-pagination ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.datatable-pagination li a, .datatable-pagination li button {
  display: inline-block; min-width: 28px; text-align: center; padding: 4px 8px;
  border-radius: 7px; border: 1px solid var(--ring); background: var(--surface);
  font-size: 12.5px; color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.datatable-pagination li.datatable-active a, .datatable-pagination li.datatable-active button {
  background: var(--accent); color: #fff; border-color: transparent;
}
.datatable-pagination li a:hover { background: #f0efec; text-decoration: none; }
.datatable-pagination li.datatable-active a:hover { background: var(--accent-deep); }
.datatable-sorter { color: inherit; }
th button.datatable-sorter {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  text-transform: inherit; letter-spacing: inherit; cursor: pointer;
}

/* ---- misc ------------------------------------------------------------- */

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.empty-state {
  background: var(--surface); border: 1px dashed var(--hairline);
  border-radius: var(--radius); padding: 36px; text-align: center; color: var(--muted);
}
.pager { display: flex; gap: 6px; margin-top: 14px; }
.pager a, .pager strong {
  min-width: 30px; text-align: center; padding: 4px 8px; border-radius: 7px;
  border: 1px solid var(--ring); background: var(--surface); font-size: 13px;
}
.pager strong { background: var(--accent); color: #fff; border-color: transparent; }
