/* ===== Cypher Vault — mobile-first styling =====
   Brand: black canvas, sparse Cypher red (#E40B0B) accent. */
:root {
  --bg: #000000;
  --surface: #111113;
  --surface-2: #1b1b1f;
  --line: #2a2a2f;
  --text: #f4f4f5;
  --muted: #9a9aa2;
  --red: #e40b0b;
  --red-hot: #ff2a2a;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-body: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.view { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Buttons ---------- */
.btn {
  display: block; width: 100%; padding: 16px; border: 0; border-radius: var(--radius);
  font-family: var(--font-body); font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:active { background: var(--red-hot); }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; padding: 8px; }

/* ---------- Login ---------- */
.login-wrap {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-b)); max-width: 460px; margin: 0 auto; width: 100%;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-bottom: 8px; }
.login-lockup { width: 100%; max-width: 320px; height: auto; display: block; }
.product-label {
  display: flex; align-items: center; gap: 14px; width: 100%; max-width: 320px;
  font-family: var(--font-mono); font-size: 15px; font-weight: 500;
  letter-spacing: .42em; text-transform: uppercase; color: var(--text);
  padding-left: .42em; /* optical balance for tracking */
}
.product-label .pl-rule { flex: 1; height: 1px; background: var(--red); opacity: .85; }
.tagline { color: var(--muted); margin: 20px 0 28px; font-size: 15px; text-align: center; }
.footnote {
  text-align: center; color: var(--muted); font-size: 11px; margin-top: 28px;
  font-family: var(--font-mono); letter-spacing: .22em; text-transform: uppercase;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.card label, .field label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px;
}
input, select {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-family: var(--font-body); font-size: 16px; /* 16px stops iOS zoom */
}
input:focus, select:focus { outline: none; border-color: var(--red); }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); z-index: 5;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-icon { height: 24px; width: auto; display: block; }
.topbar-word {
  font-family: var(--font-mono); font-weight: 500; font-size: 15px;
  letter-spacing: .26em; text-transform: uppercase; padding-left: .26em;
}
.topbar-title { font-weight: 600; }

/* ---------- Home ---------- */
.home-main { flex: 1; padding: 18px 18px 120px; }
.screen-title { font-size: 26px; font-weight: 800; letter-spacing: -.01em; margin: 8px 0 18px; }
.doc-list { display: flex; flex-direction: column; gap: 12px; }
.doc-card {
  display: flex; gap: 14px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.doc-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; }
.doc-meta { flex: 1; min-width: 0; }
.doc-supplier { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.doc-amount { font-weight: 700; color: var(--red); white-space: nowrap; }
.badge {
  display: inline-block; font-family: var(--font-mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); margin-left: 8px; vertical-align: middle;
}
.badge-invoice { background: var(--red); color: #fff; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text); }
.empty-icon { width: 46px; height: 46px; margin: 0 auto 12px; display: block; color: var(--muted); }
.photo-prompt .empty-icon { color: var(--red); opacity: .9; }
.empty-state p { margin: 4px 0; }

/* ---------- Floating Add button ---------- */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + var(--safe-b)); display: flex; align-items: center; gap: 8px;
  background: var(--red); color: #fff; border: 0; border-radius: 999px;
  padding: 14px 24px; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 24px rgba(228,11,11,0.4); z-index: 10;
}
.fab:active { background: var(--red-hot); }
.fab-plus { font-size: 20px; line-height: 1; }

/* ---------- Capture ---------- */
.capture-main { flex: 1; padding: 18px 18px calc(28px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }
.photo-dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); min-height: 220px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--surface); cursor: pointer; text-align: center;
}
.photo-preview { width: 100%; max-height: 360px; object-fit: contain; display: block; }
.field-row { display: flex; gap: 12px; }
.field { flex: 1; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 999px; font-size: 14px; z-index: 30;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

/* ---------- Search / filter toolbar ---------- */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-ic {
  position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
#search {
  padding-left: 42px; padding-right: 42px; border-radius: 999px;
}
.search-clear {
  position: absolute; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.search-clear:active { color: var(--text); }

.chips { display: flex; gap: 8px; }
.chip {
  flex: 1; padding: 9px 12px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
}
.chip.is-active { background: var(--red); border-color: var(--red); color: #fff; }

.selects { display: flex; gap: 8px; }
.mini-select {
  flex: 1; padding: 11px 12px; font-size: 13px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}

/* ---------- Month grouping ---------- */
.month-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 2px 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.month-header > span:first-child {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.month-total { font-weight: 700; font-size: 14px; color: var(--text); }
.month-header:first-child { margin-top: 0; }

.doc-thumb-file {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--red);
  border: 1px solid var(--line);
}

/* ---------- Capture: source buttons + ghost button ---------- */
.capture-actions { display: flex; gap: 12px; }
.btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
}
.btn-ghost:active { border-color: var(--red); color: var(--red); }
.btn-ghost svg { width: 18px; height: 18px; }
.capture-actions .btn-ghost { flex: 1; }
.form-hint { font-size: 13px; color: var(--muted); margin: 4px 0 2px; }

/* ---------- Image lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; padding: 20px;
  background: rgba(0,0,0,0.93); display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 10px; }
