/* app.css — application chrome. Signage/sheet styling lives in sheet.css. */

:root {
  --bg: #EFF2F5;
  --surface: #FFFFFF;
  --surface-2: #F7F9FA;
  --nav: #14182B;
  --ink: #14182B;
  --ink-2: #4A5468;
  --ink-3: #78839A;
  --rule: #DCE2E8;
  --rule-soft: #EBEFF3;
  --teal: #0E6870;
  --teal-2: #0A5057;
  --teal-soft: #E1EFF0;
  --gold: #A96F14;
  --gold-soft: #FBF1DE;
  --gold-rule: #E7CB9C;
  --red: #B23A32;
  --red-soft: #FBEDEC;
  --green: #26714F;
  --green-soft: #E5F2EC;
  --display: Bahnschrift, "DIN Alternate", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, Consolas, monospace;
  --shadow: 0 1px 2px rgba(20,24,43,.06), 0 10px 28px -20px rgba(20,24,43,.45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; }
p { margin: 0; }
a { color: var(--teal); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---- top bar -------------------------------------------------------------- */
.bar {
  background: var(--nav);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.bar .brand {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .05em;
  white-space: nowrap;
}
.bar .brand i { color: #E0A75A; font-style: normal; }
.bar .brand em { color: #4FB3BA; font-style: normal; font-weight: 400; }
.bar nav { display: flex; gap: 2px; margin-left: 8px; flex-wrap: wrap; }
.bar nav button {
  background: none;
  border: 0;
  color: #A8B1C3;
  padding: 8px 13px;
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.bar nav button:hover { color: #fff; }
.bar nav button.sel { color: #fff; border-bottom-color: #4FB3BA; font-weight: 600; }
.bar .spacer { flex: 1; }
.bar .chip {
  font-size: 11.5px;
  color: #8E98AC;
  border: 1px solid rgba(255,255,255,.16);
  padding: 3px 9px;
  white-space: nowrap;
}
.bar a.link { color: #4FB3BA; font-size: 13px; text-decoration: none; white-space: nowrap; }

/* ---- layout --------------------------------------------------------------- */
.page { padding: 20px; max-width: 1560px; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.split { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.split-wide { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) {
  .split, .split-wide { grid-template-columns: 1fr; }
}

.card { background: var(--surface); border: 1px solid var(--rule); }
.card-h {
  padding: 11px 15px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card-h h2, .card-h h3 {
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: .07em;
  text-transform: uppercase;
  font-weight: 600;
}
.card-h .spacer { flex: 1; }
.card-b { padding: 15px; }
.card-b.tight { padding: 0; }

.section-title {
  font-family: var(--display);
  font-size: 21px;
  letter-spacing: .02em;
  margin-bottom: 3px;
}
.section-sub { color: var(--ink-3); font-size: 13.5px; margin-bottom: 16px; }

/* ---- controls ------------------------------------------------------------- */
.btn {
  background: var(--teal);
  color: #fff;
  border: 1px solid var(--teal);
  padding: 9px 16px;
  font-family: var(--display);
  font-size: 12.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--teal-2); border-color: var(--teal-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--teal); border-color: var(--rule); }
.btn.ghost:hover:not(:disabled) { background: var(--teal-soft); border-color: var(--teal); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: var(--rule); }
.btn.danger.ghost:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 11px; }
.btn.lg { padding: 13px 26px; font-size: 14px; }
.btn.block { width: 100%; justify-content: center; }

label.lbl, .lbl {
  display: block;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 5px;
}
.field {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  border-radius: 2px;
}
.field:focus { border-color: var(--teal); background: #fff; outline: none; }
.field.sm { padding: 5px 7px; font-size: 13px; }
.fieldset { display: grid; gap: 11px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; }
.inline-check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; }
input[type="color"] { padding: 2px; height: 32px; cursor: pointer; }
input[type="range"] { width: 100%; }

.pill {
  display: inline-block;
  font-size: 10.5px;
  padding: 2px 8px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.pill.t { background: var(--teal-soft); color: var(--teal); }
.pill.g { background: var(--gold-soft); color: var(--gold); }
.pill.r { background: var(--red-soft); color: var(--red); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.n { background: var(--rule-soft); color: var(--ink-3); }

.muted { color: var(--ink-3); font-size: 12.5px; }
.n { font-variant-numeric: tabular-nums; }
.empty { color: var(--ink-3); padding: 30px 16px; text-align: center; font-size: 13.5px; }

/* ---- notices -------------------------------------------------------------- */
.notice {
  padding: 11px 14px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  font-size: 13.5px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.notice.warn { background: var(--gold-soft); border-color: var(--gold-rule); }
.notice.bad { background: var(--red-soft); border-color: #E9B7B2; }
.notice.good { background: var(--green-soft); border-color: #B5D6C6; }
.notice b { font-weight: 700; }
.notice .spacer { flex: 1; }

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: grid;
  gap: 8px;
  max-width: 380px;
}
.toast {
  background: var(--nav);
  color: #fff;
  padding: 11px 15px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toastin .18s ease-out;
}
.toast.bad { background: var(--red); }
.toast.good { background: var(--green); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---- stat strip ----------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px;
         background: var(--rule); border: 1px solid var(--rule); }
.stats > div { background: var(--surface); padding: 12px 15px; }
.stats .k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
            font-weight: 700; }
.stats .v { font-family: var(--display); font-size: 27px; line-height: 1.1;
            font-variant-numeric: tabular-nums; margin-top: 2px; }
.stats .v.warn { color: var(--gold); }
.stats .v.bad { color: var(--red); }
.stats .v.good { color: var(--teal); }
.stats .s { font-size: 11.5px; color: var(--ink-3); }

/* ---- tables --------------------------------------------------------------- */
.scroller { overflow: auto; max-height: 460px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th {
  text-align: left;
  font-family: var(--display);
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  padding: 9px 11px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 2;
}
td { padding: 7px 11px; border-bottom: 1px solid var(--rule-soft); color: var(--ink-2); }
tbody tr:hover td { background: var(--surface-2); }
tr.bad td { background: var(--red-soft); }
tr.bad:hover td { background: #F7E2E0; }
tr.excluded td { opacity: .45; }
td.n, th.n { font-variant-numeric: tabular-nums; }
td .cellinput {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 3px 5px;
  border-radius: 2px;
}
td .cellinput:hover { border-color: var(--rule); background: #fff; }
td .cellinput:focus { border-color: var(--teal); background: #fff; outline: none; }

/* ---- dropzone ------------------------------------------------------------- */
.drop {
  border: 2px dashed var(--rule);
  background: var(--surface);
  padding: 34px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop.hot { border-color: var(--teal); background: var(--teal-soft); }
.drop h3 { font-family: var(--display); font-size: 19px; letter-spacing: .03em; }
.drop p { color: var(--ink-3); font-size: 13px; margin-top: 5px; }
.drop .btn { margin-top: 14px; }

/* ---- signage cards -------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}
.sigcard {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
}
.sigcard.sel { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.sigcard .holder {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  padding: 8px;
  overflow: hidden;
  min-height: 120px;
}
.sigcard .cap { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.sigcard .cap .idx { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.sigcard .cap .nm {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.sigcard .acts { display: flex; gap: 5px; }
.sigcard .acts .btn { flex: 1; }
.sigcard input[type="checkbox"] { width: 15px; height: 15px; }

/* ---- A4 preview ----------------------------------------------------------- */
.sheets {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  padding: 18px;
  background: #DDE2E7;
  overflow: auto;
  max-height: 78vh;
  /* Stops the container collapsing to its padding while it is being rebuilt,
     which would make any measurement taken from it meaningless. */
  min-height: 320px;
}
.sheetwrap { position: relative; }
.sheetwrap .pagelabel {
  position: absolute;
  top: -17px;
  left: 0;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--display);
  letter-spacing: .09em;
  text-transform: uppercase;
}

/* ---- modal ---------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 18, 33, .55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 16px;
  z-index: 120;
  overflow: auto;
}
.modal.on { display: flex; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--rule);
  width: 100%;
  max-width: 980px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.55);
}
.modal-box.narrow { max-width: 460px; }
.modal-h {
  padding: 13px 17px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-h h3 { font-family: var(--display); font-size: 16px; letter-spacing: .04em; }
.modal-h .spacer { flex: 1; }
.modal-b { padding: 17px; }
.modal-f {
  padding: 13px 17px;
  border-top: 1px solid var(--rule);
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.x { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--ink-3); padding: 4px 8px; }
.x:hover { color: var(--ink); }

/* ---- box editor canvas (admin + per-signage edit) -------------------------- */
.stage {
  position: relative;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  min-height: 330px;
}
.stage-inner { position: relative; box-shadow: var(--shadow); background: #fff; }
.hbox {
  position: absolute;
  border: 1px dashed rgba(14, 104, 112, .75);
  background: rgba(14, 104, 112, .07);
  cursor: move;
  z-index: 5;
}
.hbox.sel { border: 1px solid var(--teal); background: rgba(14, 104, 112, .13); z-index: 6; }
.hbox .tag {
  position: absolute;
  top: -16px;
  left: -1px;
  font-size: 9.5px;
  background: var(--teal);
  color: #fff;
  padding: 1px 5px;
  white-space: nowrap;
  font-family: var(--display);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.hbox.mask { border-color: rgba(178, 58, 50, .8); background: rgba(178, 58, 50, .1); }
.hbox.mask .tag { background: var(--red); }
.hbox .handle {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #fff;
  border: 1.5px solid var(--teal);
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}
.boxlist { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.boxrow {
  background: var(--surface);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.boxrow.sel { background: var(--teal-soft); }
.boxrow .bk { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.boxrow .bn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boxrow .eye { background: none; border: 0; color: var(--ink-3); padding: 2px 5px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
}
.tabs button.sel { color: var(--ink); border-bottom-color: var(--teal); font-weight: 600; }

.tplcard {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 11px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.tplcard.active { border-color: var(--teal); box-shadow: inset 3px 0 0 var(--teal); }
.tplcard .thumb {
  width: 62px;
  height: 84px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  flex: none;
}
.tplcard .meta { flex: 1; min-width: 0; }
.tplcard .meta h4 { font-family: var(--display); font-size: 15px; letter-spacing: .03em; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }

.hidden { display: none !important; }
