/* DayZero app shell.
   Dark, dense, keyboard-first. Every colour resolves from tokens so the shell
   can re-tint itself to the generated brand. */
:root {
  --bg: #0a0c12;
  --bg-raised: #11141c;
  --bg-panel: #151925;
  --bg-input: #0d1017;
  --line: #232838;
  --line-soft: #1b1f2c;
  --text: #e7e9ee;
  --text-dim: #98a1b3;
  --text-faint: #6b7488;
  --accent: #6d8cff;
  --accent-soft: rgba(109, 140, 255, 0.14);
  --good: #35c07f;
  --warn: #e0a33c;
  --bad: #ec6a6a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.85);
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 0.9em; }
code, kbd { font-family: var(--mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* Layout --------------------------------------------------------------- */
.app { display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-raised), var(--bg));
  position: sticky; top: 0; z-index: 30;
}
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brandmark svg { width: 26px; height: 26px; }
.brandmark small { display: block; font-weight: 400; font-size: 11px; color: var(--text-faint); letter-spacing: 0; }
.topbar-spacer { flex: 1; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(53, 192, 127, 0.16); }
.dot.off { background: var(--warn); }

.workspace { display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
@media (max-width: 1080px) { .workspace { grid-template-columns: 1fr; } }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px; overflow-y: auto; max-height: calc(100vh - 110px);
  background: var(--bg-raised);
}
@media (max-width: 1080px) { .sidebar { max-height: none; border-right: none; border-bottom: 1px solid var(--line); } }

.content { padding: 22px 24px 80px; overflow-y: auto; max-height: calc(100vh - 110px); min-width: 0; }
@media (max-width: 1080px) { .content { max-height: none; } }

.footerbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding: 10px 20px;
  font-size: 12px; color: var(--text-faint); background: var(--bg-raised);
}

/* Panels --------------------------------------------------------------- */
.panel { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-sub { color: var(--text-dim); font-size: 13px; margin: 0; }

.section-head { margin: 0 0 16px; }
.section-head h1 { font-size: 24px; margin-bottom: 6px; }
.section-head p { color: var(--text-dim); max-width: 76ch; margin: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.notice {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--bg-input); border-radius: var(--radius-sm);
  padding: 12px 14px; color: var(--text-dim); font-size: 13px;
}
.notice.warn { border-left-color: var(--warn); }
.notice.good { border-left-color: var(--good); }
.notice strong { color: var(--text); }

/* Forms ---------------------------------------------------------------- */
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
.field .hint { font-size: 12px; color: var(--text-faint); text-transform: none; letter-spacing: 0; }
input, select, textarea, button { font: inherit; }
input[type='text'], input[type='email'], input[type='url'], input[type='search'], select, textarea {
  background: var(--bg-input); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 74px; }
input[type='range'] { width: 100%; accent-color: var(--accent); }
input[type='checkbox'] { accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--line); background: var(--bg-input); color: var(--text);
  padding: 8px 13px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-wide { width: 100%; }
.btn-danger { border-color: rgba(236, 106, 106, 0.4); color: var(--bad); }

/* Tabs ----------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 20px; padding-bottom: 0; }
.tab {
  border: none; background: none; color: var(--text-dim); cursor: pointer;
  padding: 9px 12px; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }

/* Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { background: var(--bg-input); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.015); }
td.num, th.num { text-align: right; font-family: var(--mono); }
.scroll-y { max-height: 420px; overflow-y: auto; }

/* Chips, pills, badges ------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--line); font-size: 11.5px; color: var(--text-dim);
}
.chip.good { border-color: rgba(53, 192, 127, 0.4); color: var(--good); }
.chip.bad { border-color: rgba(236, 106, 106, 0.4); color: var(--bad); }
.chip.warn { border-color: rgba(224, 163, 60, 0.4); color: var(--warn); }
.chip.accent { border-color: var(--accent); color: var(--accent); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }

/* Metric cards --------------------------------------------------------- */
.metric { background: var(--bg-input); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.metric .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 4px; }
.metric .value { font-size: 17px; font-weight: 600; word-break: break-word; }
.metric .sub { font-size: 12px; color: var(--text-dim); }

/* Brand previews ------------------------------------------------------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-input); }
.swatch .chip-colour { height: 54px; display: flex; align-items: flex-end; justify-content: flex-end; padding: 6px 8px; font-size: 11px; font-family: var(--mono); }
.swatch .meta { padding: 8px 10px; font-size: 12px; }
.swatch .meta strong { display: block; font-size: 12.5px; }

.logo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.logo-card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-input); overflow: hidden; display: flex; flex-direction: column; }
.logo-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.logo-stage { display: grid; place-items: center; padding: 22px; background: #fff; min-height: 150px; }
.logo-stage.dark { background: #0d1017; }
.logo-stage svg { max-height: 110px; width: auto; }
.logo-meta { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }

/* Checklist ------------------------------------------------------------ */
.check-list { display: grid; gap: 6px; }
.check-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-input); }
.check-item input { margin-top: 3px; flex: none; }
.check-item.done { opacity: 0.55; }
.check-item.done label { text-decoration: line-through; }
.check-item .detail { color: var(--text-dim); font-size: 12.5px; }
.phase { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); margin: 14px 0 6px; }

