/* conceptfood Konditionssystem — light, compact, single-screen app shell.
   Page never scrolls; the group list and the editor scroll internally.
   Same class/JS contract preserved. */

:root {
  --app-bg: #efefef;
  --surface: #ffffff;
  --surface-muted: #f4f4f4;
  --surface-raised: #fafafa;
  --surface-hover: #f5f5f5;
  --surface-selected: #ececec;

  --line-subtle: #ededed;
  --line: #e2e2e2;
  --line-strong: #d2d2d2;

  --ink-950: #171717;
  --ink-900: #1f1f1f;
  --ink-800: #2e2e2e;
  --ink-700: #404040;
  --ink-650: #4a4a4a;
  --ink-600: #585858;
  --ink-500: #767676;
  --ink-400: #a0a0a0;

  --accent: #2e2e2e;
  --accent-strong: #141414;
  --accent-ink: #ffffff;
  --accent-weak: #ececec;
  --accent-border: #cfcfcf;

  --ok: #0f9d6b;
  --ok-weak: #e7f6ef;
  --ok-border: rgba(15, 157, 107, 0.30);
  --warn: #b7791f;
  --warn-weak: #fbf2e0;
  --warn-border: rgba(183, 121, 31, 0.32);
  --danger: #dc2626;
  --danger-weak: #fdeceb;
  --danger-border: rgba(220, 38, 38, 0.30);

  /* legacy aliases so any stray reference still themes */
  --background: var(--app-bg);
  --shell-background: var(--app-bg);
  --foreground: var(--ink-800);
  --surface-card: var(--surface);
  --accent-olive: var(--accent);
  --accent-brass: var(--warn);
  --shadow-panel: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-pop: 0 12px 28px rgba(15, 23, 42, 0.14);

  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --topbar-h: 44px;

  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--ink-800);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a, button, input, textarea, select { font: inherit; }

button, a {
  transition: background-color 120ms ease, border-color 120ms ease,
    color 120ms ease, box-shadow 120ms ease;
}

button { cursor: pointer; }

input, textarea, select { accent-color: var(--accent); }

input:focus-visible,
button:focus-visible,
a:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

::selection { background: rgba(0, 0, 0, 0.10); }

.customer-list, .editor-scroll, .search-suggestions {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.customer-list::-webkit-scrollbar,
.editor-scroll::-webkit-scrollbar,
.search-suggestions::-webkit-scrollbar { width: 10px; height: 10px; }
.customer-list::-webkit-scrollbar-thumb,
.editor-scroll::-webkit-scrollbar-thumb,
.search-suggestions::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.screen-shell {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--ink-800);
}

/* ── App shell: fixed viewport height, internal scrolling ─────────── */
.app {
  height: 100vh;
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  overflow: hidden;
}

.topbar {
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -0.02em;
  flex: none;
}

.brand-text {
  font-weight: 650;
  font-size: 13.5px;
  color: var(--ink-950);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

.topbar-stat {
  font-size: 12px;
  color: var(--ink-600);
  white-space: nowrap;
}

.topbar-stat b {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
}

/* ── Workbench grid: two full-height columns ─────────────────────── */
.workbench-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.7fr);
  gap: 10px;
  margin: 0;
}

.panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.panel-detail { overflow: hidden; }

.panel-list[data-sync-height="true"] { height: 100%; }

.panel-header {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-subtle);
}

.panel-header h2,
.detail-header h2,
.editor-header h3,
.login-card h2,
.empty-panel h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink-950);
}

.panel-header h2, .editor-header h3 { font-size: 0.95rem; }

/* search lives in the list header now */
.list-search {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.search-input-shell { position: relative; flex: 1; z-index: 40; min-width: 0; }
.search-input { width: 100%; }

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-600);
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 5px);
  left: 0; right: 0;
  z-index: 80;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}

.search-suggestion-list { display: grid; }

.search-suggestion-item {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  border-top: 1px solid var(--line-subtle);
  text-decoration: none;
  color: inherit;
}
.search-suggestion-item:first-child { border-top: 0; }
.search-suggestion-item:hover { background: var(--surface-hover); }
.search-suggestion-item.is-selected { background: var(--accent-weak); }

.search-suggestion-head { display: flex; align-items: baseline; gap: 8px; }
.search-suggestion-number {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600;
  color: var(--accent);
}
.search-suggestion-name { font-size: 13px; font-weight: 600; color: var(--ink-950); }
.search-suggestion-meta, .search-suggestion-empty { font-size: 11.5px; color: var(--ink-600); }
.search-suggestion-empty { padding: 11px; }
.search-reset { text-decoration: none; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.primary-button, .secondary-button, .capsule-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: var(--radius-xs);
  padding: 0 13px;
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button { background: var(--accent); color: var(--accent-ink); }
.primary-button:hover:not(:disabled) { background: var(--accent-strong); }

.secondary-button {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-700);
}
.secondary-button:hover:not(:disabled) {
  border-color: var(--ink-500);
  background: var(--surface-hover);
  color: var(--ink-950);
}

