:root {
  color-scheme: dark;
  --bg: #0f1113;
  --panel: #171a1d;
  --panel-2: #1d2125;
  --line: #2a3036;
  --text: #f5f7fa;
  --muted: #a3abb4;
  --accent: #f97316;
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0,0,0,.24);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif; }
body { min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
.hidden { display: none !important; }
.app-shell { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.hero { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(24px, 4vw, 54px); line-height: 1.02; }
.hero-title { white-space: nowrap; }
.lead { margin: 14px 0 0; max-width: 720px; color: var(--muted); font-size: 16px; line-height: 1.7; }
.card { background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01)); border: 1px solid var(--line); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); }
.capture-card { margin-bottom: 18px; }
.grid-two { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; margin-bottom: 18px; }
.card-head { margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 22px; }
.card-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.upload-zone { position: relative; display: flex; align-items: center; justify-content: center; min-height: 340px; border: 1px dashed #3d454d; border-radius: 22px; background: var(--panel); overflow: hidden; }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-prompt { display: grid; place-items: center; gap: 8px; color: var(--muted); text-align: center; padding: 24px; }
.camera-icon { font-size: 48px; color: var(--accent); line-height: 1; }
.preview { width: 100%; height: 100%; object-fit: contain; background: #090a0b; }
.controls { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.primary, .ghost { min-height: 46px; padding: 0 18px; border-radius: 14px; transition: .18s ease; }
.primary { background: var(--accent); color: white; font-weight: 700; }
.primary:disabled { opacity: .45; cursor: default; }
.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.ghost.danger { color: #ffd3d3; border-color: #654040; }
.status { margin-top: 14px; color: var(--muted); min-height: 22px; }
.result-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-form label { display: grid; gap: 8px; }
.result-form label.full { grid-column: 1 / -1; }
.result-form span { color: var(--muted); font-size: 13px; }
.result-form input, .result-form textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); padding: 13px 14px; outline: none; }
.result-form textarea { resize: vertical; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-box { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.summary-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.summary-box strong { font-size: 26px; }
.category-list-wrap { margin-top: 16px; }
.category-list-wrap h3 { margin: 0 0 10px; font-size: 16px; }
.category-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.category-list li, .history-item { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.category-list li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.history-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.history-list { display: grid; gap: 12px; }
.history-item { padding: 14px; display: grid; gap: 10px; }
.history-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.history-merchant { margin: 0; font-size: 18px; }
.history-meta { color: var(--muted); font-size: 13px; }
.history-total { font-size: 20px; font-weight: 700; white-space: nowrap; }
.history-items { color: var(--muted); white-space: pre-wrap; line-height: 1.6; }
.thumb { width: 86px; height: 86px; border-radius: 14px; object-fit: cover; border: 1px solid var(--line); }
.history-body { display: flex; gap: 12px; }
.history-delete { align-self: flex-start; }
@media (max-width: 860px) {
  .grid-two { grid-template-columns: 1fr; }
  .result-form { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .app-shell { padding: 18px 12px 44px; }
  .hero { flex-direction: column; }
  .hero h1 { font-size: 24px; }
  .upload-zone { min-height: 270px; }
  .history-body { flex-direction: column; }
  .thumb { width: 100%; height: auto; max-height: 240px; }
}


.export-notice {
  margin: 10px 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(17,17,17,0.14);
  border-radius: 14px;
  background: #f6f6f6;
  font-size: 14px;
  line-height: 1.5;
}

.history-group {
  display: grid;
  gap: 12px;
}

.history-group + .history-group {
  margin-top: 18px;
}

.history-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(17,17,17,0.08);
}

.history-group-head h3 {
  margin: 0;
  font-size: 16px;
}

.history-group-head span {
  font-size: 13px;
  color: rgba(17,17,17,0.6);
}

.history-group-list {
  display: grid;
  gap: 12px;
}

.history-merchant {
  margin: 0;
}

.category-list li small {
  color: var(--muted);
  font-size: 12px;
}
.history-top-right {
  display: grid;
  justify-items: end;
  gap: 8px;
}
.history-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.history-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.22);
  color: #ffd9c2;
  font-size: 12px;
}
.export-notice {
  margin: 10px 0 14px;
  padding: 14px 16px;
  border: 1px solid rgba(249, 115, 22, 0.28);
  border-radius: 16px;
  background: rgba(249, 115, 22, 0.12);
  color: #ffe7d6;
  font-size: 14px;
  line-height: 1.6;
  font-weight: 700;
}
.history-group-head {
  border-bottom: 1px solid var(--line);
}
.history-group-head span {
  font-size: 13px;
  color: var(--muted);
}

.dict-card { margin-top: 18px; }
.dict-list { display: grid; gap: 10px; }
.dict-row { display:flex; justify-content:space-between; gap:12px; align-items:center; background: var(--panel); border:1px solid var(--line); border-radius:16px; padding:12px 14px; }
.mini { min-height: 34px; padding: 0 12px; border-radius: 12px; font-size: 12px; }
.history-items-wrap { flex: 1; display: grid; gap: 10px; }
.history-items-title { color: var(--muted); font-size: 13px; }
.history-item-list { display: grid; gap: 10px; }
.item-row { display: grid; grid-template-columns: minmax(0,1fr) 180px auto; gap: 10px; align-items: center; }
.item-row-name { min-width: 0; overflow-wrap:anywhere; }
.item-category-select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); padding: 10px 12px; }
.item-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) { .item-row { grid-template-columns: 1fr; } }

.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 520px; background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01)); border: 1px solid var(--line); border-radius: 24px; padding: 24px; box-shadow: var(--shadow); }
.auth-title { margin: 0 0 12px; font-size: clamp(24px, 4vw, 36px); line-height: 1.12; }
.auth-label { display: grid; gap: 8px; margin-top: 12px; }
.auth-label span { color: var(--muted); font-size: 13px; }
.auth-label input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); padding: 13px 14px; outline: none; }


.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form .controls {
  margin-top: 0;
}

.auth-form .primary {
  width: 100%;
  min-height: 52px;
  touch-action: manipulation;
  -webkit-appearance: none;
}
