:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --panel-2: #f0f2ef;
  --text: #1c2420;
  --muted: #5f6b65;
  --line: #dfe3df;
  --brand: #127a5c;
  --brand-2: #0e624a;
  --brand-soft: #e3f2ec;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --info-soft: #e8eef9;
  --bubble-me: #d9f4e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --panel: #1a201d;
    --panel-2: #222a26;
    --text: #e6ece9;
    --muted: #9aa8a1;
    --line: #2e3833;
    --brand: #3cc49a;
    --brand-2: #2fa582;
    --brand-soft: #173a2e;
    --warn: #f0b458;
    --warn-soft: #3a2c14;
    --bad: #ff8a80;
    --bad-soft: #3d1c1a;
    --info-soft: #1d2a3d;
    --bubble-me: #1f4636;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Heebo, system-ui, sans-serif; font-size: 15px; line-height: 1.55; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }

.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 15px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--panel-2); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .badge { margin-inline-start: auto; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.main { padding: 26px 32px 60px; max-width: 1200px; width: 100%; }
.topbar { display: none; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.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)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.btn { text-decoration: none; display: inline-block; border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 8px 11px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.ltr { direction: ltr; text-align: left; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.badge.ok { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); }

.note { padding: 10px 14px; border-radius: 10px; background: var(--info-soft); margin-bottom: 14px; }
.note.warn { background: var(--warn-soft); }
.note.bad { background: var(--bad-soft); }
.note.ok { background: var(--brand-soft); }

table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: start; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 500; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--panel-2); }

.item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--panel); }
.item.suggested { border-inline-start: 3px solid var(--warn); }
.item.approved { border-inline-start: 3px solid var(--brand); }
.quote { border-inline-start: 3px solid var(--line); padding: 2px 10px; color: var(--muted); font-size: 13px; margin-top: 6px; }

.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width .3s; }
.log { font-size: 13px; max-height: 260px; overflow-y: auto; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.log div { padding: 2px 0; }

.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(560px, 100vw); background: var(--panel); z-index: 21; overflow-y: auto; padding: 20px 22px; box-shadow: -4px 0 20px rgba(0, 0, 0, .15); }

.chat { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow); }
.bubble.me { align-self: flex-start; background: var(--bubble-me); }
.bubble.bot { align-self: flex-end; background: var(--panel); }
.bubble.sys { align-self: center; background: var(--warn-soft); font-size: 13px; }
.bubble img { max-width: 200px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.chat .compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat .compose textarea { min-height: 42px; max-height: 140px; }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(380px, 100%); }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 50; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset-inline-start: 0; top: 0; z-index: 30; width: 250px; transform: translateX(100%); transition: transform .2s; }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .main { padding: 18px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .hide-m { display: none; }
  .chat { height: calc(100vh - 170px); }
  .bubble { max-width: 90%; }
}
@media (max-width: 520px) {
  .g2, .g3 { grid-template-columns: 1fr; }
}