.capsule-button {
  min-height: 30px;
  padding: 0 11px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-600);
  font-size: 12px;
}
.capsule-button:hover { border-color: var(--line-strong); color: var(--ink-900); }

.primary-button:disabled,
.secondary-button:disabled,
.capsule-button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Inputs ──────────────────────────────────────────────────────── */
.text-input {
  width: 100%;
  min-height: 30px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-950);
  padding: 0 10px;
}
.text-input::placeholder { color: var(--ink-400); }
.text-input:hover { border-color: var(--ink-500); }
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.field-group { display: grid; gap: 5px; }
.field-group-inline { gap: 4px; }

.eyebrow, .surface-label, .search-label {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.soft-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-600);
  line-height: 1.3;
  white-space: nowrap;
}

.status-badge, .headline-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-clean { border: 1px solid var(--ok-border); background: var(--ok-weak); color: var(--ok); }
.status-dirty { border: 1px solid var(--warn-border); background: var(--warn-weak); color: var(--warn); }
.status-invalid { border: 1px solid var(--danger-border); background: var(--danger-weak); color: var(--danger); }

/* ── Flash ───────────────────────────────────────────────────────── */
.flash-banner, .flash-panel {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
}
.flash-error { color: var(--danger); border-color: var(--danger-border); background: var(--danger-weak); }
.flash-success { color: var(--ok); border-color: var(--ok-border); background: var(--ok-weak); }
.flash-dismiss { border: 0; background: transparent; color: var(--ink-500); padding: 0; }
.flash-dismiss:hover { color: var(--ink-900); }

/* ── Group list ──────────────────────────────────────────────────── */
.customer-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 5px;
  padding: 8px;
  align-content: start;
  grid-auto-rows: max-content;
}

.customer-item {
  position: relative;
  display: block;
  width: 100%;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 10px 8px 13px;
  color: inherit;
  text-decoration: none;
  overflow: hidden;
}
.customer-item:hover { border-color: var(--line-strong); background: var(--surface-hover); }
.customer-item.is-selected {
  border-color: var(--accent-border);
  background: var(--surface-selected);
}

.customer-item-bar {
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: transparent;
}
.customer-item.is-selected .customer-item-bar { background: var(--accent); }
.customer-item:hover .customer-item-bar { background: var(--line-strong); }

.customer-item-body { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.customer-item-main { display: flex; gap: 8px; align-items: center; min-width: 0; flex: 1; overflow: hidden; }

.avatar-pill {
  width: 24px; height: 24px; flex: none;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--ink-600);
  font-family: var(--font-mono);
  font-size: 0.72rem; font-weight: 700;
}
.customer-item.is-selected .avatar-pill {
  background: var(--accent-weak); border-color: var(--accent-border); color: var(--accent);
}

.customer-item h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-900);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.customer-item .eyebrow { font-size: 9.5px; }

.customer-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.customer-arrow { margin-top: 1px; color: var(--ink-400); font-size: 12px; }
.customer-item:hover .customer-arrow,
.customer-item.is-selected .customer-arrow { color: var(--accent); }

/* ── Pagination ──────────────────────────────────────────────────── */
.list-pagination {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-top: 1px solid var(--line-subtle);
  background: var(--surface-raised);
}
.pagination-pages { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.pagination-link, .pagination-page {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 26px; padding: 0 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-700);
  text-decoration: none;
  font-size: 11px; font-weight: 600;
}
.pagination-link:hover, .pagination-page:hover { border-color: var(--ink-500); color: var(--ink-950); }
.pagination-link:first-child { justify-self: start; }
.pagination-link:last-child { justify-self: end; }
.pagination-page { min-width: 26px; padding: 0 7px; font-family: var(--font-mono); }
.pagination-page.is-active { border-color: var(--accent-border); background: var(--accent-weak); color: var(--accent); }
.pagination-link.is-disabled { opacity: 0.4; pointer-events: none; }

/* ── Detail / editor ─────────────────────────────────────────────── */
.detail-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.detail-header {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line-subtle);
}
.detail-header h2 { font-size: 1.0rem; }

.detail-subtitle { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }

.detail-inline-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}
.detail-inline-label {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-500);
}
.detail-inline-value {
  font-family: var(--font-mono);
  font-size: 11.5px; font-weight: 600; color: var(--ink-900);
}

/* the editor IS the form; bar stays put, slot list scrolls */
.editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 13px;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--surface-raised);
}
.editor-bar-spacer { flex: 1; }

.editor-stat {
  font-size: 11.5px;
  color: var(--ink-600);
}
.editor-stat b {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-900);
}

.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 13px 12px;
}

.mode-inline-picker {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface-muted);
}
.mode-grid { display: grid; gap: 8px; margin-top: 6px; }
.mode-grid-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.mode-option {
  position: relative;
  display: flex; gap: 8px; align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
}
.mode-option:hover { border-color: var(--ink-500); }
.mode-option.is-active { border-color: var(--accent-border); background: var(--accent-weak); }
.mode-option strong, .mode-option span > span:first-child {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-950);
}
.mode-hover-tooltip { margin-top: 7px; min-height: 14px; font-size: 11px; color: var(--ink-600); }

