:root {
  --bg: #f4f6f5; --card: #fff; --line: #e9edeb; --line2: #d7dedb; --ink: #13201a; --muted: #66736d;
  --green: #059652; --green2: #31d17f; --greenbg: #ecfdf3; --saffron: #f99307; --saffronbg: #fff8eb;
  --red: #d93b3b; --redbg: #fdeeee; --r: 14px; --shadow: 0 1px 2px rgba(16,40,28,.06), 0 6px 20px rgba(16,40,28,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--green); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .sm { font-size: 13px; }
input, textarea, select { width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(5,150,82,.12); }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line2); background: #fff; color: var(--ink); border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; transition: transform .1s, background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { border-color: var(--green); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: #048046; }
.btn.warn { background: var(--saffron); border-color: var(--saffron); color: #fff; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, var(--greenbg), transparent 50%), radial-gradient(circle at 90% 90%, var(--saffronbg), transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 32px 26px; box-shadow: var(--shadow); text-align: center; animation: rise .35s ease; }
.login-card h1 { font-size: 22px; margin: 12px 0 6px; }
.login-card input { margin: 18px 0 12px; text-align: center; }
.login-card .btn { width: 100%; padding: 12px; }

/* shell */
.shell { display: flex; min-height: 100%; }
.side { width: 230px; flex: none; background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand b { display: block; font-size: 16px; } .brand span { font-size: 12px; color: var(--muted); }
.side a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 600; transition: background .15s, color .15s; }
.side a i { font-style: normal; width: 22px; text-align: center; font-size: 17px; color: var(--muted); }
.side a:hover { background: var(--bg); }
.side a.on { background: var(--greenbg); color: var(--green); }
.side a.on i { color: var(--green); }
.side-foot { margin-top: auto; padding: 8px; }
main { flex: 1; min-width: 0; padding: 22px; max-width: 1280px; margin: 0 auto; width: 100%; animation: fade .2s ease; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.meter { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 6px; transition: width .4s; }
.meter i.hot { background: var(--saffron); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--muted); }
.pill.ok { background: var(--greenbg); color: var(--green); }
.pill.warn { background: var(--saffronbg); color: #b45309; }
.pill.bad { background: var(--redbg); color: var(--red); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.profile { display: flex; gap: 14px; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--green2), var(--green)); flex: none; object-fit: cover; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 24px; }
.list { display: flex; flex-direction: column; }
.item { padding: 11px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.item:last-child { border-bottom: 0; }
.item .t { font-size: 12px; color: var(--muted); white-space: nowrap; }
.item.click { cursor: pointer; border-radius: 8px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; transition: background .15s; }
.item.click:hover, .item.click.on { background: var(--bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; margin-top: 7px; }
.dot.bad { background: var(--red); }
.empty { color: var(--muted); text-align: center; padding: 26px 8px; font-size: 14px; }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 13.5px; background: var(--saffronbg); border: 1px solid #ffeac6; color: #7a4a06; }
.notice.green { background: var(--greenbg); border-color: #d1fae0; color: #065f3b; }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.drop { border: 2px dashed var(--line2); border-radius: 14px; padding: 22px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--green); background: var(--greenbg); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs figure { margin: 0; width: 84px; height: 105px; border-radius: 10px; overflow: hidden; position: relative; background: var(--bg); }
.thumbs img, .thumbs video { width: 100%; height: 100%; object-fit: cover; }
.thumbs button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px; }
.phone { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; max-width: 340px; margin: 0 auto; }
.phone .ph-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; font-weight: 700; font-size: 13px; }
.phone .ph-head .avatar { width: 28px; height: 28px; font-size: 12px; }
.phone .ph-img { aspect-ratio: 4/5; background: var(--bg); display: grid; place-items: center; color: var(--muted); }
.phone .ph-img img, .phone .ph-img video { width: 100%; height: 100%; object-fit: cover; }
.phone .ph-cap { padding: 10px 12px 14px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.phone .more { color: var(--muted); }
.checks { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 13px; }
.checks div { display: flex; gap: 8px; }
.checks b { width: 44px; flex: none; font-size: 11px; }
.checks .PASS { color: var(--green); } .checks .WARN { color: #b45309; } .checks .FAIL { color: var(--red); }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; padding: 4px 2px 10px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 16px; background: var(--bg); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.bubble.me { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.bubble:not(.me) { border-bottom-left-radius: 4px; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line2); border-radius: 99px; cursor: pointer; transition: background .2s; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--bg); border-radius: 8px; padding: 9px 11px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { display: block; }
  main { padding: 14px 16px calc(88px + env(safe-area-inset-bottom)); }
  .g2 { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: auto; height: auto; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 20; gap: 0; }
  .brand, .side-foot { display: none; }
  .side a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10.5px; flex: 1; text-align: center; }
  .side a i { font-size: 18px; }
  .card { padding: 15px; }
  .kv { grid-template-columns: 1fr; }
}
