@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@500;600;700;800&family=Barlow+Condensed:wght@600;700;800&family=Bebas+Neue&family=Fraunces:opsz,wght@9..144,900&family=Poppins:wght@700&display=swap");

:root {
  --green: #1e4d2b;
  --green-d: #143620;
  --tan: #c9a96e;
  --tan-d: #a8874c;
  --paper: #f3f0e8;
  --card: #ffffff;
  --ink: #23261f;
  --muted: #6d6a5c;
  --line: #e1dccf;
  --bad: #b3261e;
  --ok: #2e7d32;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font: 500 15px/1.4 Barlow, system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- top -- */
.top {
  display: flex; align-items: center; gap: 22px;
  background: var(--green); color: #fff;
  padding: 0 22px; height: 60px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand b { font: 800 24px "Barlow Condensed", sans-serif; letter-spacing: .02em; text-transform: uppercase; }
.brand span { color: var(--tan); font-weight: 700; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button {
  background: none; border: 0; color: rgba(255,255,255,.75);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 700;
}
.tabs button:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs button.on { color: var(--green-d); background: var(--tan); }
.top .spacer { flex: 1; }
.top a { color: rgba(255,255,255,.7); font-size: 13px; text-decoration: none; }

/* ------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 15px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 700; font-size: 14px;
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-d); }
.btn.gold { background: var(--tan); border-color: var(--tan); color: #241d0d; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------- library -- */
.page { padding: 26px; max-width: 1500px; margin: 0 auto; }
.lib-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.lib-head h1 { font: 800 30px "Barlow Condensed", sans-serif; text-transform: uppercase; margin: 0; }
.lib-head .count { color: var(--muted); font-weight: 600; }
.lib-head input[type=search] {
  margin-left: auto; width: 280px; max-width: 100%;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.empty {
  border: 2px dashed var(--line); border-radius: 14px; padding: 50px; text-align: center; color: var(--muted);
}
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }

.ad-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.ad-card.off { opacity: .62; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--pitch);
  cursor: pointer;
}
.thumb img, .thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(255,255,255,.75); font-weight: 700; font-size: 14px; text-align: center; padding: 20px;
}
.thumb .badge {
  position: absolute; left: 10px; top: 10px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 99px; letter-spacing: .03em;
}
.thumb .dur {
  position: absolute; right: 10px; top: 10px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 99px;
}
.ad-info { padding: 12px 14px 4px; }
.ad-info .name { font-weight: 800; font-size: 17px; line-height: 1.2; }
.ad-info .client { color: var(--muted); font-size: 13px; font-weight: 600; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; margin-top: 6px; min-height: 20px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.ready .dot { background: var(--ok); }
.status.working .dot { background: var(--tan); animation: blink 1s infinite; }
.status.failed { color: var(--bad); }
.status.failed .dot { background: var(--bad); }
.status.stale .dot { background: #e08a00; }
.status .bar { flex: 1; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; max-width: 140px; }
.status .bar i { display: block; height: 100%; background: var(--tan); }
.status small { color: var(--muted); font-weight: 600; }
@keyframes blink { 50% { opacity: .3; } }
.ad-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 14px; align-items: center; }
.ad-actions .grow { flex: 1; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); }
.switch input { accent-color: var(--green); width: 16px; height: 16px; }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 10;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.15); min-width: 250px; padding: 6px;
}
.menu-list a, .menu-list button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  background: none; border: 0; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600;
}
.menu-list a:hover, .menu-list button:hover { background: var(--paper); }
.menu-list small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

.libnote {
  margin-top: 28px; padding: 14px 16px; border-radius: 12px; background: #fff; border: 1px solid var(--line);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted);
}
.libnote code { background: var(--paper); padding: 3px 8px; border-radius: 6px; color: var(--ink); font-size: 12px; word-break: break-all; }

