:root {
  /* frost CI palette */
  --frost-orange:   #f05a28;   /* brand orange – slightly warmer than before */
  --frost-dark:     #1a1a1a;   /* near-black used on website */
  --frost-white:    #ffffff;
  --frost-ice:      #f4f6f8;   /* very light blue-grey — "frost" / icy feel */
  --frost-stone:    #e8e6e0;   /* warm divider tone */
  --frost-muted:    #6b7280;

  --color-bg:           var(--frost-ice);
  --color-surface:      var(--frost-white);
  --color-ink:          var(--frost-dark);
  --color-muted:        var(--frost-muted);
  --color-line:         var(--frost-stone);
  --color-accent:       var(--frost-orange);
  --color-accent-ink:   var(--frost-white);
  --color-accent-soft:  #fef0ea;
  --color-success:      #1f8a53;
  --color-success-soft: #e9f6ee;
  --color-danger:       #c7402f;
  --color-danger-soft:  #fbeae7;

  --font-display: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
  --font-mono:    ui-monospace, "SF Mono", Menlo, monospace;

  --radius-l: 16px;
  --radius-m: 12px;
  --radius-s: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button   { font-family: inherit; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; }

button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ──────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--frost-dark);
  padding-top: var(--safe-top);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* frost wordmark SVG lives here */
.frost-logo {
  height: 28px;
  width: auto;
  display: block;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-btn {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lang-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.ticket-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  gap: 0;
  padding: 6px 12px 0;
}
.nav-tab {
  flex: 1;
  background: none;
  color: rgba(255,255,255,0.55);
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  padding: 8px 4px 7px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* ─── CUSTOMER CARD ───────────────────────────────────────────────────────── */
.customer-card {
  background: var(--frost-white);
  border-bottom: 2px solid var(--color-accent);
  padding: 10px 16px;
}
.customer-card-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 4px;
}
.customer-card input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-ink);
  padding: 0;
  caret-color: var(--color-accent);
}
.customer-card input::placeholder {
  color: #c0c4cc;
  font-weight: 400;
}
.customer-card input:focus { outline: none; }

/* ─── VIEWS ───────────────────────────────────────────────────────────────── */
.view { display: none; flex: 1; flex-direction: column; }
.view.active { display: flex; }

.section        { padding: 14px 16px; }
.section + .section { padding-top: 0; }

.muted { color: var(--color-muted); }
.hint  { font-size: 12.5px; color: var(--color-muted); line-height: 1.45; }

.banner {
  margin: 10px 16px 0;
  background: var(--color-accent-soft);
  border: 1px solid #fbd5c0;
  border-radius: var(--radius-m);
  padding: 10px 12px;
  font-size: 12.5px;
  color: #8a3509;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.banner button.dismiss {
  background: none;
  color: #8a3509;
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  flex-shrink: 0;
  padding: 0;
}

/* ─── SEARCH ──────────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-input {
  width: 100%;
  font-size: 17px;
  padding: 13px 14px;
  border-radius: var(--radius-m);
  border: 1.5px solid var(--color-line);
  background: var(--color-surface);
}
.search-input:focus { border-color: var(--color-accent); }

.catalog-status {
  margin-top: 7px;
  font-size: 12px;
  color: var(--color-muted);
  display: flex;
  justify-content: space-between;
}
.catalog-status a { color: var(--color-accent); font-weight: 600; text-decoration: none; }

.results { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

.result-row {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  padding: 11px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
}
.result-row:active { background: #f9f9f9; }
.result-main   { min-width: 0; }
.result-name   { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-nr     { font-family: var(--font-mono); font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.result-add    {
  background: var(--color-ink);
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.empty-state       { text-align: center; padding: 36px 12px; color: var(--color-muted); }
.empty-state .glyph  { font-size: 30px; margin-bottom: 8px; }
.empty-state .title  { font-weight: 700; color: var(--color-ink); margin-bottom: 4px; }

.manual-toggle {
  margin-top: 12px;
  background: none;
  color: var(--color-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 0;
  text-decoration: underline;
}
.manual-panel {
  display: none;
  margin-top: 10px;
  background: var(--color-surface);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-m);
  padding: 12px;
}
.manual-panel.open { display: block; }
.manual-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }

.field-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--color-muted);
  margin-bottom: 4px; display: block;
}
.field-input {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-s);
  border: 1.5px solid var(--color-line);
  font-size: 16px;
  font-family: var(--font-mono);
  background: var(--color-surface);
}
select.field-input {
  font-family: var(--font-body);
  font-size: 13.5px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%236b7280'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 26px;
}
.manual-add-btn {
  margin-top: 10px;
  width: 100%;
  background: var(--color-ink);
  color: #fff;
  padding: 11px;
  border-radius: var(--radius-s);
  font-weight: 700;
  font-size: 14px;
}

/* ─── PERFORATION DIVIDER ──────────────────────────────────────────────────── */
.perforation {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 16px 0;
  color: var(--color-muted);
}
.perforation .line   { flex: 1; height: 0; border-top: 2px dashed var(--color-line); }
.perforation .label  { font-size: 10.5px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; white-space: nowrap; }
.perforation .notch  { width: 7px; height: 7px; border-radius: 50%; background: var(--color-bg); border: 2px solid var(--color-line); }

