:root {
  --bg: #f6f5f2; --surface: #fff; --line: #e4e2dc; --text: #1d1d1b; --muted: #7a776f;
  --accent: #1f3a34; --accent-ink: #fff; --warn: #9a5b12; --warn-bg: #fbf1e3;
  --err: #9b2c2c; --err-bg: #fbeaea; --ok-bg: #e9f2ee; --radius: 8px;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 28px 0 12px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 28px; height: 56px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: .02em; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: var(--radius); }
.top nav a.active, .top nav a:hover { color: var(--text); background: var(--bg); }
.logout { margin: 0; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.count { color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

input, select, button { font: inherit; }
input:not([type=checkbox]), select {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); color: var(--text); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn { display: inline-block; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c9c6be; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { opacity: .92; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 0; }
button.link:hover { color: var(--text); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[name=q] { width: 240px; }
.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.check { color: var(--text); }
.export { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-bottom: 12px; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #fbfaf8; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfaf8; }
td.addr { max-width: 340px; }
td.empty { text-align: center; color: var(--muted); padding: 40px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; color: var(--muted); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; background: var(--ok-bg); }
.flash.error { background: var(--err-bg); color: var(--err); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; max-width: 760px; }
.card h2 { margin-top: 0; }
.stack { display: grid; gap: 14px; }
.stack label, .login label { display: grid; gap: 6px; font-weight: 500; }
.hint { color: var(--muted); margin: 18px 0 0; padding-left: 18px; }
.hint li { margin-bottom: 4px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stats div { background: var(--bg); border-radius: var(--radius); padding: 12px; display: grid; }
.stats b { font-size: 20px; }
.stats span { color: var(--muted); font-size: 12px; }
.stats .warn { background: var(--warn-bg); color: var(--warn); }

.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg); white-space: nowrap; }
.tag.export { background: var(--warn-bg); color: var(--warn); }
.tag.login_failed, .tag.login_locked { background: var(--err-bg); color: var(--err); }
.tag.import { background: var(--ok-bg); color: var(--accent); }

.login { max-width: 360px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 32px; }
.login h1 { margin-bottom: 20px; }
.login form { display: grid; gap: 14px; }
.login .btn { width: 100%; padding: 10px; }

@media (max-width: 720px) {
  .top-inner { gap: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .export { justify-content: flex-start; flex-wrap: wrap; }
}
