/* BC Wiki. Same design family as the fleet app: identical tokens and class names,
   so anything copied between the two apps keeps working. */

:root {
  --red: #C8102E;
  --red-dark: #a00d24;
  --red-light: #fdf0f2;
  --red-mid: #f5c0c8;
  --bg: #f7f6f4;
  --bg2: #ffffff;
  --bg3: #f0eeec;
  --border: #e4e1dd;
  --border-strong: #ccc9c4;
  --text: #1a1917;
  --text2: #6b6762;
  --text3: #a8a49f;
  --green: #1a7d4a;
  --green-bg: #edf7f2;
  --amber: #b85c00;
  --amber-bg: #fff4e6;
  --blue: #1a5fa8;
  --blue-bg: #edf3fc;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  --tabbar-h: 60px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: none;
}

#app { height: 100%; display: flex; flex-direction: column; }

.screen { display: none; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

.hidden { display: none !important; }

/* ── Login ── */
.identity-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: #fff;
  overflow-y: auto;
}

.bc-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 2rem;
}

/* A rounded square, where the fleet app uses a circle. On a phone home screen
   the two apps sit side by side and have to be told apart at a glance. */
.bc-logo-square {
  width: 96px;
  height: 96px;
  background: var(--red);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(200,16,46,0.25);
  margin-bottom: 0.35rem;
}
.bc-logo-square svg { width: 62px; height: 62px; }

