:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1d2a24;
  --muted: #6b7a72;
  --line: #e4ded1;
  --green: #14513b;
  --green-2: #1e6b4f;
  --lime: #c8e86b;
  --coral: #e2674a;
  --amber: #e9a83b;
  --blue: #3b6fe9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 6px 24px rgba(20, 40, 30, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 'Manrope', system-ui, sans-serif; }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 28px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
a { color: var(--green-2); }
button, input, select, textarea { font: inherit; color: inherit; }

/* layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--green); color: #e9f2ec; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-family: 'Fraunces', serif; font-size: 22px; padding: 0 10px 18px; display: flex; align-items: center; gap: 10px; }
.brand b { background: var(--lime); color: var(--green); border-radius: 8px; padding: 0 8px; font-size: 16px; }
.side a { color: #cfe0d6; text-decoration: none; padding: 9px 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.on { background: var(--lime); color: var(--green); }
.side .foot { margin-top: auto; font-size: 12px; color: #9fbcae; padding: 10px; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1240px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head p { margin: 0; color: var(--muted); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat .k { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .v { font-family: 'Fraunces', serif; font-size: 32px; line-height: 1.1; margin-top: 4px; }
.stat .s { font-size: 12px; color: var(--muted); }
.ok { color: var(--green-2); } .bad { color: var(--coral); } .warn { color: var(--amber); }

/* forms */
label { display: block; font-size: 13px; font-weight: 700; margin: 12px 0 5px; color: #34443c; }
label small { font-weight: 500; color: var(--muted); }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(30,107,79,.12); }
textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row > .btn, .row > button, .row > span { flex: 0 0 auto; min-width: 0; }
.head .row { flex: 0 1 auto; justify-content: flex-end; }
.head .row > select, .head .row > input { flex: 0 0 auto; }
.btn { border: 0; background: var(--green); color: #fff; padding: 9px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.btn:hover { background: var(--green-2); }
.btn.sec { background: #fff; color: var(--green); border: 1px solid var(--line); }
.btn.sec:hover { border-color: var(--green-2); }
.btn.lime { background: var(--lime); color: var(--green); }
.btn.red { background: #fff; color: var(--coral); border: 1px solid #f1c9be; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: wait; }

/* tables & lists */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #faf7f0; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #eef0ea; color: #4b5a52; white-space: nowrap; }
.tag.g { background: #e1f1d0; color: #2c5a17; } .tag.r { background: #fbe1da; color: #9c3a22; } .tag.y { background: #fbefd6; color: #8a5b0c; } .tag.b { background: #e1e9fb; color: #23449a; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.empty { text-align: center; padding: 36px; color: var(--muted); }

/* media library */
.media-list { display: grid; gap: 10px; }
.media { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.media .ico { width: 64px; height: 64px; border-radius: 10px; background: #eef3ee; display: grid; place-items: center; font-size: 26px; overflow: hidden; }
.media .ico img { width: 100%; height: 100%; object-fit: cover; }
.media audio { width: 100%; height: 32px; margin-top: 6px; }
.media .tr { font-size: 13px; color: #4b5a52; max-height: 4.5em; overflow: hidden; }

/* drop zone */
.drop { border: 2px dashed #cdd5c8; border-radius: 14px; padding: 26px; text-align: center; background: #fbfaf5; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--green-2); background: #f0f6ef; }
.drop b { color: var(--green); }

/* creatives */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.cri { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.cri.win { outline: 3px solid var(--lime); }
.cri img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #eee; }
.cri .b { padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cri .m { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; text-align: center; background: #f7f5ef; border-radius: 8px; padding: 6px 0; }
.cri .m b { display: block; font-size: 15px; }
.cri .m span { font-size: 11px; color: var(--muted); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; background: #e9e3d6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23d9d1c0'/%3E%3C/svg%3E"); border-radius: 14px; padding: 16px; min-height: 380px; max-height: 62vh; overflow-y: auto; }
.bub { max-width: 78%; padding: 8px 12px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.bub.in { background: #fff; align-self: flex-start; border-top-left-radius: 3px; }
.bub.out { background: #d6f5c6; align-self: flex-end; border-top-right-radius: 3px; }
.bub.humano { background: #fff1c7; }
.bub .t { font-size: 11px; color: #7b8a80; text-align: right; margin-top: 2px; }
.bub audio { width: 230px; height: 34px; display: block; }
.bub img { max-width: 220px; border-radius: 8px; display: block; }
.bub .lab { font-size: 11px; font-weight: 700; color: var(--green-2); }

/* qr */
.qr { width: 280px; height: 280px; border-radius: 14px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto; }
.qr img { width: 260px; height: 260px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #bbb; }
.dot.on { background: #3dbb6a; box-shadow: 0 0 0 4px rgba(61,187,106,.2); } .dot.off { background: var(--coral); }

/* misc */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 99; max-width: 420px; font-size: 14px; }
.toast.err { background: #8f2e19; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.tabs button.on { background: var(--green); color: #fff; border-color: var(--green); }
.kit { display: grid; grid-template-columns: 2fr .6fr .8fr 2.4fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.funnel .bar { height: 26px; border-radius: 7px; background: var(--green-2); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; padding: 0 10px; margin: 4px 0; min-width: 34px; }
.log { font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log time { color: var(--muted); font-size: 12px; margin-right: 8px; }
.steps li { margin-bottom: 8px; }
code { background: #efece3; padding: 1px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
dialog { border: 0; border-radius: 16px; padding: 22px; max-width: 640px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 30, 22, .45); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .brand { width: 100%; padding-bottom: 8px; }
  .side .foot { display: none; }
  .kit { grid-template-columns: 1fr 1fr; }
  .media { grid-template-columns: 48px 1fr; }
  .media > :last-child { grid-column: 1 / -1; }
}
