/* n2n migration dashboard. One stylesheet, no framework. */

:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #59636e;
  --border: #d8dee4;
  --border-soft: #eaeef2;
  --zebra: #f9fafb;
  --accent: #1c4f25;          /* Serso dark green */
  --accent-hover: #163f1d;
  --accent-soft: #e8efe9;
  --green: #1a7f37;
  --green-bg: #dafbe1;
  --orange: #9a6700;
  --orange-bg: #fff1c2;
  --red: #b42318;
  --red-bg: #ffebe9;
  --grey: #59636e;
  --grey-bg: #eaeef2;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ── Layout ─────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; min-width: 1280px; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 18px 18px; color: var(--text); }
.sidebar .brand img { width: 30px; height: 30px; }
.sidebar .brand span { font-weight: 600; font-size: 15px; }
.sidebar .brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.sidebar nav a {
  display: block; padding: 7px 18px; color: var(--text); border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.sidebar nav .section {
  padding: 16px 18px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px; padding: 0 24px;
  display: flex; align-items: center; gap: 16px; justify-content: flex-end;
  position: sticky; top: 0; z-index: 5;
}
.topbar .sync { color: var(--muted); }
.topbar .sync.late { color: var(--red); font-weight: 600; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.topbar form { margin: 0; }
.content { padding: 24px; max-width: 1800px; }

/* ── Cards, KPIs, blocks ────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ── Forms and buttons ──────────────────────────────── */

label { display: block; font-weight: 600; margin: 10px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 9px; background: var(--surface); width: 100%; max-width: 480px;
}
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 140px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input.code { font-family: var(--mono); font-size: 20px; letter-spacing: .2em; max-width: 200px; }
select.small, input.small { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 6px 14px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--surface); color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
form.inline { display: inline; margin: 0; }

.secret-state { display: flex; align-items: center; gap: 10px; }
details.replace summary { cursor: pointer; color: var(--accent); font-weight: 600; display: inline; }
details.replace[open] summary { margin-bottom: 6px; }

/* ── Messages ───────────────────────────────────────── */

.flash { border-radius: var(--radius); padding: 9px 12px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { background: var(--green-bg); border-color: #aceebb; }
.flash.warn { background: var(--orange-bg); border-color: #f5d978; }
.flash.error { background: var(--red-bg); border-color: #ffcecb; }
.test-result.ok { color: var(--green); font-weight: 600; }
.test-result.error { color: var(--red); font-weight: 600; }

/* ── Badges, labels, progress ───────────────────────── */

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.grey { background: var(--grey-bg); color: var(--grey); }
.tag {
  display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface);
}
.tag.weak { border-color: var(--orange); color: var(--orange); }

.progress { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.progress .bar { width: 90px; height: 8px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--accent); }

/* ── Tables ─────────────────────────────────────────── */

.table-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.table-tools input[type=search] {
  font: inherit; border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 9px; width: 280px;
}
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto; max-height: calc(100vh - 220px);
}
table.data { border-collapse: collapse; width: 100%; }
table.data th, table.data td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: top; white-space: nowrap; }
table.data td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg); font-weight: 600; font-size: 12.5px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.data th a { color: var(--text); }
table.data th .arrow { color: var(--muted); font-size: 10px; }
table.data tbody tr:nth-child(even) { background: var(--zebra); }
table.data tbody tr:hover { background: var(--accent-soft); }
table.data td.num, table.data th.num { text-align: right; }
table.data td.empty { color: var(--muted); text-align: center; padding: 24px; }
table.data td pre { margin: 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; max-width: 520px; max-height: 120px; overflow: auto; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; color: var(--muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs a { padding: 8px 14px; color: var(--text); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--surface); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chips a { border: 1px solid var(--border); border-radius: 12px; padding: 1px 10px; background: var(--surface); color: var(--text); font-size: 12.5px; }
.chips a.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chips a:hover { text-decoration: none; }

.bulkbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 8px;
}

/* ── Dialog ─────────────────────────────────────────── */

dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; max-width: 520px; }
dialog::backdrop { background: rgba(31, 35, 40, .35); }

/* ── Login pages ────────────────────────────────────── */

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth .card { width: 420px; padding: 28px; }
.auth .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth .brand img { width: 34px; height: 34px; }
.auth input[type=text], .auth input[type=password] { max-width: none; }
.qr { background: #fff; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); width: 220px; }
.qr svg { width: 100%; height: auto; display: block; }
ol.codes { columns: 2; font-family: var(--mono); font-size: 15px; padding-left: 22px; }

/* ── HTMX indicator: the only animation ─────────────── */

.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
