:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1b1f27; --muted: #6a7384; --line: #e4e7ec;
  --brand: #ff5a1f; --brand-ink: #ffffff; --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --soft: #fff1ea;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f1218; --panel:#171b24; --text:#e8ebf1; --muted:#98a1b3; --line:#262c38; --soft:#2a1d17; --shadow:none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
a { color: var(--brand); }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 1.2rem; padding: 0 8px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
nav a:hover { background: var(--soft); }
nav a.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.main { padding: 28px clamp(16px, 3vw, 40px); max-width: 1200px; width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 18px; }
.stat .n { font-size: 1.9rem; font-weight: 700; } .stat .l { color: var(--muted); font-size: .85rem; }
.cols2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: wait; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; background: var(--line); }
.pill.ok { background: #dcfce7; color: #166534; } .pill.warn { background: #fef3c7; color: #92400e; } .pill.bad { background: #fee2e2; color: #991b1b; }
@media (prefers-color-scheme: dark) {
  .pill.ok { background:#12351f; color:#86efac; } .pill.warn { background:#3b2a0b; color:#fcd34d; } .pill.bad { background:#3d1515; color:#fca5a5; }
}

label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .f3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--text); font-size: .95rem; }
.check input { width: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.thumb { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.title-cell { max-width: 340px; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tbl-wrap { overflow-x: auto; }

.seg { display: flex; flex-direction: column; gap: 10px; }
.seg h3 { display: flex; align-items: center; gap: 8px; }
.kv { color: var(--muted); font-size: .88rem; }
.kv b { color: var(--text); font-weight: 600; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { background: var(--soft); color: var(--brand); padding: 2px 9px; border-radius: 999px; font-size: .78rem; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; z-index: 10; overflow-y: auto; }
.modal-box { width: min(620px, 100%); max-height: 92vh; overflow-y: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 20; max-width: 90vw; }
.toast.err { background: var(--bad); }
.banner { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }

.wa-preview { background: #0b141a; border-radius: 12px; padding: 12px; }
.wa-bubble { background: #005c4b; color: #e9edef; border-radius: 10px 10px 2px 10px; padding: 6px; max-width: 360px; margin-left: auto; font-size: .92rem; white-space: pre-wrap; word-break: break-word; }
.wa-bubble img { width: 100%; border-radius: 6px; display: block; margin-bottom: 6px; background: #fff; }
.wa-bubble .t { padding: 2px 6px 6px; }
.qr { width: 280px; max-width: 100%; background: #fff; padding: 10px; border-radius: 10px; }
code { background: var(--bg); padding: 1px 6px; border-radius: 5px; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  nav { flex-direction: row; flex-wrap: wrap; } .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .f2, .f3 { grid-template-columns: 1fr; }
}
