:root {
  --bg: #f4f4f2;
  --card: #fff;
  --text: #1c1c1b;
  --muted: #6b6b66;
  --border: #d8d8d2;
  --accent: #1d5f8a;
  --error: #a32d2d;
  --ok: #1d7a52;
  --warn: #96610a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar nav, .topbar-right { display: flex; align-items: center; gap: 1.25rem; }
.topbar a { color: var(--text); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.brand { font-weight: 600; }

main { max-width: 900px; margin: 2rem auto; padding: 0 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem;
}

.card.narrow { max-width: 460px; margin: 0 auto; }
.card-header { display: flex; justify-content: space-between; align-items: center; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; }

label { display: block; margin: 1rem 0 0.35rem; font-weight: 500; }
label.checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
label.checkbox input { width: auto; }

input, select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font-size: 1.05rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input:disabled { background: var(--bg); color: var(--muted); }

button, .button {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link {
  margin: 0; padding: 0; border: 0; background: none;
  color: var(--accent); text-decoration: underline; font-size: inherit;
}

form.inline { display: inline; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }

.tag { font-size: 0.85rem; padding: 0.15rem 0.5rem; border-radius: 999px; }
.tag.ok { background: #e1f5ee; color: var(--ok); }
.tag.warn { background: #faeeda; color: var(--warn); }
.tag.off { background: #eee; color: var(--muted); }

.muted { color: var(--muted); }
.error { color: var(--error); background: #fceaea; padding: 0.7rem 0.9rem; border-radius: 6px; }
.ok { color: var(--ok); background: #e1f5ee; padding: 0.7rem 0.9rem; border-radius: 6px; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.small { font-size: 0.88rem; }
.actions { white-space: nowrap; }
.actions form + form { margin-left: 0.75rem; }
button.link.danger { color: var(--error); }

.counters { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.counter {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.counter.secondary { background: #37556b; }
.counter-value { font-size: 2.5rem; font-weight: 600; line-height: 1; }
.counter-label { font-size: 1rem; opacity: 0.9; }

.row { display: flex; gap: 0.5rem; align-items: stretch; }
.row .button { margin-top: 0; white-space: nowrap; }

button.big { padding: 0.9rem 1.5rem; font-size: 1.1rem; width: 100%; }

.warn-box {
  border: 1px solid var(--warn);
  background: #faeeda;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin-bottom: 1.25rem;
}
.warn-box p { margin: 0.5rem 0; }
.warn-box .button { margin-top: 0.5rem; }

.search { display: flex; gap: 0.5rem; margin: 1rem 0; }
.search .button { margin-top: 0; }

td.call { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-weight: 600; }

textarea { width: 100%; padding: 0.7rem 0.8rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 6px; resize: vertical; }
textarea.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.95rem; line-height: 1.5; }
code { font-family: ui-monospace, Menlo, monospace; background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.9em; }

.import-summary { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.pill { padding: 0.3rem 0.8rem; border-radius: 999px; font-size: 0.9rem; font-weight: 500; }
.pill.new { background: #e1f5ee; color: var(--ok); }
.pill.warn { background: #faeeda; color: var(--warn); }
.pill.dup { background: #eef; color: #4a4a8a; }
.pill.err { background: #fceaea; color: var(--error); }

.import-table { font-size: 0.92rem; }
.import-table tr.row-error { background: #fdf3f3; }
.import-table tr.row-duplicate_db, .import-table tr.row-duplicate_internal { opacity: 0.7; }

.import-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.5rem; }
.import-actions form { margin: 0; }
.import-actions button { margin: 0; }

ul { margin: 0.5rem 0; padding-left: 1.25rem; }
li { margin: 0.2rem 0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.stat-cards { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 180px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.5rem; display: flex; flex-direction: column; gap: 0.35rem;
}
.stat-card.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.9rem; opacity: 0.85; }

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; border-top: 2px solid var(--border); }

.range-form { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.range-form label { margin: 0; }
.range-form input { width: auto; }
.range-form .button { margin: 0; }
.range-result { font-size: 1.1rem; }
