/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d14;
  --bg2: #111118;
  --surface: #16161f;
  --surface2: #1e1e2c;
  --surface3: #252535;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.14);
  --text: #e4e4f0;
  --text-muted: #64648a;
  --text-dim: #9494b8;
  --accent: #c8ff57;
  --accent-glow: rgba(200,255,87,0.18);
  --accent-dim: rgba(200,255,87,0.1);
  --accent-border: rgba(200,255,87,0.25);
  --danger: #ff5f5f;
  --danger-dim: rgba(255,95,95,0.1);
  --purple: #a78bfa;
  --purple-dim: rgba(167,139,250,0.1);
  --blue: #60a5fa;
  --blue-dim: rgba(96,165,250,0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --font-d: 'Fraunces', serif;
  --font-m: 'DM Mono', monospace;
  --ease: cubic-bezier(0.4,0,0.2,1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font-m); -webkit-font-smoothing: antialiased; }

/* ── SPLASH ── */
#splash {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
#splash.fade-out { opacity: 0; transform: scale(1.05); pointer-events: none; }
.splash-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.splash-logo svg { width: 72px; height: 72px; filter: drop-shadow(0 0 20px rgba(200,255,87,0.3)); animation: logoFloat 2s ease-in-out infinite; }
@keyframes logoFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
#splash h1 { font-family: var(--font-d); font-size: 40px; font-weight: 500; line-height: 1.1; }
#splash h1 em { font-style: italic; color: var(--accent); font-weight: 300; }
.splash-sub { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-muted); }
.splash-dots { display: flex; gap: 6px; margin-top: 8px; }
.splash-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--surface3); animation: dotPulse 1.2s ease-in-out infinite; }
.splash-dots span:nth-child(2) { animation-delay: 0.2s; }
.splash-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%,100%{background:var(--surface3)} 50%{background:var(--accent)} }

/* ── APP ── */
#app { position: fixed; inset: 0; overflow: hidden; }
#app.hidden { display: none; }

/* ── VIEWS ── */
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  will-change: transform;
}
.view.active { transform: translateX(0); }
.view.slide-left { transform: translateX(-28%); }

/* ── LIST HERO ── */
.list-hero {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding-top: calc(16px + var(--safe-t));
}
.hero-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px 16px;
}
.hero-brand { display: flex; align-items: center; gap: 14px; }
.hero-icon {
  width: 46px; height: 46px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.hero-icon svg { width: 22px; height: 22px; }
.hero-title { font-family: var(--font-d); font-size: 26px; font-weight: 700; line-height: 1; }
.hero-subtitle { font-size: 11px; color: var(--text-muted); letter-spacing: 0.08em; margin-top: 3px; }
.hero-count-wrap { text-align: right; }
.hero-count {
  display: block;
  font-family: var(--font-d); font-size: 42px; font-weight: 700;
  line-height: 1; color: var(--accent);
}
.hero-count-label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; }

/* ── STATS BAR ── */
.stats-bar {
  display: flex; gap: 8px; padding: 0 20px 16px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.stats-bar::-webkit-scrollbar { display: none; }
.stat-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 12px;
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap; flex-shrink: 0;
}
.stat-pill svg { width: 13px; height: 13px; }
.stat-pill span { color: var(--text); font-weight: 500; }

/* ── SEARCH ── */
.search-wrap {
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  transition: border-color 0.2s;
}
.search-box:focus-within { border-color: var(--border2); }
.search-icon { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-muted); }
#search-input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: var(--font-m); font-size: 14px; padding: 13px 0; }
#search-input::placeholder { color: var(--text-muted); }
.search-clear { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 4px; }

/* ── PROPOSAL LIST ── */
.proposal-list {
  flex: 1; overflow-y: auto; padding: 14px 16px calc(88px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.proposal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  position: relative; overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
  animation: cardIn 0.28s var(--ease) both;
}
@keyframes cardIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.proposal-card:active { transform: scale(0.985); border-color: var(--border2); }

/* Accent left stripe */
.proposal-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent) 0%, transparent 100%);
  opacity: 0; transition: opacity 0.2s;
}
.proposal-card:active::before { opacity: 1; }

.card-row1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-name { font-family: var(--font-d); font-size: 17px; font-weight: 600; line-height: 1.3; flex: 1; }
.card-date-chip {
  font-size: 10px; color: var(--text-muted);
  background: var(--surface2);
  border-radius: 6px; padding: 3px 8px;
  white-space: nowrap; flex-shrink: 0;
  border: 1px solid var(--border);
}
.card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.badge {
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: 4px; padding: 2px 7px; font-weight: 500;
}
.badge-image { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(96,165,250,0.2); }
.badge-text  { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }
.badge-table { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); }
.card-preview { font-size: 12px; color: var(--text-muted); line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── EMPTY STATE ── */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 40px; text-align: center;
}
.empty-art svg { width: 100px; height: 100px; }
.empty-state h3 { font-family: var(--font-d); font-size: 22px; font-weight: 600; }
.empty-state p { color: var(--text-muted); font-size: 14px; line-height: 1.8; }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(28px + var(--safe-b)); right: 22px;
  width: 60px; height: 60px;
  background: var(--accent); color: #0d0d14;
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 28px rgba(200,255,87,0.4), 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 20;
}
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(0.9); box-shadow: 0 2px 12px rgba(200,255,87,0.2); }

