:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #17201b;
  --muted: #5d6a62;
  --line: #e2e6e0;
  --brand: #0e8a5f;
  --brand-ink: #ffffff;
  --brand-soft: #e3f4ec;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
a { color: var(--brand); }
img, video { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

header.top {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: .7rem clamp(1rem, 4vw, 2.5rem);
}
.logo { font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--ink); letter-spacing: -.02em; }
.logo span { color: var(--brand); }
header nav { margin-left: auto; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
header nav a { text-decoration: none; color: var(--ink); padding: .4rem .7rem; border-radius: 8px; font-size: .95rem; }
header nav a:hover { background: var(--bg); }

main { max-width: 1120px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 6rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: .6rem 1rem; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 42px;
}
.btn:hover { border-color: #c5ccc5; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: #f1c4bf; }
.btn.small { padding: .3rem .6rem; min-height: 32px; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: progress; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.two-col { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.spacer { flex: 1; }

.hero { padding: 2.5rem 0 1.5rem; }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 640px; }

.project-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.project-card .thumb { aspect-ratio: 16/10; background: var(--brand-soft) center/cover no-repeat; }
.project-card .body { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.project-card h3 { margin: 0; }

.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; }
.stat-big { font-size: 1.7rem; font-weight: 800; }

.pill { display: inline-block; padding: .15rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--bg); border: 1px solid var(--line); text-transform: capitalize; }
.pill.live, .pill.verified, .pill.approve, .pill.running, .pill.active { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.needs_changes, .pill.pending, .pill.warning, .pill.paused, .pill.scheduled { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.reject, .pill.failed, .pill.blocker, .pill.refunded { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

form label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: 1.1rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .86rem; }
input, select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid #cfd6cf; border-radius: 9px; font: inherit; background: #fff; color: inherit;
}
textarea { resize: vertical; min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
input[type=range] { padding: 0; }
input[type=checkbox], input[type=radio] { width: auto; }
.inline-options { display: flex; gap: 1rem; flex-wrap: wrap; }
.inline-options label { font-weight: 500; display: flex; gap: .4rem; align-items: center; }

.budget-row { display: grid; grid-template-columns: 1fr 140px 36px; gap: .5rem; margin-bottom: .5rem; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.media-grid .tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg) center/cover; border: 1px solid var(--line); }
.media-grid .tile button { position: absolute; top: 4px; right: 4px; }

.gallery-main { border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16/9; display: grid; place-items: center; }
.gallery-main img, .gallery-main video { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: .5rem; margin-top: .5rem; overflow-x: auto; }
.thumbs button { border: 2px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; width: 84px; height: 56px; flex: none; cursor: pointer; background: #000 center/cover; color: #fff; font-size: .8rem; }
.thumbs button.active { border-color: var(--brand); }

.notice { padding: .8rem 1rem; border-radius: 10px; background: var(--brand-soft); }
.notice.warn { background: var(--warn-soft); }
.notice.error { background: var(--danger-soft); color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.issue { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: .6rem .9rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }

.agent { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.meter > div { height: 100%; background: var(--brand); }
.meter.hot > div { background: var(--warn); }
.log { font-size: .85rem; max-height: 340px; overflow-y: auto; }
.log div { padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.bar-row { display: grid; grid-template-columns: 120px 1fr 60px; gap: .6rem; align-items: center; font-size: .9rem; margin-bottom: .4rem; }
.bar-row .bar { height: 14px; background: var(--brand); border-radius: 4px; }

/* chat */
#chat-toggle { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 40; border-radius: 99px; padding: .8rem 1.1rem; box-shadow: var(--shadow); }
#chat-panel {
  position: fixed; right: 1.2rem; bottom: 5rem; z-index: 40; width: min(380px, calc(100vw - 2.4rem)); height: min(540px, calc(100vh - 7rem));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.15);
  display: none; flex-direction: column; overflow: hidden;
}
#chat-panel.open { display: flex; }
#chat-panel .head { padding: .8rem 1rem; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; }
#chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.msg { padding: .55rem .8rem; border-radius: 12px; max-width: 88%; white-space: pre-wrap; font-size: .93rem; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--bg); }
#chat-form { display: flex; gap: .4rem; padding: .7rem; border-top: 1px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.demo-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .85rem; padding: .35rem 1rem; }
dialog { border: 0; border-radius: 16px; padding: 1.5rem; max-width: 460px; width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }

/* Reports */
.report-tiles { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--brand); }
.chart .bar-hit { cursor: default; }
.chart .bar-hit.hover .bar { fill: #0a6b49; }
.chart .bar-hit.hover rect { fill: rgba(14, 138, 95, .07); }
.chart-tip { position: absolute; top: 0; width: 180px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: .45rem .6rem; font-size: .82rem; pointer-events: none; }
.chart details { margin-top: .6rem; }
.barlist { display: grid; gap: .45rem; }
.barlist-row { display: grid; grid-template-columns: minmax(90px, 40%) 1fr auto; gap: .6rem; align-items: center; font-size: .9rem; }
.barlist-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.barlist-fill { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.barlist-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .85rem; }
.backer-map { height: 420px; border-radius: 10px; overflow: hidden; margin-top: .8rem; border: 1px solid var(--line); z-index: 0; }
.map-pop { margin: .4rem 0 0; padding-left: 1.1rem; max-height: 180px; overflow: auto; }