.editor-header { display: none; }
.editor-actions-top, .editor-secondary-actions { display: contents; }

.is-hidden { display: none !important; }

/* ── Slot table ──────────────────────────────────────────────────── */
.slot-table-shell {
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.slot-table-head, .slot-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1.5fr) 124px 84px;
  gap: 10px;
  align-items: center;
}
.slot-table-head {
  padding: 6px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-500);
}
.slot-table-body { display: grid; }
.slot-row { padding: 3px 11px; border-top: 1px solid var(--line-subtle); background: var(--surface); }
.slot-row:first-child { border-top: 0; }
.slot-row.is-active { background: #f6f6f6; }
.slot-row .text-input { min-height: 28px; }

.slot-pill {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface-muted);
  padding: 4px 7px;
  font-family: var(--font-mono);
  font-size: 11.5px; font-weight: 600; color: var(--ink-600);
}
.slot-pill.is-active { border-color: var(--accent); background: var(--accent); color: #fff; }

.percent-input-wrap { position: relative; }
.percent-input {
  padding-right: 26px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.percent-input::-webkit-outer-spin-button,
.percent-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.percent-input[type="number"] { -moz-appearance: textfield; }
.percent-suffix {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  color: var(--ink-500); font-family: var(--font-mono); font-size: 11.5px; pointer-events: none;
}

/* active toggle → real switch (native checkbox, :checked driven) */
.toggle-card {
  display: flex; align-items: center; gap: 8px;
  min-height: 30px;
  padding: 0 2px;
  font-size: 11px; font-weight: 600;
  color: var(--ink-500);
  cursor: pointer;
}
.toggle-card.is-active { color: var(--accent); }
.toggle-card input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  width: 32px; height: 18px; margin: 0;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.toggle-card input[type="checkbox"]::after {
  content: ""; position: absolute; top: 50%; left: 2px;
  width: 12px; height: 12px; border-radius: 999px;
  background: var(--ink-400);
  transform: translateY(-50%);
  transition: transform 120ms ease, background 120ms ease;
}
.toggle-card input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.toggle-card input[type="checkbox"]:checked::after { transform: translateY(-50%) translateX(14px); background: #fff; }

.field-error { font-size: 11px; color: var(--danger); }
.field-invalid .text-input { border-color: var(--danger-border); box-shadow: 0 0 0 3px var(--danger-weak); }

.editor-footnote {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-500);
}

.mobile-only { display: none; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state-panel {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
}
.empty-panel {
  max-width: 460px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: var(--surface-muted);
  padding: 28px 26px;
  text-align: center;
}
.empty-panel h2 { font-size: 1rem; margin: 6px 0; }
.empty-panel p:last-child { color: var(--ink-600); font-size: 12.5px; margin-top: 6px; }
.empty-panel .eyebrow { color: var(--ink-500); }
.compact-empty {
  border: 1px dashed var(--line-strong);
  background: var(--surface-muted);
  padding: 26px 18px; max-width: none;
  color: var(--ink-600); font-size: 12.5px; text-align: center;
  border-radius: var(--radius-sm);
}

/* ── Login (centered card) ───────────────────────────────────────── */
.page-wrap-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.login-shell { width: 100%; display: flex; justify-content: center; }
.login-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  padding: 26px;
}
.login-card-compact { width: min(100%, 460px); padding: 28px; }
.login-card h2 { font-size: 1.25rem; margin: 4px 0 0; }
.section-divider { padding-bottom: 14px; border-bottom: 1px solid var(--line-subtle); }
.section-copy { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-600); line-height: 1.5; }
.form-grid { display: grid; gap: 12px; }
.login-form-grid { margin-top: 20px; }
.login-input { min-height: 40px; padding: 0 13px; font-size: 14px; }
.login-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 20px;
}
.microcopy { font-size: 11.5px; color: var(--ink-500); margin: 0; }

/* ── Responsive: below 1100px stack and allow normal page scroll ──── */
@media (max-width: 1100px) {
  .app { height: auto; min-height: 100vh; overflow: visible; }
  .workbench-grid { grid-template-columns: 1fr; }
  .panel { height: auto; }
  .customer-list { max-height: 420px; }
  .editor { min-height: 0; }
  .editor-scroll { overflow: visible; }
  .panel-list[data-sync-height="true"] { height: auto !important; }
}

@media (max-width: 720px) {
  .topbar-stat { display: none; }
  .detail-header h2 { font-size: 0.95rem; }
  .slot-table-head { display: none; }
  .slot-row { grid-template-columns: 1fr; gap: 8px; padding: 10px 11px; }
  .mode-grid-compact { grid-template-columns: 1fr; }
  .login-actions { flex-direction: column; align-items: stretch; }
  .mobile-only { display: inline; }
}
