:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #16202b;
  --muted: #64748b;
  --line: #dbe2ea;
  --accent: #1f4e79;
  --accent-2: #2f6ea5;
  --green: #157347;
  --green-bg: #e3f4ea;
  --red: #b02a37;
  --red-bg: #fbe6e8;
  --amber: #9a6700;
  --amber-bg: #fff4d6;
  --grey-bg: #eef1f5;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- topbar ---------- */
.topbar {
  background: #0f2a44;
  color: #fff;
  border-bottom: 3px solid var(--accent-2);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: #fff; color: #0f2a44; font-weight: 800; letter-spacing: .08em;
  font-size: 12px; padding: 5px 8px; border-radius: 5px;
}
.brand-text { font-weight: 600; font-size: 16px; }
.brand-text small { display: block; font-weight: 400; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a { color: #cfe0f0; padding: 8px 12px; border-radius: 7px; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.nav .nav-exit { color: #9fb6cb; }

/* ---------- layout ---------- */
main.wrap { padding-top: 20px; padding-bottom: 40px; }
.footer { border-top: 1px solid var(--line); background: #fff; }
.footer .wrap { display: flex; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; font-size: 13px; color: var(--muted); }

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.card .num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.card .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.card.green .num { color: var(--green); }
.card.red .num { color: var(--red); }
.card.amber .num { color: var(--amber); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 18px;
}
.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
input[type=text], input[type=password], input[type=search], textarea, select, input[type=file] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(47,110,165,.35); border-color: var(--accent-2); }
textarea { resize: vertical; min-height: 92px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

button, .btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 9px 14px; border-radius: 8px; font: inherit; font-weight: 600;
}
button:hover, .btn:hover { background: var(--accent-2); border-color: var(--accent-2); text-decoration: none; color: #fff; }
button.ghost, .btn.ghost { background: #fff; color: var(--accent); border-color: var(--line); font-weight: 500; }
button.ghost:hover, .btn.ghost:hover { background: #f0f5fa; color: var(--accent); }
button.danger { background: #fff; color: var(--red); border-color: #e7bfc4; font-weight: 500; }
button.danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
button.small, .btn.small { padding: 5px 9px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }

/* ---------- flash ---------- */
.flash { border-radius: 8px; padding: 11px 14px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--green-bg); border-color: #b9e0c9; color: #10522f; }
.flash.err { background: var(--red-bg); border-color: #efc0c6; color: #7d1a24; }
.flash.warn { background: var(--amber-bg); border-color: #f0dca4; color: #7a5300; }

/* ---------- table ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th {
  position: sticky; top: 0; background: #eef2f7; z-index: 2;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #475569; font-weight: 600;
  white-space: nowrap;
}
table.data tbody tr:hover { background: #f7fafd; }
table.data td.idx { color: var(--muted); font-size: 12px; text-align: right; width: 52px; }
table.data td.url { max-width: 520px; word-break: break-all; }
table.data td.url .u-title { color: var(--muted); font-size: 12px; margin-top: 3px; }
table.data tr.is-removed td { background: #fcf7f8; }
table.data tr.is-off td { background: #f8f9fb; color: #55616e; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; white-space: nowrap; padding: 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid transparent;
}
.b-alive { background: var(--green-bg); color: var(--green); border-color: #bfe3cd; }
.b-removed { background: var(--red-bg); color: var(--red); border-color: #f0c4c9; }
.b-dead { background: #fdeccd; color: #8a5a00; border-color: #f0d69a; }
.b-error { background: var(--amber-bg); color: var(--amber); border-color: #f0dca4; }
.b-new { background: var(--grey-bg); color: #475569; border-color: #d9e0e8; }
.b-off { background: #e8eaf0; color: #3e4a5a; border-color: #cfd5e0; }

.kind { font-size: 11px; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line); color: #475569; background: #f8fafc; white-space: nowrap; }
.k-wb { color: #6b1a8a; border-color: #e2cdee; background: #faf3fd; }
.k-ym { color: #8a1a1a; border-color: #f0cfcf; background: #fdf4f4; }
.k-oz { color: #1a4a8a; border-color: #cddcee; background: #f3f7fd; }

.tag { display: inline-block; font-size: 12px; color: var(--muted); }
.tag.warn { color: var(--amber); font-weight: 600; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .f { min-width: 140px; }
.filters .f.grow { flex: 1 1 260px; }
.filters label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---------- progress ---------- */
.progress { display: none; margin-top: 12px; }
.progress.on { display: block; }
.progress .bar { height: 10px; background: var(--grey-bg); border-radius: 999px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--accent-2); transition: width .25s; }
.progress .txt { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f2a44; padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 26px; box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-box button { width: 100%; justify-content: center; margin-top: 6px; }

/* ---------- link card ---------- */
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- report ---------- */
.report-head { border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 18px; }
.report-head .org { font-weight: 700; }
.report-summary { display: flex; gap: 24px; flex-wrap: wrap; margin: 14px 0; font-size: 14px; }
.report-summary b { font-size: 16px; }

@media print {
  .topbar, .footer, .no-print, .nav, .actions, form { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main.wrap { padding: 0; max-width: none; }
  .panel { border: none; padding: 0; margin: 0 0 12px; }
  .table-wrap { border: none; overflow: visible; }
  table.data th, table.data td { padding: 4px 6px; border-bottom: 1px solid #bbb; font-size: 9.5pt; }
  table.data thead th { position: static; background: #eee; }
  a { color: #000; text-decoration: none; }
}

/* ---------- misc ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.checkbox-cell { width: 30px; }