.progress { height: 7px; background: var(--bg-input); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

/* Markdown ------------------------------------------------------------- */
.md { font-size: 13.5px; color: var(--text-dim); }
.md h1, .md h2, .md h3 { color: var(--text); margin-top: 1.4em; font-size: 15px; }
.md h1 { font-size: 19px; }
.md h2 { font-size: 16px; }
.md ul, .md ol { padding-left: 20px; }
.md li { margin-bottom: 4px; }
.md code { background: var(--bg-input); border: 1px solid var(--line-soft); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--bg-input); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; }
.md blockquote { margin: 0 0 1em; padding: 10px 14px; border-left: 3px solid var(--warn); background: var(--bg-input); border-radius: var(--radius-sm); }
.md table { margin: 0 0 1em; }
.md strong { color: var(--text); }

/* Preview -------------------------------------------------------------- */
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; overflow: auto; }
.preview-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

/* File tree ------------------------------------------------------------ */
.file-tree { display: grid; gap: 4px; font-family: var(--mono); font-size: 12.5px; max-height: 460px; overflow-y: auto; }
.file-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 9px; border-radius: 6px; border: 1px solid transparent; }
.file-row:hover { background: var(--bg-input); border-color: var(--line); }
.file-row button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }

/* Spinner and toast ---------------------------------------------------- */
.spinner { width: 13px; height: 13px; border: 2px solid var(--text-faint); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 11px 16px; border-radius: var(--radius); opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease; z-index: 100; max-width: 90vw; font-size: 13px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { border-color: rgba(236, 106, 106, 0.5); }

/* Printable-form modal ------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 90; padding: 22px;
  background: rgba(4, 6, 10, 0.72); display: flex;
  align-items: stretch; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-panel {
  display: flex; flex-direction: column; width: min(1140px, 100%); min-height: 0;
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.modal-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal-titles strong { font-size: 14px; }
#form-modal-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #6f6f6f; }
.modal-foot { padding: 9px 14px; border-top: 1px solid var(--line); }

/* Printing normally targets the frame's own document. If a browser prints its
   host page instead, the form must still be the only thing on the sheet, so
   the modal chrome and the app are hidden — but only while the modal is open,
   otherwise printing the app itself would come out blank. */
@media print {
  body.form-open .app,
  body.form-open #toast,
  body.form-open .modal-head,
  body.form-open .modal-foot { display: none !important; }
  body.form-open .modal { position: static; inset: auto; padding: 0; background: none; display: block; }
  body.form-open .modal-panel {
    width: auto; border: 0; border-radius: 0; box-shadow: none; overflow: visible; height: auto;
  }
  body.form-open #form-modal-frame { display: block; height: 100vh; background: none; }
}

.empty { padding: 26px; text-align: center; color: var(--text-faint); border: 1px dashed var(--line); border-radius: var(--radius); }
.skeleton { background: linear-gradient(90deg, var(--bg-input), var(--line-soft), var(--bg-input)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; height: 14px; border-radius: 5px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
