/* Back office: layout on top of the app's styles (/css/styles.css). */
body { background: var(--bg); }

.bo { min-height: 100vh; display: flex; flex-direction: column; }
.bo-top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 32px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.bo-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; white-space: nowrap; }
.bo-brand .bo-logo, .bo-brand svg { width: 32px; height: 32px; }
.bo-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.bo-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  color: var(--subtle-fg); text-decoration: none; font-size: 15px;
}
.bo-tab .icon { width: 18px; height: 18px; }
.bo-tab:hover { background: var(--muted); color: var(--fg); }
.bo-tab.active { background: var(--fg); color: var(--bg); }
.bo-user { display: flex; align-items: center; gap: 8px; }

.bo-main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px; }
.bo-head { display: flex; flex-direction: column; gap: 6px; }
.bo-head .crumbs { margin-bottom: 6px; }
.bo-title { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; }
.bo-card { padding: 24px 28px; }

.bo-search { max-width: 360px; margin-bottom: 12px; }
.bo-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--subtle-fg); }
.bo-true { color: var(--win); font-weight: 600; }
.bo-false { color: var(--muted-fg); }

.bo-password { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.bo-password > .field { flex: 1; min-width: 240px; }
.bo-password > .btn { margin-bottom: 26px; }
.bo-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 15px; }
.bo-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--fg); }
.bo-done { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-radius: 12px; background: var(--muted); }
.bo-done .icon { width: 18px; height: 18px; color: var(--win); }
.bo-id { font-size: 13px; color: var(--subtle-fg); }
.bo-textarea { min-height: 110px; resize: vertical; padding-top: 10px; line-height: 1.5; }

/* image container */
.bo-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 200px; padding: 20px; position: relative; overflow: hidden;
  border: 1.5px dashed var(--border); border-radius: 14px; background: var(--muted);
  color: var(--fg); font: inherit; cursor: pointer; text-align: center;
}
.bo-drop:hover, .bo-drop.over { border-color: var(--fg); }
.bo-drop-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); }
.bo-drop-icon .icon { width: 20px; height: 20px; }
.bo-drop-img { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.bo-drop-change { position: absolute; bottom: 12px; right: 12px; padding: 6px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-size: 13px; }

/* ad list */
.bo-ads { display: flex; flex-direction: column; }
.bo-ad { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 16px 0; border-top: 1px solid var(--border); }
.bo-ad:first-child { border-top: 0; padding-top: 0; }
.bo-ad-img { width: 120px; height: 80px; object-fit: cover; border-radius: 10px; background: var(--muted); }
.bo-ad-noimg { display: grid; place-items: center; color: var(--muted-fg); }
.bo-ad-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bo-ad-url { color: var(--subtle-fg); overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .bo-top { padding: 12px 16px; gap: 12px; }
  .bo-main { padding: 20px 16px; }
  .bo-card { padding: 20px 16px; }
  .bo-ad { grid-template-columns: 80px minmax(0, 1fr) auto; }
  .bo-ad-img { width: 80px; height: 56px; }
}

/* customers → one customer */
.bo-link { color: var(--fg); text-decoration: none; font-weight: 500; }
.bo-link:hover { text-decoration: underline; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--muted); }
.bo-back { display: inline-flex; align-items: center; gap: 4px; color: var(--subtle-fg); text-decoration: none; font-size: 15px; width: fit-content; }
.bo-back .icon { width: 18px; height: 18px; }
.bo-back:hover { color: var(--fg); }
.bo-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 24px; margin: 0; }
.bo-facts dt { font-size: 13px; color: var(--muted-fg); margin-bottom: 4px; }
.bo-facts dd { margin: 0; overflow-wrap: anywhere; }

/* "Add advertisement" picker: search + a grid of ad banners */
.dialog.bo-pick { width: min(760px, calc(100vw - 32px)); max-width: none; }
.bo-pick-search { margin-top: 16px; }
.bo-pick-count { margin-top: 8px; }
.bo-pick-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-height: min(60vh, 560px); overflow-y: auto; margin-top: 12px; padding: 2px; }
.bo-pick-grid > .empty, .bo-pick-grid > .center, .bo-pick-none { grid-column: 1 / -1; }
.bo-banner {
  display: flex; flex-direction: column; gap: 0; padding: 8px 8px 0; overflow: hidden; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg); color: var(--fg); font: inherit;
}
.bo-banner:hover:not(:disabled) { border-color: var(--fg); }
.bo-banner:disabled { cursor: default; opacity: 0.6; }
.bo-banner-img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--muted); }
.bo-banner-noimg { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted-fg); }
.bo-banner-noimg .icon { width: 22px; height: 22px; }
.bo-banner-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.bo-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.bo-banner-text .bo-ad-url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bo-banner-added { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted-fg); }
.bo-banner-added .icon { width: 15px; height: 15px; }
.bo-pick-add { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 500; padding: 6px 12px; border-radius: 999px; background: var(--fg); color: var(--bg); flex-shrink: 0; }
.bo-pick-add .icon { width: 16px; height: 16px; }