/* ─── ORDER LIST ───────────────────────────────────────────────────────────── */
.order-list { display: flex; flex-direction: column; gap: 8px; }

.order-row {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  padding: 10px 10px 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.order-idx  { font-family: var(--font-mono); font-size: 12px; color: var(--color-muted); width: 24px; flex-shrink: 0; padding-top: 2px; }
.order-main { flex: 1; min-width: 0; }
.order-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-nr   { font-family: var(--font-mono); font-size: 11.5px; color: var(--color-muted); }
.order-comment {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 3px 0 4px;
  border: none;
  border-bottom: 1px dashed var(--color-line);
  background: transparent;
  font-size: 12.5px;
  font-style: italic;
  color: var(--color-ink);
}
.order-comment::placeholder { color: #c0c4cc; font-style: italic; }
.order-comment:focus { outline: none; border-bottom: 1px dashed var(--color-accent); font-style: normal; }

.qty-stepper {
  display: flex; align-items: center; gap: 6px;
  background: var(--color-bg);
  border-radius: var(--radius-s);
  padding: 4px;
  flex-shrink: 0;
}
.qty-btn {
  width: 28px; height: 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 7px;
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.qty-value {
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
  min-width: 26px; text-align: center;
}
.remove-btn {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  width: 30px; height: 30px;
  border-radius: 8px;
  font-size: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}

.order-summary {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-muted);
  padding: 4px 4px 0;
}
.order-summary strong { color: var(--color-ink); }

/* ─── BOTTOM BAR ───────────────────────────────────────────────────────────── */
.bottom-bar {
  position: sticky; bottom: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-line);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  display: flex; gap: 8px;
  z-index: 20;
}
.btn {
  flex: 1; padding: 13px 10px;
  border-radius: var(--radius-m);
  font-weight: 700; font-size: 14.5px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary   { background: var(--color-accent); color: var(--color-accent-ink); }
.btn-primary:disabled { background: #f5c4ad; color: #fff; }
.btn-secondary { background: var(--color-bg); color: var(--color-ink); border: 1px solid var(--color-line); }
.btn-ghost     { background: none; color: var(--color-muted); flex: 0; padding: 13px 14px; }

/* ─── SETTINGS ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; }

textarea {
  width: 100%;
  min-height: 110px;
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-s);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  margin-top: 8px;
  resize: vertical;
  background: var(--color-surface);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 18px; height: 18px;
}
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; font-size: 13.5px;
}

.file-btn {
  display: inline-block;
  background: var(--color-ink); color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius-s);
  font-size: 13px; font-weight: 700;
  margin-top: 8px; cursor: pointer;
}
.file-btn input { display: none; }
.danger-link {
  background: none; color: var(--color-danger);
  font-size: 12.5px; font-weight: 600; text-decoration: underline;
  padding: 0; margin-top: 10px;
}

/* ─── HISTORY ────────────────────────────────────────────────────────────── */
.history-row {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  padding: 11px 12px;
  margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.history-main       { min-width: 0; }
.history-customer   { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta       { font-size: 11.5px; color: var(--color-muted); margin-top: 2px; }
.history-redownload {
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-s);
  padding: 7px 10px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%; bottom: calc(78px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: var(--frost-dark); color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .toast, .nav-tab { transition: none; }
}