/* -------------------------------------------------------------- editor -- */
.editor { display: grid; grid-template-columns: 410px 1fr; height: calc(100vh - 60px); }
.form { overflow-y: auto; background: #fff; border-right: 1px solid var(--line); padding: 18px 20px 120px; }
.sec { padding: 16px 0; border-top: 1px solid var(--line); }
.sec:first-child { border-top: 0; padding-top: 0; }
.sec h3 {
  margin: 0 0 12px; font: 800 13px Barlow, sans-serif; letter-spacing: .12em;
  text-transform: uppercase; color: var(--green);
  display: flex; align-items: center; gap: 8px;
}
.sec h3 .btn { margin-left: auto; }
.field { margin-bottom: 12px; }
.field > label, .lbl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; letter-spacing: .02em; }
.field input[type=text], .field input[type=url], .field input[type=number], .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid var(--tan); outline-offset: -1px; border-color: var(--tan); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.tpls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpl {
  text-align: left; padding: 10px 11px; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
.tpl b { display: block; font-size: 14px; }
.tpl span { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; margin-top: 3px; }
.tpl.on { border-color: var(--green); background: #f4f8f3; }
.tpl svg { display: block; width: 100%; height: 34px; margin-bottom: 6px; }

.logo-row { display: flex; gap: 10px; align-items: center; }
.logo-prev {
  width: 92px; height: 64px; border-radius: 8px; border: 1px solid var(--line); flex: none;
  background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 14px 14px;
  display: grid; place-items: center; overflow: hidden;
}
.logo-prev img { max-width: 86%; max-height: 86%; }
.logo-btns { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: #fff; padding: 8px 6px; cursor: pointer; font-weight: 700; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--green); color: #fff; }

.colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.color { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.color input[type=color] { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.swatch { width: 34px; height: 24px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; overflow: hidden; display: flex; }
.swatch i { flex: 1; }

.pagecard { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fcfbf8; }
.pagecard .ph { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12px; font-weight: 800; color: var(--green); letter-spacing: .08em; text-transform: uppercase; }
.pagecard .ph .grow { flex: 1; }
.pagecard .ph button { border: 0; background: none; cursor: pointer; font-size: 15px; color: var(--muted); padding: 2px 5px; border-radius: 5px; }
.pagecard .ph button:hover { background: var(--line); color: var(--ink); }
.pagecard input[type=text] { margin-bottom: 6px; }
.hold { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.hold input { width: 70px !important; }

.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--green); }
.range output { width: 52px; text-align: right; font-weight: 700; font-size: 13px; }

/* preview side */
.prev { display: flex; flex-direction: column; min-width: 0; padding: 18px 22px; gap: 12px; overflow: auto; }
.prev-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.prev-bar .grow { flex: 1; }
.prev-bar input[type=text] {
  font: 800 22px "Barlow Condensed", sans-serif; text-transform: uppercase; border: 0; background: none; padding: 4px 0; min-width: 0; flex: 1;
}
.prev-bar input[type=text]:focus { outline: 0; border-bottom: 2px solid var(--tan); }
.screen {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
  background: var(--pitch); box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.screen iframe, .screen video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.screen .safe { position: absolute; inset: 5%; border: 1px dashed rgba(255,255,255,.25); pointer-events: none; border-radius: 4px; }
.screen .board {
  position: absolute; left: 3.6%; top: 4.5%; width: 23%; height: 7%;
  background: rgba(10,25,15,.75); border-radius: 6px; pointer-events: none;
  display: flex; align-items: center; justify-content: space-around; color: rgba(255,255,255,.7);
  font: 800 clamp(9px, 1.2vw, 18px) "Barlow Condensed", sans-serif;
}
.transport { display: flex; align-items: center; gap: 10px; }
.transport input[type=range] { flex: 1; accent-color: var(--green); }
.transport .time { font: 700 13px ui-monospace, Menlo, monospace; color: var(--muted); width: 110px; text-align: right; }
.bgs { display: flex; gap: 6px; }
.bgs button { width: 30px; height: 22px; border-radius: 5px; border: 2px solid transparent; cursor: pointer; }
.bgs button.on { border-color: var(--green); }
.savebar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.savebar .msg { color: var(--muted); font-size: 13px; font-weight: 600; }
.tip { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.35; }

/* Pitch backdrop for previews: mown stripes. */
:root {
  --pitch: repeating-linear-gradient(90deg, #3f7d3c 0 8.33%, #457f40 8.33% 16.66%),
           #3f7d3c;
  --checker: repeating-conic-gradient(#cfcfcf 0 25%, #f4f4f4 0 50%) 0 0 / 22px 22px;
}
.bg-checker { background: var(--checker) !important; }
.bg-green { background: #00b140 !important; }
.bg-dark { background: #141a15 !important; }

/* -------------------------------------------------------------- upload -- */
.drop {
  border: 2px dashed var(--tan); border-radius: 14px; background: #fff;
  padding: 40px; text-align: center; cursor: pointer; transition: background .15s;
}
.drop.over { background: #fbf6ea; }
.drop b { display: block; font-size: 19px; margin-bottom: 4px; }
.drop span { color: var(--muted); }
.up-grid { display: grid; grid-template-columns: 420px 1fr; gap: 24px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.prog { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.prog i { display: block; height: 100%; width: 0; background: var(--green); transition: width .15s; }
.note { padding: 10px 12px; border-radius: 8px; background: #fbf6ea; border: 1px solid #ecdcb8; font-size: 13px; margin-top: 10px; }
.note.bad { background: #fdecea; border-color: #f2c0bb; color: var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 700;
  z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.3);
}

@media (max-width: 980px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .form { border-right: 0; padding-bottom: 30px; order: 2; }
  .prev { order: 1; }
  .up-grid { grid-template-columns: 1fr; }
  .tabs button { padding: 8px 9px; }
  .brand span { display: none; }
}