/* banner designer */
.bo-section { display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 8px; }
.bo-designer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.bo-preview { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: 14px; background: repeating-conic-gradient(var(--muted) 0 25%, var(--bg) 0 50%) 0 0 / 16px 16px; }
.bo-preview-label { font-size: 12px; color: var(--muted-fg); margin-top: 6px; }
.bo-design-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.bo-design-controls > .field { gap: 12px; }
.bo-colour { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; width: fit-content; }
.bo-colour input { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; }
.bo-gradient { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 12px; background: var(--muted); }
.bo-gradient[hidden] { display: none; }
.bo-arrows { display: grid; grid-template-columns: repeat(8, 36px); gap: 6px; }
.bo-arrow { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--fg); font-size: 17px; cursor: pointer; }
.bo-arrow:hover { border-color: var(--fg); }
.bo-arrow.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.bo-angle-row { display: flex; align-items: center; gap: 12px; }
.bo-angle { flex: 1; accent-color: var(--fg); }
.bo-angle-value { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* saved ads shown as their banners */
.bo-ad-banner { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; border-top: 1px solid var(--border); }
.bo-ad-banner:first-child { border-top: 0; padding-top: 0; }
.bo-ad-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@media (max-width: 760px) { .bo-arrows { grid-template-columns: repeat(4, 36px); } }

.bo-sub-label { margin-top: 6px; }

.bo-pos { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bo-dim { opacity: 0.4; pointer-events: none; }
.bo-fill-note { font-size: 14px; line-height: 1.5; padding: 12px 14px; border-radius: 12px; background: var(--muted); color: var(--subtle-fg); }
.bo-fill-note[hidden] { display: none; }

.bo-fill-controls { display: flex; flex-direction: column; gap: 14px; padding: 14px; border-radius: 12px; background: var(--muted); }
.bo-fill-controls[hidden] { display: none; }
.bo-fill-row { display: flex; gap: 28px; flex-wrap: wrap; }
.bo-fill-controls .bo-fill-note { padding: 0; background: none; }
.bo-grid { display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 26px); gap: 4px; padding: 6px; width: fit-content; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }
.bo-grid-cell { display: grid; place-items: center; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.bo-grid-cell:hover { background: var(--muted); }
.bo-grid-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.bo-grid-cell.active { background: var(--fg); }
.bo-grid-cell.active .bo-grid-dot { background: var(--bg); }

.bo-pos[hidden], .bo-pos-sm[hidden] { display: none; }
.bo-grids { display: flex; gap: 16px; flex-wrap: wrap; }
.bo-pos-sm { gap: 6px; }
.bo-pos-sm .field-sub { font-size: 13px; color: var(--subtle-fg); }

/* staff */
.bo-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 13px; background: var(--muted); color: var(--subtle-fg); }
.bo-pill .icon { width: 14px; height: 14px; }
.bo-pill-owner { background: var(--fg); color: var(--bg); }
.bo-pill-blocked { background: color-mix(in srgb, var(--loss) 18%, transparent); color: var(--loss); }
.bo-row-blocked td { opacity: 0.65; }
.bo-row-blocked td:last-child { opacity: 1; }
.bo-row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.bo-note { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.bo-note .icon { width: 16px; height: 16px; }

/* how often an ad appears */
.bo-freq-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bo-freq-times { width: 90px; }
.bo-freq-row .select-wrap { min-width: 140px; }
.bo-freq { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--subtle-fg); }
.bo-freq .icon { width: 15px; height: 15px; }
.bo-dialog-field { margin-top: 18px; }

/* home: tiles + customers-over-time chart */
.bo-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.bo-tile { display: flex; flex-direction: column; gap: 6px; padding: 20px 24px; border: 1px solid var(--border); border-radius: var(--radius); }
.bo-tile-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted-fg); font-size: 14px; }
.bo-tile-value { font-size: 36px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.bo-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.bo-tile-label .bo-key { margin-right: 0; }
.bo-key-1 { background: var(--cat-1); }
.bo-key-2 { background: var(--cat-2); }
.bo-chart-wrap { display: flex; flex-direction: column; gap: 10px; }
.bo-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--subtle-fg); }
.bo-chart-area { position: relative; }
.bo-chart { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.bo-grid { stroke: var(--border); stroke-width: 1; }
.bo-axis { stroke: var(--muted-fg); stroke-width: 1; opacity: 0.6; }
.bo-tick { fill: var(--muted-fg); font-size: 12px; font-variant-numeric: tabular-nums; }
.bo-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bo-line.bo-line-1, .bo-dot.bo-line-1 { stroke: var(--cat-1); }
.bo-line.bo-line-2, .bo-dot.bo-line-2 { stroke: var(--cat-2); }
.bo-dot { fill: var(--bg); stroke-width: 2; }
.bo-dot-hover { stroke-width: 2.5; }
.bo-end-label { fill: var(--fg); font-size: 12.5px; }
.bo-cross { stroke: var(--muted-fg); stroke-width: 1; stroke-dasharray: 3 3; }
.bo-tip { position: absolute; top: 4px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); box-shadow: var(--shadow); font-size: 13px; pointer-events: none; white-space: nowrap; z-index: 2; }
.bo-tip[hidden] { display: none; }
.bo-table-view { margin-top: 14px; }
.bo-table-view summary { cursor: pointer; color: var(--subtle-fg); font-size: 14px; }
.bo-table-view .table-wrap { max-height: 320px; overflow-y: auto; margin-top: 8px; }

