:root {
  --forest: #0E3B2E; --forest-2: #13493a; --green: #2BB673; --green-ink: #167a4a; --green-soft: #e6f5ed;
  --teal: #1FA3A3; --ink: #12211c; --muted: #4f5f59; --line: #dfe7e2; --paper: #f6f8f5; --white: #fff;
  --amber: #a15c00; --amber-soft: #fff3df; --red: #b3261e; --red-soft: #fdeceb; --blue-soft: #e2f3f3;
  --radius: 12px; --shadow: 0 1px 2px rgba(14,59,46,.06), 0 10px 30px -14px rgba(14,59,46,.22);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-xs: .78rem; --text-sm: .875rem; --text-base: .95rem; --text-lg: 1.15rem; --text-xl: 1.5rem;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: var(--text-base); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; line-height: 1.5; }
a { color: var(--green-ink); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; color: var(--forest); }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--forest); color: #e8f2ec; padding: 22px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo img { height: 40px; width: auto; display: block; margin: 2px 8px 6px; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #cfe1d8; text-decoration: none; font-weight: 600; font-size: var(--text-sm); }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a[aria-current="page"] { background: rgba(43,182,115,.18); color: #fff; }
.side nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.side nav .count { margin-left: auto; background: var(--green); color: var(--forest); font-size: 11px; font-weight: 800; border-radius: 99px; padding: 1px 7px; }
.side .who { margin-top: auto; padding: 12px; border-radius: 10px; background: rgba(255,255,255,.06); font-size: var(--text-xs); }
.side .who b { display: block; color: #fff; font-size: var(--text-sm); word-break: break-all; }
.side .who .role { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 99px; background: rgba(43,182,115,.2); color: #b7ebcf; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
.side .who button { margin-top: 10px; background: none; border: 1px solid rgba(255,255,255,.25); color: #e8f2ec; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: var(--text-xs); font-weight: 600; }
.side .who button:hover { border-color: #fff; }
.topbar { display: none; }
main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: var(--text-xl); font-weight: 800; }
.page-head p { color: var(--muted); font-size: var(--text-sm); margin-top: 4px; max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards, KPIs */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: var(--text-lg); font-weight: 700; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: #bcd9c9; box-shadow: var(--shadow); }
.kpi span { font-size: var(--text-xs); color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-size: 1.7rem; font-weight: 800; color: var(--forest); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.kpi.warn b { color: var(--amber); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; font-weight: 700; font-size: var(--text-sm); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--green); color: var(--forest); }
.btn-primary:hover { background: #33c77f; }
.btn-dark { background: var(--forest); color: #fff; }
.btn-dark:hover { background: var(--forest-2); }
.btn-ghost { background: var(--white); color: var(--forest); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--forest); }
.btn-danger { background: var(--white); color: var(--red); border-color: #efc4c1; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: var(--text-xs); border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* Forms */
.form { display: grid; gap: 14px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
label.f { display: grid; gap: 5px; font-size: var(--text-xs); font-weight: 700; color: var(--forest); }
label.f small { font-weight: 500; color: var(--muted); }
.f input, .f select, .f textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid #cdd9d3; border-radius: 9px; background: #fff; font-size: var(--text-sm); font-weight: 500; }
.f textarea { min-height: 80px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(43,182,115,.18); }
.check { display: flex; gap: 8px; align-items: center; font-size: var(--text-sm); font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--green-ink); }
.err { color: var(--red); font-size: var(--text-sm); font-weight: 600; }
.hint { font-size: var(--text-xs); color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th { text-align: left; font-size: var(--text-xs); color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbfcfb; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .85em; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--forest); font-size: var(--text-base); margin-bottom: 4px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; background: #eef2f0; color: var(--muted); }
.pill.ok { background: var(--green-soft); color: var(--green-ink); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.info { background: var(--blue-soft); color: #157c7c; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b9c5c0; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(43,182,115,.2); }

/* Media */
.thumb { width: 96px; aspect-ratio: 16/9; border-radius: 8px; object-fit: cover; background: #0E3B2E; display: block; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.media-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-card .pv { aspect-ratio: 16/9; background: #0b2c22; display: grid; place-items: center; }
.media-card .pv img, .media-card .pv video { width: 100%; height: 100%; object-fit: contain; display: block; }
.media-card .body { padding: 12px 14px; display: grid; gap: 6px; font-size: var(--text-sm); flex: 1; }
.media-card .body h3 { font-size: var(--text-base); font-weight: 700; }
.media-card .meta { color: var(--muted); font-size: var(--text-xs); }
.media-card .foot { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Planner */
.planner td.slot { padding: 6px; min-width: 120px; }
.cell { border-radius: 8px; padding: 7px 9px; font-size: var(--text-xs); font-weight: 600; line-height: 1.3; min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
.cell.merchant { background: #f1f4f2; color: var(--muted); }
.cell.booked { background: var(--blue-soft); color: #0f5f5f; cursor: pointer; }
.cell.pending { background: var(--amber-soft); color: var(--amber); cursor: pointer; }
.cell.free { border: 1.5px dashed #bcd2c6; color: var(--green-ink); cursor: pointer; background: #fff; }
.cell.free.sel { background: var(--green); border-color: var(--green); color: var(--forest); }
.cell small { font-weight: 500; opacity: .85; }
.bar { position: sticky; bottom: 0; margin-top: 14px; background: var(--forest); color: #fff; border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.bar .f { color: #fff; } .bar .f select, .bar .f input { min-height: 36px; color: var(--ink); }

/* Dialog */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 24px)); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); }
dialog::backdrop { background: rgba(10,30,24,.55); }
dialog .dh { padding: 18px 20px 0; display: flex; justify-content: space-between; gap: 12px; align-items: start; }
dialog .dh h2 { font-size: var(--text-lg); }
dialog .db { padding: 16px 20px; max-height: 70vh; overflow-y: auto; }
dialog .df { padding: 14px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }
.x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; background: var(--forest); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: var(--text-sm); font-weight: 600; max-width: 380px; }
.toast.bad { background: var(--red); }

/* Auth screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .art { background: radial-gradient(circle at 80% 15%, #13493a, var(--forest) 60%); color: #e8f2ec; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .art img.logo { height: 52px; width: auto; }
.auth .art h2 { color: #fff; font-size: 2.1rem; font-weight: 800; line-height: 1.1; max-width: 16ch; }
.auth .art h2 span { color: var(--green); }
.auth .art p { color: #a9c3b7; margin-top: 14px; max-width: 44ch; }
.auth .art img.qube { max-height: 300px; width: auto; align-self: center; }
.auth .panel { display: grid; place-items: center; padding: 32px 20px; background: #fff; }
.auth .box { width: min(400px, 100%); }
.auth .box h1 { font-size: 1.6rem; font-weight: 800; }
.auth .box > p { color: var(--muted); margin: 6px 0 22px; font-size: var(--text-sm); }
.auth .links { margin-top: 18px; font-size: var(--text-sm); color: var(--muted); display: grid; gap: 6px; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; position: relative; padding-left: 36px; font-size: var(--text-sm); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--green-soft); color: var(--green-ink); font-weight: 800; font-size: 12px; display: grid; place-items: center; }
.keybox { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; font-weight: 700; letter-spacing: .08em; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; color: var(--forest); }
.split2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.quote-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: var(--text-sm); }
.quote-total { display: flex; justify-content: space-between; font-weight: 800; font-size: var(--text-lg); color: var(--forest); padding-top: 10px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.skel { background: linear-gradient(90deg, #eef2f0, #f7f9f8, #eef2f0); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--forest); position: sticky; top: 0; z-index: 30; }
  .topbar img { height: 30px; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
  .topbar svg { width: 26px; height: 26px; }
  .auth { grid-template-columns: 1fr; }
  .auth .art { padding: 28px 24px; gap: 20px; }
  .auth .art img.qube { display: none; }
  .auth .art h2 { font-size: 1.5rem; }
  .split2 { grid-template-columns: 1fr; }
  main { padding: 20px 14px 60px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 860px) { .bar { position: static; } }
/* Play mode: spaced out vs one longer advert */
.chk { display: flex; gap: 8px; align-items: flex-start; font-size: var(--text-sm); line-height: 1.4; cursor: pointer; }
.chk input { width: 17px; height: 17px; margin-top: 1px; flex: none; accent-color: var(--green-ink); }
.bar .chk { align-items: center; color: #fff; align-self: flex-end; min-height: 36px; }
.bar .chk input { accent-color: #9be37a; margin-top: 0; }
.playmode { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 12px 0 0; display: grid; gap: 8px; }
.playmode legend { font-weight: 700; font-size: var(--text-sm); padding: 0 4px; }
/* Revenue reports */
.sub-h { font-size: var(--text-lg); color: var(--forest); margin: 22px 0 10px; }
.seg { display: inline-flex; gap: 4px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.seg a { padding: 7px 14px; border-radius: 7px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: var(--text-sm); }
.seg a[aria-selected="true"] { background: var(--forest); color: #fff; }
.rf-row { align-items: flex-end; }
tr.total td { font-weight: 800; border-top: 2px solid var(--forest); }
table.daily tr.newday td { border-top: 2px solid var(--line); }
.print-only { display: none; }
@media print {
  .side, .topbar, .page-head .actions, .seg, .no-print { display: none !important; }
  .shell { display: block; } main { padding: 0 !important; }
  .print-only { display: block; }
  .table-wrap { overflow: visible; border: 0; } table { font-size: 10pt; }
  .kpi { border: 1px solid #999; }
}
.daily-wrap > summary { cursor: pointer; font-weight: 700; color: var(--forest); margin: 22px 0 6px; }
@media print { .daily-wrap > summary { display: none; } }