/* ── TOP BAR ── */
.top-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + var(--safe-t)) 14px 12px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bar-title { font-family: var(--font-d); font-size: 20px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 10px; transition: background 0.15s; flex-shrink: 0; }
.icon-btn:active { background: var(--surface2); }
.save-btn { background: var(--accent); color: #0d0d14; border: none; border-radius: var(--radius-sm); font-family: var(--font-m); font-size: 13px; font-weight: 500; padding: 9px 18px; cursor: pointer; flex-shrink: 0; transition: opacity 0.15s, transform 0.15s; }
.save-btn:active { transform: scale(0.95); }
.save-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── FORM ── */
.form-scroll { flex: 1; overflow-y: auto; padding-bottom: calc(32px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.form-section { padding: 20px 16px 0; }
.field-label { display: block; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.field-label.mt { margin-top: 18px; }
.field-input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: var(--font-m); font-size: 15px; padding: 13px 14px; outline: none; transition: border-color 0.2s; }
.field-input:focus { border-color: var(--border2); }
.field-input::placeholder { color: var(--text-muted); }

/* ── DATE ── */
.date-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.toggle-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle-input { display: none; }
.toggle-track { width: 46px; height: 25px; background: var(--surface2); border: 1px solid var(--border); border-radius: 13px; position: relative; transition: background 0.2s, border-color 0.2s; }
.toggle-input:checked + .toggle-track { background: var(--accent-dim); border-color: var(--accent); }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: var(--text-muted); transition: transform 0.2s, background 0.2s; }
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(21px); background: var(--accent); }
.toggle-label { font-size: 13px; color: var(--text-dim); }
.date-input { flex: 1; min-width: 160px; color-scheme: dark; }
.date-input.hidden { display: none; }

/* ── IMAGE ── */
.image-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.img-btn { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); font-family: var(--font-m); font-size: 13px; padding: 10px 16px; cursor: pointer; transition: border-color 0.2s; }
.img-btn:active { border-color: var(--border2); }
.img-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.img-btn.danger { color: var(--danger); border-color: rgba(255,95,95,0.2); }
.img-btn.danger:active { background: var(--danger-dim); }
.image-preview-wrap { margin-top: 14px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); max-height: 220px; }
.image-preview { width: 100%; object-fit: cover; display: block; }
.ocr-status { display: flex; align-items: center; gap: 12px; padding: 14px; background: rgba(200,255,87,0.05); border: 1px solid rgba(200,255,87,0.12); border-radius: var(--radius-sm); margin-top: 14px; color: var(--accent); font-size: 13px; }
.ocr-spinner { width: 16px; height: 16px; border: 2px solid rgba(200,255,87,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to{transform:rotate(360deg)} }
.ocr-error { margin-top: 14px; padding: 12px 14px; background: var(--danger-dim); border: 1px solid rgba(255,95,95,0.2); border-radius: var(--radius-sm); color: var(--danger); font-size: 13px; }
.field-ocr { width: 100%; min-height: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: var(--font-m); font-size: 14px; line-height: 1.7; padding: 14px; outline: none; resize: vertical; transition: border-color 0.2s; }
.field-ocr:focus { border-color: var(--border2); }
.field-ocr::placeholder { color: var(--text-muted); }
.table-link-btn { width: 100%; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: var(--font-m); font-size: 14px; padding: 16px; cursor: pointer; text-align: left; transition: border-color 0.2s; margin-top: 4px; }
.table-link-btn:active { border-color: var(--border2); }
.table-link-btn svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.chevron { margin-left: auto; color: var(--text-muted); font-size: 18px; }

/* ── TABLE ── */
.table-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; min-width: 580px; }
.data-table thead { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.data-table th { padding: 11px 10px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); text-align: left; font-weight: 500; font-family: var(--font-m); }
.col-num { width: 42px; text-align: center; }
.col-div { width: 22%; }
.col-com, .col-add { width: 39%; }
.data-table td { padding: 5px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.012); }
.table-num { text-align: center; font-size: 10px; color: var(--text-muted); padding-top: 13px; }
.table-cell { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); font-family: var(--font-m); font-size: 13px; padding: 8px; outline: none; resize: none; line-height: 1.5; min-height: 38px; transition: border-color 0.15s, background 0.15s; }
.table-cell:focus { border-color: var(--border2); background: var(--surface2); }
.table-cell::placeholder { color: var(--text-muted); }

/* ── DETAIL ── */
.detail-scroll { flex: 1; overflow-y: auto; padding: 20px 16px calc(40px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 14px; }
.detail-date-badge { display: inline-block; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); border-radius: 5px; padding: 3px 10px; margin-bottom: 12px; }
.detail-name { font-family: var(--font-d); font-size: 26px; font-weight: 700; line-height: 1.2; margin-bottom: 4px; }
.detail-divider { height: 1px; background: var(--border); margin: 18px 0; }
.detail-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.detail-ocr { font-size: 14px; line-height: 1.8; color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow-y: auto; }
.detail-ocr:empty::before { content: 'No text extracted.'; color: var(--text-muted); font-style: italic; }
.delete-btn { width: 100%; background: var(--danger-dim); border: 1px solid rgba(255,95,95,0.2); border-radius: var(--radius-sm); color: var(--danger); font-family: var(--font-m); font-size: 13px; padding: 14px; cursor: pointer; transition: background 0.15s; }
.delete-btn:active { background: rgba(255,95,95,0.18); }

/* ── TOAST ── */
.toast { position: fixed; bottom: calc(100px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(16px); background: var(--surface3); border: 1px solid var(--border2); color: var(--text); border-radius: 10px; padding: 11px 20px; font-size: 13px; white-space: nowrap; opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 1000; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── UTILS ── */
.hidden { display: none !important; }
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::selection { background: var(--accent-dim); color: var(--accent); }
