:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  --bg: #f7f9fc; --surface: #fff; --panel: #fff; --text: #142033; --muted: #718096;
  --edge: #e5eaf0; --accent: #2269d2; --accent-soft: #edf5ff; --accent-edge: #99c1f8;
  --shadow: 0 5px 19px rgba(26,44,74,.035); --warn: #b87917; --warn-soft: #fff7e8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {color-scheme:dark;--bg:#101827;--surface:#182335;--panel:#1c293c;--text:#f5f8fe;--muted:#98a9bf;--edge:#304056;--accent:#80b4ff;--accent-soft:#202f49;--accent-edge:#3e76b9;--shadow:none;--warn:#ffc375;--warn-soft:#32291d}
}
:root[data-theme="dark"] {color-scheme:dark;--bg:#101827;--surface:#182335;--panel:#1c293c;--text:#f5f8fe;--muted:#98a9bf;--edge:#304056;--accent:#80b4ff;--accent-soft:#202f49;--accent-edge:#3e76b9;--shadow:none;--warn:#ffc375;--warn-soft:#32291d}
* { box-sizing:border-box; }
html {min-height:100%;-webkit-text-size-adjust:100%;}
body {margin:0; background:var(--bg); color:var(--text); min-height:100vh; }
button,input,select {font:inherit}
button {cursor:pointer}
button:disabled {cursor:not-allowed;opacity:.45}
button:focus-visible,input:focus-visible,select:focus-visible {outline:3px solid var(--accent-edge);outline-offset:2px}
.svg-icon {display:inline-block;flex-shrink:0}
[hidden] {display:none!important}
.shell {max-width:594px; margin:0 auto; padding:16px 18px max(22px, env(safe-area-inset-bottom));}
.icon-button {border:1px solid var(--edge);background:var(--surface);color:var(--muted);height:38px;width:38px;border-radius:12px;display:grid;place-items:center;flex-shrink:0}
.icon-button:active,.secondary-button:active {transform:scale(.98)}
.utility-bar {display:flex;align-items:center;justify-content:space-between;gap:10px;background:var(--surface);border:1px solid var(--edge);box-shadow:var(--shadow);border-radius:12px;padding:6px 8px 6px 12px;margin-top:14px;min-height:48px}
.utility-status {display:flex;align-items:center;gap:10px;min-width:0;flex:1}
.status-dot {width:8px;height:8px;border-radius:99px;flex-shrink:0;background:#28a878;box-shadow:0 0 0 4px #28a8781f}
.status-dot.working {background:var(--accent);box-shadow:0 0 0 4px var(--accent-soft)}
.status-dot.warning {background:#dd9b33;box-shadow:0 0 0 4px var(--warn-soft)}
.status-text {display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}
.status-text strong {font-size:12px;font-weight:690;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.status-text span {font-size:10.5px;color:var(--muted);line-height:1.25}
.utility-actions {display:flex;align-items:center;gap:6px;flex-shrink:0}
.refresh-button {height:38px;width:38px}
.refresh-button.spinning svg {animation:spin 1.4s linear infinite}
@keyframes spin {to{transform:rotate(360deg)}}
.section-heading {display:flex;justify-content:space-between;align-items:baseline;margin:0 2px 9px}
.section-heading-main {margin-top:0}
.section-heading h2 {font-size:16px;font-weight:750;letter-spacing:-.3px;margin:0}
.section-heading span {font-size:12px;color:var(--muted)}
.currency-cards {display:flex;flex-direction:column;gap:9px}
.currency-card {background:var(--surface);border:1.5px solid var(--edge);border-radius:15px;box-shadow:var(--shadow);padding:12px 13px 10px;transition:border-color 150ms,background 150ms;cursor:text}
.currency-card.active {background:var(--accent-soft);border-color:var(--accent-edge)}
.card-main {display:flex;align-items:center;gap:8px;min-width:0}
.identity {display:flex;align-items:center;gap:9px;min-width:0;flex:0 1 43%}
.flag {display:flex;align-items:center;justify-content:center;font-size:25px;line-height:1;width:35px;height:35px;border-radius:10px;background:var(--bg);flex-shrink:0}
.identity-text {display:flex;flex-direction:column;gap:1px;min-width:0}
.identity-text strong {font-size:15px;font-weight:750;letter-spacing:.1px}
.identity-text span {font-size:11px;color:var(--muted);line-height:1.15;overflow:hidden;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.amount-line {display:flex;align-items:center;gap:2px;margin:0;min-height:42px;min-width:0;flex:1}
.amount-input {display:block;flex:1;width:100%;min-width:0;padding:5px 0;text-align:right;font-size:clamp(23px,6.5vw,31px);font-weight:730;letter-spacing:-.75px;font-variant-numeric:tabular-nums;line-height:1.14;color:var(--text);background:transparent;border:none;border-radius:0;outline:0;text-overflow:clip;box-shadow:none}
.amount-input:focus {outline:none}
.amount-input::selection {background:#74b4fd88;color:var(--text)}
.copy-button {background:transparent;border:0;color:var(--muted);height:38px;width:30px;display:grid;place-items:center;flex-shrink:0;border-radius:8px;cursor:pointer}
.copy-button:hover {color:var(--accent);background:var(--accent-soft)}
.card-bottom {display:flex;align-items:center;min-height:23px;padding-top:6px;margin-top:6px;border-top:1px solid var(--edge)}
.currency-card.active .card-bottom {border-color:var(--accent-edge)}
.rate-line {font-size:11.5px;color:var(--muted);line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.add-currency {width:100%;display:flex;align-items:center;justify-content:center;gap:6px;min-height:41px;border:1.5px dashed var(--edge);background:transparent;color:var(--accent);font-size:13px;font-weight:690;border-radius:12px;margin-top:11px}
.add-currency:not(:disabled):hover {background:var(--accent-soft);border-color:var(--accent-edge)}
.footer {text-align:center;color:var(--muted);font-size:10px;line-height:1.55;padding-top:16px}
.footer span {opacity:.75}
.toast {position:fixed;left:50%;bottom:calc(24px + env(safe-area-inset-bottom));transform:translate(-50%,14px);background:#20334c;color:white;border-radius:12px;padding:13px 18px;font-size:13px;font-weight:600;box-shadow:0 8px 30px #0002;z-index:99;pointer-events:none;opacity:0;transition:opacity 160ms,transform 160ms;max-width:calc(100vw - 30px);text-align:center}
.toast.show {opacity:1;transform:translate(-50%,0)}
.visually-hidden {position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;clip-path:inset(50%)}
.sheet {padding:0;position:fixed;inset:auto 0 0 0;width:min(100%,600px);max-width:none;margin:0 auto;border:1px solid var(--edge);border-radius:24px 24px 0 0;background:var(--surface);color:var(--text);box-shadow:0 -12px 54px #0003;max-height:min(87vh,880px);overflow:hidden}
.sheet::backdrop {background:rgba(14,25,42,.56);backdrop-filter:blur(2px)}
.sheet[open] {display:flex;flex-direction:column}
.sheet-head {padding:20px 22px 17px;display:flex;align-items:start;justify-content:space-between;gap:12px;border-bottom:1px solid var(--edge)}
.sheet-head h2 {margin:0 0 5px;font-size:21px;letter-spacing:-.35px}
.sheet-head p {color:var(--muted);font-size:12px;margin:0}
.sheet-body {padding:20px 22px calc(30px + env(safe-area-inset-bottom));overflow-y:auto;overscroll-behavior:contain}
.sheet-body h3 {margin:0 0 12px;font-size:13px;letter-spacing:.1px}
.sheet-body .space-top {margin-top:27px}
.sheet-body h3 span {font-weight:500;color:var(--muted)}
.manage-list {display:flex;flex-direction:column;gap:7px}
.manage-row {min-height:60px;display:flex;gap:9px;align-items:center;padding:8px 9px;background:var(--bg);border:1px solid var(--edge);border-radius:12px}
.manage-row.dragging {opacity:.6;background:var(--accent-soft);border-color:var(--accent-edge)}
.drag-handle {display:grid;place-items:center;background:transparent;border:0;color:var(--muted);height:38px;width:26px;touch-action:none;cursor:grab;flex-shrink:0}
.drag-handle:active {cursor:grabbing}
.manage-flag {font-size:25px;width:33px;flex-shrink:0;text-align:center}
.manage-name {display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}
.manage-name strong {font-size:13px}
.manage-name small {font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mini-button {display:grid;place-items:center;color:var(--muted);height:34px;width:29px;flex-shrink:0;border:0;border-radius:8px;background:transparent}
.mini-button:not(:disabled):hover {background:var(--accent-soft);color:var(--accent)}
.mini-button.danger:not(:disabled):hover {background:#fce8e8;color:#d33a4d}
.search {display:flex;align-items:center;gap:8px;border:1px solid var(--edge);background:var(--bg);border-radius:12px;padding:0 13px;min-height:48px;color:var(--muted)}
.search:focus-within {border-color:var(--accent-edge)}
.search input {flex:1;min-width:0;border:0;outline:0;background:transparent;color:var(--text);height:44px;font-size:14px}
.search-results {display:flex;flex-direction:column;gap:3px;max-height:300px;overflow:auto;margin-top:10px}
.search-result {background:transparent;border:0;border-radius:12px;display:flex;align-items:center;gap:9px;padding:9px 10px;min-height:58px;text-align:left;color:var(--text)}
.search-result:not(:disabled):hover {background:var(--accent-soft)}
.search-result:disabled {opacity:.42}
.result-end {display:flex;align-items:center;color:var(--accent);font-size:11px}
.empty-results {color:var(--muted);font-size:13px;padding:15px 6px}
.select-label {display:block;margin:2px 0 10px;font-size:13px;color:var(--muted)}
.theme-choice {width:100%;height:48px;padding:0 13px;background:var(--bg);color:var(--text);border:1px solid var(--edge);border-radius:12px}
.settings-info {border:1px solid var(--edge);border-radius:12px;padding:2px 14px}
.settings-row {display:flex;align-items:center;justify-content:space-between;gap:12px;padding:13px 0;border-bottom:1px solid var(--edge);font-size:12px}
.settings-row:last-child {border:0}
.settings-row span {color:var(--muted)}
.settings-row strong {text-align:right;font-size:12px}
.secondary-button {display:flex;justify-content:center;align-items:center;gap:9px;border:1px solid var(--edge);background:var(--bg);color:var(--text);border-radius:12px;width:100%;min-height:46px;font-size:13px;font-weight:670;margin-top:15px}
.settings-note {font-size:12px;color:var(--muted);line-height:1.6;margin:16px 0 20px}
.startup {text-align:center;color:var(--muted);padding:40vh 10px}.loading-ring {display:inline-block;width:28px;height:28px;border-radius:50%;border:3px solid var(--edge);border-top-color:var(--accent);animation:spin 1s linear infinite}
@media(max-width:420px) {
 .shell {padding:15px 14px max(28px,env(safe-area-inset-bottom))}
 .topbar {margin-bottom:12px}
 .currency-card {padding:11px 11px 9px}
 .rate-status {margin-bottom:14px}
 .identity {flex-basis:41%;gap:7px}
 .flag {width:33px;height:33px;font-size:23px}
 .amount-input {font-size:clamp(22px,6.4vw,29px)}
 .sheet-body,.sheet-head {padding-left:16px;padding-right:16px}
 .manage-row {gap:5px;padding:7px 6px}
 .manage-flag {width:29px;font-size:22px}
 .mini-button {width:28px}
}
@media(max-width:345px) {
 .identity {flex-basis:39%}
 .flag {width:29px;height:29px;font-size:21px}
 .identity-text span {font-size:10px}
 .amount-input {font-size:21px}
 .copy-button {width:27px}
}
@media(min-width:800px) {.shell {padding-top:32px}}
@media(prefers-reduced-motion:reduce) {*,*:before,*:after {animation-duration:.01ms!important;transition-duration:.01ms!important}}

@media (max-width: 380px) {
  .shell {padding-inline: 14px; padding-top: 14px;}
  .utility-bar {padding-inline: 8px 6px;}
  .section-heading h2 {font-size:15px;}
}
/* Scanner integration — keep the converter's compact first screen unchanged. */
.heading-tools {display:flex;align-items:center;gap:13px}
.scan-launch {display:grid;place-items:center;width:37px;height:32px;border:1px solid var(--edge);border-radius:9px;background:var(--surface);color:var(--accent)}
.scan-launch:active {background:var(--accent-soft)}
.scanner-sheet {max-height:min(94vh,1000px)}
.scan-actions {display:grid;grid-template-columns:1fr 1fr;gap:9px}
.scan-actions .secondary-button {margin-top:0;font-size:13px}
.scan-preview {background:var(--bg);border:1px solid var(--edge);border-radius:12px;padding:10px;margin-top:12px;display:flex;justify-content:center}
.scan-preview img {display:block;max-height:230px;max-width:100%;object-fit:contain}
.scan-message {font-size:12px;color:var(--muted);margin:12px 0;line-height:1.5}
.scan-message[data-error="true"] {color:var(--warn)}
.scan-auth {background:var(--accent-soft);border:1px solid var(--accent-edge);border-radius:12px;padding:12px;margin:12px 0}
.scan-auth label {display:block;font-size:12px;font-weight:700;margin-bottom:8px}
.scan-auth input {width:100%;padding:12px;border-radius:10px;background:var(--surface);color:var(--text);border:1px solid var(--edge)}
.scan-auth p,.scan-privacy {font-size:11px;color:var(--muted);line-height:1.6}
.scan-auth .secondary-button {margin-top:8px}
.primary-button {width:100%;min-height:46px;border:0;border-radius:12px;background:var(--accent);color:white;font-weight:760;margin:7px 0 16px}
.primary-button:disabled {opacity:.55}
.receipt-overview {margin-top:16px}
.receipt-top {display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:13px;font-size:15px}
.receipt-top span {font-size:12px;color:var(--muted)}
.receipt-currency {display:flex;align-items:center;justify-content:space-between;font-size:12px;margin-bottom:11px}
.receipt-currency select {background:var(--bg);color:var(--text);border:1px solid var(--edge);border-radius:9px;padding:8px;min-width:95px}
.receipt-lines {display:flex;flex-direction:column;gap:7px}
.receipt-item {border:1px solid var(--edge);background:var(--bg);border-radius:12px;padding:11px 12px}
.receipt-item-top {display:flex;gap:12px;justify-content:space-between;align-items:start}
.receipt-names {min-width:0;flex:1;display:flex;flex-direction:column;gap:3px}
.receipt-names strong {font-size:13px;line-height:1.3;overflow-wrap:anywhere}
.receipt-names small {font-size:11px;color:var(--muted);overflow-wrap:anywhere}
.receipt-price {text-align:right;flex-shrink:0;display:flex;flex-direction:column;gap:3px}
.receipt-price strong {font-size:15px;font-variant-numeric:tabular-nums}
.receipt-price small {color:var(--muted);font-size:11px}
.receipt-item-edit {display:flex;gap:10px;margin-top:10px}
.receipt-item-edit label {display:flex;align-items:center;gap:6px;font-size:10px;color:var(--muted)}
.receipt-item-edit input,.receipt-totals input {color:var(--text);background:var(--surface);border:1px solid var(--edge);border-radius:7px;padding:6px;font-size:12px;width:66px;min-width:0;font-variant-numeric:tabular-nums}
.receipt-item-edit label:last-child input {width:87px}
.receipt-total {display:flex;justify-content:space-between;gap:12px;padding:15px 4px 12px;border-top:1px solid var(--edge);margin-top:14px}
.receipt-total>div:first-child {display:flex;flex-direction:column;gap:4px}
.receipt-total>div:first-child strong {font-size:14px}
.receipt-total small {color:var(--muted);font-size:11px}
.receipt-totals {display:flex;flex-direction:column;align-items:end;gap:5px}
.receipt-totals>strong {font-size:19px}
.receipt-totals label {font-size:11px;color:var(--muted)}
.receipt-check,.receipt-warning,.receipt-note,.receipt-disclaimer {font-size:11px;line-height:1.6;color:var(--muted);margin:8px 0}
.receipt-check.mismatch,.receipt-warning {color:var(--warn);background:var(--warn-soft);padding:10px;border-radius:9px}
.saved-receipt {width:100%;border:1px solid var(--edge);border-radius:11px;padding:11px;background:var(--bg);color:var(--text);display:flex;align-items:center;justify-content:space-between;gap:10px;text-align:left;margin:6px 0}
.saved-receipt span {display:flex;flex-direction:column;gap:4px;min-width:0}
.saved-receipt small {font-size:10px;color:var(--muted)}
#saved-scans h3 {margin:20px 0 10px;font-size:13px}
.scan-privacy {margin-top:20px}
.quiet-button {color:var(--muted);background:transparent;border:0;text-decoration:underline;font-size:11px;padding:10px 0}
@media(max-width:350px) {.scan-actions .secondary-button{font-size:11px}.receipt-item-edit{gap:4px;flex-wrap:wrap}.heading-tools{gap:8px}}

.receipt-name-edit {display:flex;align-items:center;gap:8px;color:var(--muted);font-size:10px;margin-top:9px}
.receipt-name-edit input {flex:1;min-width:0;color:var(--text);background:var(--surface);border:1px solid var(--edge);border-radius:7px;padding:7px;font-size:12px}
