:root {
  --bg: #F6F3EC; --card: #fff; --ink: #1E2A24; --muted: #6B776F; --line: #E4DED1;
  --green: #1F4D3A; --leaf: #4E8B5F; --gold: #E2A93B; --terra: #C8553D; --blue: #2D6CDF;
  --r: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--green); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 20px; } h3 { font-size: 16px; }
.muted { color: var(--muted); }
.err { color: var(--terra); }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: var(--green); color: #fff; position: sticky; top: 0; z-index: 10; }
.top .brand { display: flex; align-items: center; gap: 12px; }
.top .brand img { width: 40px; height: 40px; }
.top .brand b { display: block; font-size: 17px; }
.top .brand .muted { color: #cfe0d5; font-size: 13px; }
.autopilot { display: flex; align-items: center; gap: 10px; }
nav#tabs { display: flex; gap: 2px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 64px; z-index: 9; }
nav#tabs a { padding: 12px 14px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
nav#tabs a.on { color: var(--green); border-color: var(--gold); }
main { max-width: 1280px; margin: 0 auto; padding: 22px 24px 80px; }

.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)); }
@media (max-width: 900px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } main { padding: 16px; } .top { padding: 10px 16px; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card + .card { margin-top: 16px; }
.stat b { display: block; font-size: 28px; color: var(--green); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--leaf); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1E2A24; }
.btn.danger { color: var(--terra); }
.btn.ghost { background: transparent; color: #fff; border-color: #ffffff55; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.top .btn:not(.ghost) { border: none; }

input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field small { display: block; color: var(--muted); font-weight: 400; margin-top: 3px; }
.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.inline input { width: auto; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eee; color: #333; white-space: nowrap; }
.pill.on { background: #D7F0DD; color: #1F6B3A; } .pill.off { background: #F6D6CC; color: #8a2f1c; }
.s-planned { background: #ECEFF3; color: #445; } .s-producing { background: #FFF1CC; color: #7a5a00; } .s-ready { background: #DCEBFF; color: #1d4fa8; }
.s-scheduled { background: #E6DDFF; color: #4b2ea8; } .s-published { background: #D7F0DD; color: #1F6B3A; } .s-failed { background: #F6D6CC; color: #8a2f1c; }
.s-cancelled { background: #eee; color: #888; text-decoration: line-through; } .s-draft { background: #F3E9D8; color: #6b4b16; }
.t-reel { background: #1F4D3A; color: #fff; } .t-carousel { background: #E2A93B; color: #1E2A24; } .t-post { background: #4E8B5F; color: #fff; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* calendar */
.cal { display: grid; grid-template-columns: 70px repeat(var(--days), minmax(118px, 1fr)); overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.cal > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-height: 64px; font-size: 13px; }
.cal .hd { background: #FAF8F3; font-weight: 700; min-height: auto; text-align: center; position: sticky; top: 0; }
.cal .hd.today { background: #FFF4DC; }
.cal .tm { font-weight: 700; color: var(--muted); background: #FAF8F3; }
.cal .past { background: #fbfbfa; }
.slot { border-radius: 10px; padding: 6px 8px; cursor: pointer; border: 1px solid var(--line); background: #fff; }
.slot:hover { border-color: var(--leaf); }
.slot .tp { font-size: 12px; margin: 3px 0 0; color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* library */
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; }
.tile .th { aspect-ratio: 4/5; background: #e9e4d8 center/cover no-repeat; position: relative; }
.tile .th.reel { aspect-ratio: 9/16; max-height: 300px; width: 100%; }
.tile .th .pill { position: absolute; left: 8px; top: 8px; }
.tile .meta { padding: 10px 12px; font-size: 13px; }
.tile .meta b { display: block; font-size: 14px; margin-bottom: 4px; }

.slides { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.slides img { height: 360px; border-radius: 10px; border: 1px solid var(--line); }
video.reel { height: 520px; max-width: 100%; border-radius: 12px; background: #000; }
.caption { white-space: pre-wrap; background: #FAF8F3; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 14px; }
.log { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: #10201a; color: #d6e6dc; border-radius: 10px; padding: 12px; max-height: 520px; overflow: auto; white-space: pre-wrap; }
.log .warn { color: #ffd479; } .log .error { color: #ff8f7a; }

.modal { position: fixed; inset: 0; background: #0008; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow: auto; }
.modal[hidden] { display: none; }
.modal-box { background: var(--bg); border-radius: 18px; width: min(1100px, 100%); padding: 24px; position: relative; }
.modal .x { position: absolute; right: 14px; top: 10px; font-size: 28px; border: none; background: none; cursor: pointer; color: var(--muted); }
#toast { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; max-width: 420px; box-shadow: 0 6px 20px #0003; }
#toast div.bad { background: var(--terra); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: #EEF3EE; font-weight: 600; font-size: 13px; }
.chip button { border: none; background: #fff; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; line-height: 1; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; margin: 0; }
.days input { width: auto; }
.progress { font-size: 13px; color: var(--leaf); font-weight: 700; }

.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 340px; text-align: center; }
.login-card input, .login-card button { margin-top: 12px; width: 100%; }
.preview-week td { font-size: 13px; }

/* progress */
.steps { display: flex; align-items: center; gap: 0; margin: 8px 0 4px; }
.steps b { flex: 1; height: 3px; background: var(--line); min-width: 8px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.step i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; background: #EEE9DE; color: var(--muted); }
.steps.big .step i { width: 34px; height: 34px; font-size: 14px; }
.steps.big .step span { font-weight: 700; }
.step.ok i { background: var(--leaf); color: #fff; } .step.ok span { color: var(--leaf); }
.step.now i { background: var(--gold); color: var(--ink); animation: pulse 1.2s infinite; } .step.now span { color: var(--ink); }
.step.bad i { background: var(--terra); color: #fff; } .step.bad span { color: var(--terra); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #E2A93B44; } }
.bar { height: 8px; background: #EEE9DE; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar div { height: 100%; background: linear-gradient(90deg, var(--leaf), var(--gold)); border-radius: 99px; transition: width .6s; }