/* home filters */
.bo-filters { display: flex; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.bo-filter { display: flex; flex-direction: column; gap: 4px; }
.bo-filter .field-sub { font-size: 12.5px; color: var(--muted-fg); }
.bo-date { width: 160px; }
.bo-filter .select-wrap { min-width: 180px; }

/* companies */
.bo-ad-facts { padding: 4px 0 2px; }
.bo-ad-facts dd { font-size: 14.5px; }
.bo-ad-actions { justify-content: flex-start; }

.bo-filter-grow { flex: 1; min-width: 220px; max-width: 420px; }
.bo-filter-grow .bo-search { max-width: none; margin-bottom: 0; }

.bo-tile-total { color: var(--muted-fg); font-weight: 500; }

/* ---- phones: logo + profile at the top, the pages as a bar along the bottom ---- */
.bo-profile, .bo-bottom { display: none; }
@media (max-width: 760px) {
  .bo-top { flex-wrap: nowrap; justify-content: space-between; }
  .bo-top .bo-nav, .bo-top .bo-user { display: none; }
  .bo-brand > span:not(.logo) { display: none; } /* just the logo, not the words */
  .bo-brand .logo { display: block; line-height: 0; }
  .bo-brand .bo-logo, .bo-brand svg { width: 38px; height: 38px; }
  .bo-profile { display: block; position: relative; }
  .bo-profile-btn {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--muted); color: var(--fg); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  }
  .bo-profile-btn[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
  .bo-profile-menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px; z-index: 30; }
  .bo-profile-menu[hidden] { display: none; }
  .bo-profile-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 6px; }
  .bo-bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .bo-bottom-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; border-radius: 10px;
    color: var(--muted-fg); text-decoration: none; font-size: 11px;
  }
  .bo-bottom-item .icon { width: 22px; height: 22px; }
  .bo-bottom-item.active { color: var(--fg); font-weight: 600; }
  .bo-main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); } /* room for the bottom bar */
}
@media (max-width: 760px) {
  /* filters stack neatly on a phone: the time periods fill the width (and wrap if needed) */
  .bo-filters > div:first-child { width: 100%; }
  .bo-filters .segmented { display: flex; flex-wrap: wrap; width: 100%; }
  .bo-filters .segment { flex: 1 1 auto; padding-left: 8px; padding-right: 8px; }
  .bo-filters .bo-filter { flex: 1 1 140px; }
  .bo-date { width: 100%; }
  .bo-filters .bo-filter .select-wrap { min-width: 0; }
  .segmented { max-width: 100%; flex-wrap: wrap; } /* any other segmented control never runs off the screen */
}
