/* Book Empire operator console — clean, minimal styling. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1c2128;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #2f6feb;
  --accent-ink: #ffffff;
  --ok: #1f9d55;
  --warn: #b7791f;
  --error: #c0392b;
  --approve: #1f9d55;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: #eef1f5;
  padding: 0.08em 0.35em;
  border-radius: 5px;
}

/* Top bar -------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.nav a {
  margin-left: 1.25rem;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { color: var(--ink); text-decoration: none; }

/* Layout --------------------------------------------------------------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-head h1 { margin: 0; font-size: 1.6rem; }
.subhead { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; }
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 2rem 0;
}

/* Buttons -------------------------------------------------------------- */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { text-decoration: none; border-color: #c8cdd6; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1f5fd6; }
.btn-approve { background: var(--approve); border-color: var(--approve); color: #fff; }
.btn-approve:hover { background: #178a48; }
.btn-small { padding: 0.32rem 0.7rem; font-size: 0.82rem; }

/* Cards ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.card-head h2 { margin: 0; font-size: 1.05rem; }
.warn-card { border-color: var(--warn); }
.warn-card p { margin: 0; color: var(--warn); }
.recipe-summary h2 { font-size: 1.05rem; }

/* Definition lists ----------------------------------------------------- */
.meta { margin: 0.75rem 0 1rem; display: grid; gap: 0.3rem; }
.meta > div { display: flex; justify-content: space-between; gap: 0.75rem; }
.meta dt { color: var(--muted); margin: 0; }
.meta dd { margin: 0; font-weight: 500; }
.meta-inline { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.meta-inline > div { flex-direction: column; gap: 0.1rem; }

/* Tables --------------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td {
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #fafbfc;
}
.table tbody tr:last-child td { border-bottom: none; }

/* Pills / status ------------------------------------------------------- */
.pill {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #eef1f5;
  color: var(--muted);
}
.pill-building { background: #e7f0ff; color: var(--accent); }
.pill-done { background: #e3f6ec; color: var(--ok); }
.pill-blocked { background: #fdecea; color: var(--error); }
.pill-pending { background: #f1f2f4; color: var(--muted); }
.pill-type { background: #efeafe; color: #6c47d6; }

/* Progress bar --------------------------------------------------------- */
.progress {
  display: inline-block;
  width: 90px;
  height: 8px;
  background: #eceef2;
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
}
.progress-bar { display: block; height: 100%; background: var(--ok); }
.progress-label { margin-left: 0.5rem; font-size: 0.8rem; color: var(--muted); }

/* Empty state ---------------------------------------------------------- */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Create form ---------------------------------------------------------- */
.create-form { display: grid; gap: 0.6rem; margin-top: 0.5rem; }
.create-form label { display: grid; gap: 0.25rem; font-size: 0.85rem; font-weight: 600; }
.create-form label small { font-weight: 400; color: var(--muted); }
.create-form input,
.create-form textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 0.9rem;
}
.create-form textarea { font-family: "SFMono-Regular", Menlo, monospace; resize: vertical; }
.create-form input:focus,
.create-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Stage tracker -------------------------------------------------------- */
.stages {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.stage {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
  background: #fafbfc;
}
.stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c7ccd5;
  flex: none;
}
.stage-name { font-weight: 600; }
.stage-status { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.02em; }
.stage-done .stage-dot { background: var(--accent); }
.stage-approved .stage-dot { background: var(--ok); }
.stage-approved { border-color: #bfe6cd; background: #f3fbf6; }
.stage-next { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 111, 235, 0.12); }

/* Gate ----------------------------------------------------------------- */
.gate { margin: 1rem 0; }
.gate-msg { margin: 0 0 0.6rem; }
.gate-done { color: var(--ok); font-weight: 600; }

/* Previews ------------------------------------------------------------- */
.previews { margin-top: 1.5rem; }
.previews h3, .issues h3 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.preview-links { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }

/* Compliance issues ---------------------------------------------------- */
.issues { margin-top: 1.5rem; }
.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.issue {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.45rem 0.65rem;
  border-radius: 7px;
  font-size: 0.86rem;
  background: #fafbfc;
  border: 1px solid var(--line);
}
.issue-level { font-weight: 700; font-size: 0.72rem; }
.issue-error { border-color: #f3c6c0; background: #fdf2f0; }
.issue-error .issue-level { color: var(--error); }
.issue-warn { border-color: #f0dcb0; background: #fdf8ec; }
.issue-warn .issue-level { color: var(--warn); }

.bundle { margin-top: 1rem; color: var(--ok); font-size: 0.88rem; }
.muted { color: var(--muted); }
.small { font-size: 0.78rem; font-weight: 400; }

/* Gate inline preview + edit/re-run ------------------------------------ */
.gate-preview {
  margin: 0.5rem 0 0.9rem;
  padding: 0.8rem 0.9rem;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.gate-preview p { margin: 0.2rem 0; }
.content-summary p { margin: 0.15rem 0; }
.pdf-preview {
  width: 100%;
  height: 540px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.meta-preview .desc {
  margin: 0.5rem 0;
  padding: 0.5rem 0.7rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.9rem;
}
.gate-actions { margin-bottom: 0.6rem; }
.btn-secondary { background: #eef1f5; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: #e4e8ee; }

.revise {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.revise > summary {
  cursor: pointer;
  padding: 0.55rem 0.8rem;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}
.revise[open] > summary { border-bottom: 1px solid var(--line); }
.revise form { display: grid; gap: 0.5rem; padding: 0.8rem; }
.revise label { font-size: 0.85rem; font-weight: 600; }
.revise textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: "SFMono-Regular", Menlo, monospace;
  font-size: 0.85rem;
  resize: vertical;
}
.revise textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.revise .btn { justify-self: start; }
