:root {
  --bg: #f5f1ea; --surface: #ffffff; --surface-2: #faf6f0; --ink: #1f1a16; --muted: #6c645b; --line: #e6ddd0;
  --head-1: #2a1e16; --head-2: #4b3628; --head-ink: #fbf6ee;
  --accent: #b88f4f; --accent-soft: #f3e8d6; --accent-ink: #7b5823;
  --btn: #2e2119; --btn-ink: #ffffff; --wa: #1b774a; --wa-soft: #e8f4ed; --danger: #a63b2b;
  --shadow: 0 1px 2px rgba(42, 30, 22, .05), 0 6px 18px rgba(42, 30, 22, .06);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14110e; --surface: #1e1a16; --surface-2: #26211b; --ink: #f2ece3; --muted: #a99f92; --line: #352e27;
  --head-1: #0d0a08; --head-2: #2a1f17; --head-ink: #f6efe4;
  --accent: #d3ab69; --accent-soft: #352b1f; --accent-ink: #e3c28b;
  --btn: #d3ab69; --btn-ink: #1a130d; --wa: #5ec893; --wa-soft: #17271e; --danger: #f08a7a;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select { font: inherit; color: inherit; }
.serif { font-family: "Playfair Display", Georgia, serif; }
[hidden] { display: none !important; }

.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  min-height: 60px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  color: var(--head-ink); background: linear-gradient(135deg, var(--head-1), var(--head-2));
  box-shadow: inset 0 -2px 0 var(--accent);
}
.bar h1 { flex: 1; min-width: 0; margin: 0; font-size: 19px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--accent); color: var(--accent); font-size: 17px; }
.back { flex: none; min-height: 40px; padding: 0 10px 0 4px; background: none; border: 0; border-radius: 8px; color: var(--head-ink); cursor: pointer; font-size: 15px; }
.icon-btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); color: var(--head-ink); cursor: pointer; }
.icon-btn svg { width: 19px; height: 19px; }

.menu { position: fixed; top: 64px; right: 12px; z-index: 6; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); overflow: hidden; }
.menu button { display: block; width: 100%; padding: 13px 16px; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer; }
.menu button:first-child { border-top: 0; }
.menu .who { padding: 12px 16px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 56px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 40px 10px; }
.hero h2 { margin: 6px 2px 4px; font-size: 26px; font-weight: 600; }
.hero p { margin: 0 2px 14px; color: var(--muted); font-size: 15px; }
h3.section { margin: 26px 2px 10px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); }
.page-title { margin: 6px 2px 2px; font-size: 26px; font-weight: 600; }
.page-sub { margin: 0 2px 16px; color: var(--muted); font-size: 14px; }

.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 13px 0; outline: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 62px; padding: 12px 16px; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer; }
.item:first-child { border-top: 0; }
.item:hover { background: var(--surface-2); }
.item-text { flex: 1; min-width: 0; font-weight: 550; }
.item-text small { display: block; margin-top: 1px; color: var(--muted); font-size: 13px; font-weight: 400; }
.badge { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-size: 18px; font-weight: 700; }
.chevron { flex: none; color: var(--accent); font-size: 22px; }

.doc { padding: 14px 16px; border-top: 1px solid var(--line); }
.doc:first-child { border-top: 0; }
.doc-head { display: flex; align-items: flex-start; gap: 12px; }
.doc-title { flex: 1; min-width: 0; font-weight: 600; }
.doc-title small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 600; }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.wa { background: var(--wa-soft); color: var(--wa); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }

.login { max-width: 400px; margin: 30px auto; }
.field { display: block; margin: 0 0 14px; }
.field span { display: block; margin: 0 0 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select { width: 100%; padding: 12px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-card { padding: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.error { color: var(--danger); font-size: 14px; margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 2px 0; }

.tabs { display: flex; gap: 6px; margin: 4px 0 16px; overflow-x: auto; }
.tab { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.tab.on { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.admin-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.admin-row:first-child { border-top: 0; }
.admin-row .grow { flex: 1; min-width: 160px; }
.admin-row small { display: block; color: var(--muted); font-size: 13px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.tag.off { background: var(--surface-2); color: var(--muted); }
.muted-row { opacity: .55; }
table.log { width: 100%; border-collapse: collapse; font-size: 14px; }
table.log td, table.log th { padding: 9px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
table.log th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-top: 0; }

.install { margin-top: 18px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.install p { margin: 0; flex: 1; font-size: 14px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9; max-width: 90vw; padding: 11px 16px; border-radius: 10px; background: var(--btn); color: var(--btn-ink); font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.sheet-back { position: fixed; inset: 0; z-index: 8; background: rgba(0,0,0,.4); display: grid; place-items: end center; }
.sheet { width: 100%; max-width: 520px; background: var(--surface); border-radius: 16px 16px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
.sheet h4 { margin: 0 0 6px; font-size: 18px; }
.sheet p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.sheet .btn { width: 100%; margin-top: 8px; min-height: 46px; }

.segs { display: inline-flex; margin-top: 10px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg { min-height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
