/* GBE — Design Tokens & Base */
:root {
  /* Color */
  --bg: #FAF9F6;
  --bg-sunken: #F2F0EA;
  --surface: #FFFFFF;
  --surface-2: #FBFAF7;
  --ink: #1C1B1A;
  --ink-2: #3A3733;
  --muted: #6B6963;
  --muted-2: #9C9890;
  --border: #E8E5DF;
  --border-strong: #D8D3CA;

  --accent: #2D5F7C;
  --accent-ink: #1B3F54;
  --accent-tint: #EAF1F5;
  --accent-tint-2: #D6E4EC;

  --ok: #2D7A4E;
  --ok-tint: #E5F1EA;
  --warn: #B8741D;
  --warn-tint: #F8EEDF;
  --err: #B33A3A;
  --err-tint: #F4E2E2;

  /* Type */
  --font-sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(28, 27, 26, 0.04), 0 0 0 0.5px rgba(28, 27, 26, 0.06);
  --shadow-md: 0 4px 14px rgba(28, 27, 26, 0.06), 0 0 0 0.5px rgba(28, 27, 26, 0.07);
  --shadow-lg: 0 24px 60px rgba(28, 27, 26, 0.16), 0 0 0 0.5px rgba(28, 27, 26, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
button { font-family: inherit; }

/* App shell */
.app {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

/* Top nav */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.topnav-brand .brandmark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.topnav-brand .brandmark img { width: 100%; height: 100%; object-fit: contain; }
.topnav-actions { display: flex; align-items: center; gap: 8px; }

.topnav-link {
  color: var(--muted);
  font-size: 13.5px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
}
.topnav-link:hover { background: var(--bg-sunken); color: var(--ink); }
.topnav-link.active { color: var(--ink); background: var(--bg-sunken); }

/* Page container */
.page {
  flex: 1;
  padding: 32px 36px 64px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}
.page.narrow { max-width: 760px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  text-wrap: pretty;
}
.page-header .sub {
  color: var(--muted);
  font-size: 14px;
  max-width: 56ch;
}
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #000; }
.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-sunken); border-color: var(--ink-2); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-sunken); color: var(--ink); }
.btn-danger {
  background: var(--surface);
  color: var(--err);
  border-color: var(--border-strong);
}
.btn-danger:hover:not(:disabled) { background: var(--err-tint); border-color: var(--err); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn-icon {
  width: 36px;
  padding: 0;
}
.btn-icon.btn-sm { width: 30px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .err-msg { font-size: 12.5px; color: var(--err); }
.req { color: var(--err); margin-left: 2px; }

.input, .textarea, .select {
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--ink);
  width: 100%;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.input.invalid, .textarea.invalid { border-color: var(--err); }
.input.invalid:focus, .textarea.invalid:focus { box-shadow: 0 0 0 3px var(--err-tint); }

/* Tables */
.tbl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--surface-2); }
.tbl tbody tr.dimmed td { color: var(--muted-2); }
.tbl tbody tr.dimmed .col-title { color: var(--muted); }

.col-title { font-weight: 600; color: var(--ink); }
.col-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.col-end { text-align: right; }
.col-action { width: 1%; white-space: nowrap; }
.col-cb { width: 36px; }

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.pill.err { background: var(--err-tint); color: var(--err); border-color: transparent; }
.pill.accent { background: var(--accent-tint); color: var(--accent-ink); border-color: transparent; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live .dot { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Progress */
.progress {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-sunken);
  overflow: hidden;
}
.progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
}
.progress.indeterminate .progress-bar {
  width: 38%;
  animation: indet 1.6s cubic-bezier(.5,0,.5,1) infinite;
}
@keyframes indet {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.status-line .dotwave { display: inline-flex; gap: 2px; }
.status-line .dotwave i {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  animation: dotw 1.2s ease-in-out infinite;
}
.status-line .dotwave i:nth-child(2) { animation-delay: 0.18s; }
.status-line .dotwave i:nth-child(3) { animation-delay: 0.36s; }
@keyframes dotw {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.card .card-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}

/* Empty states */
.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}
.empty p { margin: 0 0 18px; font-size: 13.5px; max-width: 44ch; margin-inline: auto; }

/* Wizard */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.stepper .step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
}
.stepper .step .num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-sunken);
  color: var(--muted);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stepper .step.active .num { background: var(--ink); color: #fff; }
.stepper .step.done .num { background: var(--accent); color: #fff; }
.stepper .step.active { color: var(--ink); font-weight: 500; }
.stepper .step.done { color: var(--ink-2); }
.stepper .sep {
  flex: 0 0 auto;
  width: 24px; height: 1px;
  background: var(--border-strong);
}

/* Modal */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(28, 27, 26, 0.36);
  display: grid; place-items: center;
  z-index: 50;
  padding: 24px;
  animation: fade 0.16s ease-out;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s cubic-bezier(.2,.8,.4,1);
  overflow: hidden;
}
.modal.lg { max-width: 640px; }
.modal-head {
  padding: 20px 24px 8px;
}
.modal-head h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.modal-head p { margin: 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 16px 24px; }
.modal-foot {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(4px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* Toasts */
.toaster {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  animation: pop 0.2s ease-out;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

/* Drag & drop */
.dnd-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  transition: box-shadow 0.12s, transform 0.12s, border-color 0.12s;
}
.dnd-row.dragging {
  opacity: 0.5;
  border-style: dashed;
}
.dnd-row.drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.dnd-grip {
  cursor: grab;
  color: var(--muted-2);
  width: 24px;
  height: 24px;
  display: grid; place-items: center;
  border-radius: 4px;
  flex-shrink: 0;
}
.dnd-grip:hover { color: var(--ink); background: var(--bg-sunken); }
.dnd-grip:active { cursor: grabbing; }
.dnd-row .body { flex: 1; min-width: 0; }
.dnd-row .body .ttl { font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.dnd-row .body .desc { color: var(--muted); font-size: 13px; line-height: 1.4; }
.dnd-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* Drop zones */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 28px 20px;
  text-align: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13.5px;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-tint); color: var(--accent-ink); }
.dropzone strong { color: var(--ink); font-weight: 600; }

/* Login */
.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  font-size: 20px;
  margin: 14px 0 4px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.login-card p.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }

/* Misc */
.row { display: flex; gap: 12px; align-items: center; }
.row.gap-sm { gap: 6px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 1.5px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
}
.tag-mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
}
hr.div { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* Utility */
.checkbox {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}
.checkbox:hover { border-color: var(--ink-2); }
.checkbox:checked {
  background: var(--ink);
  border-color: var(--ink);
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}
.checkbox.suggested {
  outline: 2px solid var(--accent-tint-2);
  outline-offset: 1px;
}

.suggested-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent-tint);
  padding: 2px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

/* Dropdown menu items */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.menu-item:hover:not([disabled]):not(.disabled) { background: var(--bg-sunken); }
.menu-item.danger { color: var(--err); }
.menu-item.danger:hover:not([disabled]) { background: var(--err-tint); }
.menu-item[disabled], .menu-item.disabled {
  color: var(--muted-2);
  cursor: not-allowed;
  pointer-events: none;
}

/* Animation utils */
.fade-in { animation: fade 0.2s ease-out; }
