:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #17201c;
  --ink-2: #4a5550;
  --muted: #7b8580;
  --line: #e2e0d8;
  --line-2: #eceae4;
  --brand: #14322a;
  --brand-2: #1f4a3d;
  --accent: #0e8a5f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ec;
  --warn: #9a6a00;
  --warn-soft: #fff4d6;
  --err: #b42318;
  --err-soft: #fde8e6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 2px 8px rgba(20, 30, 25, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- top bar ---------- */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; min-height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 800; letter-spacing: .02em;
}
.brand-mark.sm { width: 30px; height: 30px; border-radius: 8px; font-size: .78rem; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: rgba(255, 255, 255, .78); padding: 8px 12px; border-radius: 8px;
  white-space: nowrap; font-size: .92rem; font-weight: 500;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .14); }
.nav-logout { margin-left: auto; }

@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 4px; padding-top: 8px; }
  .brand { width: 100%; }
  .nav { flex: 1 1 100%; margin: 0 -16px; padding: 0 12px 8px; }
  .nav-logout { margin-left: 0; }
}

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 0 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-settings { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 20px; align-items: start; }
@media (max-width: 900px) {
  .grid-2, .grid-settings { grid-template-columns: minmax(0, 1fr); }
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.stack > * + * { margin-top: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row, .row-3 { grid-template-columns: 1fr; } }
.section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line-2);
}
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: 2px; }
@media (max-width: 560px) { .stat .v { font-size: 1.1rem; } .stats { grid-template-columns: 1fr 1fr; } .stats .stat:last-child { grid-column: span 2; } }

/* ---------- forms ---------- */
label { display: block; font-size: .86rem; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #d3d1c8; border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 138, 95, .15);
}
input[readonly] { background: var(--line-2); }
input.big { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hint { font-size: .78rem; color: var(--muted); font-weight: 400; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
.input-group { display: flex; gap: 8px; align-items: flex-end; }
.input-group > :first-child { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); background: #faf9f6; color: var(--ink-2);
  border-radius: 999px; padding: 5px 11px; font: inherit; font-size: .82rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .92rem;
  border-radius: var(--radius-sm); border: 1px solid #cfccc2; background: #fff; color: var(--ink);
  padding: 9px 16px; min-height: 42px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f7f6f2; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #0b7952; }
.btn-dark { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-dark:hover { background: var(--brand-2); }
.btn-danger { color: var(--err); border-color: #efc5c0; }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 1rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- alerts ---------- */
.alert { border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 16px; font-size: .92rem; border: 1px solid transparent; }
.alert-ok { background: var(--accent-soft); border-color: #bfe3d3; color: #0b5e41; }
.alert-warn { background: var(--warn-soft); border-color: #f1dc9f; color: #6b4a00; }
.alert-err { background: var(--err-soft); border-color: #f4c2bc; color: var(--err); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfaf7; }
td.amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--line-2); color: var(--ink-2);
}
.badge-green { background: var(--accent-soft); color: var(--accent); }
.badge-grey { background: #ecebe6; color: var(--muted); }

/* recent list */
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.recent li:last-child { border-bottom: 0; }
.recent .ico {
  flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 800; font-size: .72rem;
}
.recent .mid { flex: 1; min-width: 0; }
.recent .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .s { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .a { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* filters */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters .actions { grid-column: span 2; } }

/* ---------- settings preview ---------- */
.preview-pane { position: sticky; top: 76px; }
.paper-stage {
  background: repeating-linear-gradient(45deg, #e7e5de, #e7e5de 10px, #ecebe5 10px, #ecebe5 20px);
  border-radius: var(--radius); padding: 18px 10px; display: flex; justify-content: center;
  max-height: calc(100vh - 210px); overflow: auto;
}
.paper-stage .frame-box { flex: none; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); background: #fff; }
.paper-stage iframe {
  border: 0; background: #fff; display: block;
  transform-origin: 0 0;
}
@media (max-width: 900px) { .preview-pane { position: static; } .paper-stage { max-height: none; } }

/* ---------- auth ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--brand); }
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 30px 26px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.auth-card .brand-mark { margin-bottom: 14px; }

/* ---------- verify page ---------- */
.verify-card { max-width: 440px; margin: 40px auto; }
.verify-status {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: #0b5e41; font-weight: 700; margin-bottom: 16px;
}
.verify-status .tick {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 1.2rem; flex: none;
}
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .86rem; }
dl.kv dd { margin: 0; font-weight: 600; text-align: right; word-break: break-all; }