.bc-wordmark {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.bc-wordmark span { color: var(--red); }

.bc-sub-label {
  font-size: 0.7rem;
  color: var(--text3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.login-form { width: 100%; max-width: 360px; }

.login-error {
  background: var(--red-light);
  border: 1px solid var(--red-mid);
  color: var(--red-dark);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.84rem;
  margin-bottom: 0.9rem;
}

.login-hint {
  font-size: 0.78rem;
  color: var(--text3);
  text-align: center;
  margin-top: 1rem;
  line-height: 1.45;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 0.6rem; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.topbar-logo {
  width: 30px;
  height: 30px;
  background: var(--red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-logo svg { width: 22px; height: 22px; }

.view-title { font-size: 1rem; font-weight: 600; color: var(--text); }

.actor-badge {
  font-size: 0.78rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  color: var(--text2);
  font-weight: 500;
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: var(--bg3); }

/* ── Tabbar ── */
.tabbar {
  height: var(--tabbar-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  order: 99;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.tab-btn {
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: color 0.15s;
  position: relative;
  min-width: 0;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-btn.active { color: var(--red); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--red);
  border-radius: 0 0 2px 2px;
}
.tab-btn:active { opacity: 0.7; }

/* ── Content ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  text-align: center;
  color: var(--text2);
  padding: 3.5rem 1.5rem;
  max-width: 420px;
  margin: 0 auto;
}
.empty-state svg { width: 40px; height: 40px; color: var(--text3); margin-bottom: 0.9rem; }
.empty-state h2 { font-size: 1.05rem; color: var(--text); margin-bottom: 0.35rem; font-weight: 650; }
.empty-state p { font-size: 0.88rem; line-height: 1.5; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn:active { opacity: 0.8; transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 2px 8px rgba(200,16,46,0.25); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1.5px solid var(--border); }
.btn-full { width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 0.9rem; }
.form-label {
  font-size: 0.75rem;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.35rem;
}
.form-input, .form-textarea {
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
}
.form-input:focus, .form-textarea:focus { outline: none; border-color: var(--red); }

/* ── Toast ── */
.toast {
  order: 50;
  flex-shrink: 0;
  width: 100%;
  background: var(--text);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  text-align: center;
  cursor: pointer;
}
.toast.hidden { display: none; }
.toast.success { background: var(--green); }
.toast.error { background: #e04040; }

/* ── Modal (unused until Phase 1, kept so the shell is complete) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  transition: opacity .2s ease;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; display: flex; }

.modal-box {
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.25rem 1rem 2.5rem;
  position: relative;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  transition: transform .24s cubic-bezier(.2, .8, .25, 1);
}
.modal-overlay.hidden .modal-box { transform: translateY(102%); }

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg3);
  border: none;
  color: var(--text2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

/* ── Motion ── */
.content.tab-enter { animation: content-in .18s ease-out; }
@keyframes content-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

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

@media (max-width: 400px) {
  .tab-btn { font-size: 0.62rem; padding-left: 2px; padding-right: 2px; }
}

/* ── Phase 1: manual, capture, approvals ── */

.loading { text-align: center; color: var(--text3); padding: 3rem 1rem; font-size: 0.9rem; }

.error-box {
  background: var(--red-light);
  border: 1px solid var(--red-mid);
  color: var(--red-dark);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font-size: 0.85rem;
  margin: 0.75rem 0;
}

.notice {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font-size: 0.85rem;
  margin-top: 0.85rem;
  line-height: 1.5;
}
.notice-good { background: var(--green-bg); border-color: #a8ddc0; color: var(--green); }
.notice-warn { background: var(--amber-bg); border-color: #f0d0a0; color: var(--amber); }
.notice-sub { font-size: 0.78rem; opacity: 0.85; margin-top: 0.3rem; }

.btn-link {
  background: none; border: none; padding: 0;
  color: inherit; font: inherit; font-weight: 600;
  text-decoration: underline; cursor: pointer;
}

/* Manual */
.role-switch { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.role-chip {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 0.3rem 0.8rem;
  font-size: 0.78rem; font-weight: 600; color: var(--text2);
  cursor: pointer; text-transform: capitalize; font-family: inherit;
}
.role-chip.active { background: var(--red); border-color: var(--red); color: #fff; }

.manual-section { margin-bottom: 1.5rem; }
.section-title {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  padding-bottom: 0.35rem; margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}
.manual-section .manual-section .section-title {
  font-size: 0.92rem; border-bottom-width: 1px; color: var(--text2);
}

.fact {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.9rem 1rem;
  margin-bottom: 0.75rem; box-shadow: var(--shadow);
}
.fact-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.fact-title { font-size: 0.95rem; font-weight: 650; color: var(--text); }

/* Rendered markdown */
.markdown { font-size: 0.9rem; color: var(--text); line-height: 1.6; }
.markdown > *:last-child { margin-bottom: 0; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown pre, .markdown table { margin-bottom: 0.7rem; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { font-size: 0.95rem; font-weight: 650; margin: 0.9rem 0 0.4rem; }
.markdown ul, .markdown ol { padding-left: 1.2rem; }
.markdown li { margin-bottom: 0.2rem; }
.markdown code {
  background: var(--bg3); border-radius: 4px;
  padding: 1px 5px; font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.markdown pre {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem; overflow-x: auto;
}
.markdown pre code { background: none; padding: 0; }
.markdown blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 0.75rem; color: var(--text2);
}
.markdown a { color: var(--blue); }
.markdown table { border-collapse: collapse; width: 100%; font-size: 0.85rem; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 0.35rem 0.55rem; text-align: left; }
.markdown th { background: var(--bg3); font-weight: 650; }
.markdown img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.6rem 0; align-items: center; }
.chip {
  display: inline-flex; align-items: center;
  border-radius: 20px; padding: 0.25rem 0.7rem;
  font-size: 0.74rem; font-weight: 600;
  border: 1.5px solid var(--border); background: var(--bg3);
  color: var(--text2); font-family: inherit;
}
button.chip { cursor: pointer; }
.chip-placement { text-decoration: line-through; opacity: 0.55; }
.chip-placement.active { text-decoration: none; opacity: 1; background: var(--blue-bg); border-color: #b5cdea; color: var(--blue); }
.chip-tag { background: var(--bg); color: var(--text3); }
.chip-clearance { background: var(--amber-bg); border-color: #f0d0a0; color: var(--amber); white-space: nowrap; }
.chip-add { background: none; border-style: dashed; color: var(--text3); }
.chip-select {
  border-radius: 20px; padding: 0.25rem 0.7rem;
  font-size: 0.74rem; font-weight: 600; font-family: inherit;
  border: 1.5px solid var(--border); background: var(--bg3); color: var(--text2);
}

/* Add and import */
.add-wrap { max-width: 640px; margin: 0 auto; }
.add-intro { font-size: 0.85rem; color: var(--text2); margin-bottom: 0.85rem; line-height: 1.5; }
.add-box { margin-bottom: 0.85rem; font-size: 0.9rem; line-height: 1.5; resize: vertical; }
.admin-heading { font-size: 1rem; font-weight: 700; margin: 1.25rem 0 0.5rem; }
.admin-heading:first-child { margin-top: 0; }

/* Inbox */
.inbox-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.85rem; flex-wrap: wrap;
}
.inbox-count { font-size: 0.8rem; color: var(--text2); font-weight: 600; }
.inbox-bar-actions { display: flex; gap: 0.4rem; }

.proposal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.9rem 1rem;
  margin-bottom: 0.85rem; box-shadow: var(--shadow);
}
.proposal-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.proposal-pick { display: flex; align-items: center; }
.proposal-check { width: 18px; height: 18px; accent-color: var(--red); }
.proposal-meta { font-size: 0.72rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }

.proposal-title { font-weight: 650; margin-bottom: 0.5rem; }
.proposal-body { font-size: 0.88rem; line-height: 1.5; resize: vertical; font-family: inherit; }

.proposal-actions { display: flex; gap: 0.6rem; margin-top: 0.85rem; }
.btn-decide {
  flex: 1; height: 46px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-decide svg { width: 22px; height: 22px; }
.btn-decide:active { transform: scale(0.98); }
.btn-decide:disabled { opacity: 0.5; }
.btn-approve { background: var(--green-bg); border-color: #a8ddc0; color: var(--green); }
.btn-reject { background: var(--red-light); border-color: var(--red-mid); color: var(--red-dark); }

.placement-form { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }
.placement-form .placement-role { flex: 0 0 auto; width: auto; text-transform: capitalize; }
.placement-form .placement-path { flex: 1; min-width: 160px; }
