@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #16211d;
  --muted: #69736e;
  --paper: #fffefa;
  --canvas: #f3f0e8;
  --line: #dedbd2;
  --green: #2f6b55;
  --green-soft: #dbe8df;
  --orange: #e76935;
  --shadow: 0 24px 65px rgba(36, 43, 39, 0.12);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Manrope', system-ui, sans-serif;
  background:
    radial-gradient(circle at 78% 3%, rgba(255,255,255,.9), transparent 29rem),
    linear-gradient(rgba(31, 46, 39, .026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 46, 39, .026) 1px, transparent 1px),
    var(--canvas);
  background-size: auto, 26px 26px, 26px 26px, auto;
  touch-action: manipulation;
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(28px, calc((100vw - 1140px) / 2));
  border-bottom: 1px solid rgba(22, 33, 29, .12);
  background: rgba(245, 242, 234, .82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .16em;
  text-decoration: none;
}

.brand-mark { height: 27px; display: flex; gap: 2px; align-items: stretch; }
.brand-mark i { display: block; width: 2px; background: var(--ink); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { width: 4px; }
.brand-mark i:nth-child(3) { margin-inline: 1px; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-button, .clear-button, .paper-footer button {
  border: 1px solid rgba(22, 33, 29, .16);
  background: transparent;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.icon-button:hover, .clear-button:hover, .paper-footer button:hover:not(:disabled) { background: white; border-color: rgba(22,33,29,.35); }
.icon-button:active, .clear-button:active, .paper-footer button:active { transform: translateY(1px); }
.icon-button { width: 39px; height: 39px; border-radius: 50%; display: grid; place-items: center; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.clear-button { height: 39px; padding: 0 18px; border-radius: 24px; font-size: 12px; font-weight: 700; }

.workspace { width: min(820px, calc(100% - 36px)); margin: 0 auto; padding: 70px 0 48px; }
.intro { text-align: center; }
.eyebrow, .paper-kicker {
  margin: 0;
  color: var(--green);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .18em;
}
.intro h1 { margin: 13px 0 10px; font-size: clamp(42px, 6vw, 66px); line-height: .98; letter-spacing: -.055em; }
.intro-copy { max-width: 500px; margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.65; }

.scanner-status {
  width: fit-content;
  margin: 27px auto 29px;
  padding: 0 0 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(47, 107, 85, .45);
  color: var(--green);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.status-icon { height: 13px; display: flex; align-items: stretch; gap: 2px; }
.status-icon i { display: block; width: 1px; background: currentColor; }
.status-icon i:nth-child(2), .status-icon i:nth-child(4) { width: 3px; }

.paper {
  background: var(--paper);
  border: 1px solid rgba(22,33,29,.14);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.paper::before { content: ''; position: absolute; left: 63px; top: 0; bottom: 0; border-left: 1px solid rgba(231,105,53,.24); pointer-events: none; }
.paper-heading { min-height: 108px; padding: 27px 31px 23px 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.date { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.scan-count { display: flex; align-items: baseline; gap: 7px; }
.scan-count strong { font-family: 'DM Mono', monospace; font-size: 32px; font-weight: 400; }
.scan-count span { color: var(--muted); font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .15em; }

.scanner-field {
  height: 74px;
  margin: 24px 30px 22px 87px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  background: #f4f7f2;
  border: 1px solid #b9c7bc;
  cursor: text;
}
.scanner-field:focus-within { background: #f8fbf7; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47,107,85,.09); }
.scanner-field > svg { width: 27px; flex: 0 0 auto; fill: none; stroke: var(--green); stroke-width: 1.5; }
.scanner-field input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; font-family: 'DM Mono', monospace; font-size: 17px; }
.scanner-field input::placeholder { color: #87908b; }
.scanner-field kbd { padding: 5px 8px; border: 1px solid #c5cbc6; border-bottom-width: 2px; border-radius: 4px; background: white; color: #7d8580; font: 9px 'DM Mono', monospace; letter-spacing: .08em; }
.corner { width: 8px; height: 8px; position: absolute; border-color: var(--green); border-style: solid; }
.corner-tl { top: -1px; left: -1px; border-width: 2px 0 0 2px; }.corner-tr { top: -1px; right: -1px; border-width: 2px 2px 0 0; }
.corner-bl { bottom: -1px; left: -1px; border-width: 0 0 2px 2px; }.corner-br { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.list-wrap { min-height: 298px; border-top: 1px solid var(--line); position: relative; }
.list-wrap::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(transparent 0, transparent 48px, rgba(73,84,77,.115) 49px); pointer-events: none; }
.scan-list { margin: 0; padding: 0; list-style: none; position: relative; }
.scan-item { min-height: 49px; padding: 0 31px 0 87px; display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; animation: lineIn .24s ease-out both; }
@keyframes lineIn { from { opacity: 0; transform: translateY(-7px); } }
.line-number { color: #9aa19d; font: 11px 'DM Mono', monospace; }
.barcode-value { overflow: hidden; text-overflow: ellipsis; color: #27312c; font: 14px 'DM Mono', monospace; white-space: nowrap; }
.remove-scan { width: 28px; height: 28px; border: 0; border-radius: 50%; opacity: 0; background: transparent; color: #89918d; cursor: pointer; font-size: 18px; transition: opacity .15s, background .15s; }
.scan-item:hover .remove-scan, .remove-scan:focus { opacity: 1; }
.remove-scan:hover { background: #f0e5df; color: #a54e2b; }
.empty-state { min-height: 298px; display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; color: var(--muted); text-align: center; }
.empty-state.hidden { display: none; }
.empty-bars { height: 35px; display: flex; align-items: stretch; gap: 3px; margin-bottom: 18px; opacity: .28; }
.empty-bars i { width: 2px; background: var(--ink); }.empty-bars i:nth-child(2), .empty-bars i:nth-child(6) { width: 5px; }.empty-bars i:nth-child(4) { width: 3px; }
.empty-state p { margin: 0 0 5px; color: #6e7873; font-size: 14px; font-weight: 600; }
.empty-state span { font-size: 12px; }

.paper-footer { min-height: 63px; padding: 0 30px 0 87px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.paper-footer > span { display: flex; align-items: center; gap: 8px; }
.paper-footer-actions { display: flex; align-items: center; gap: 3px; }
.saved-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.paper-footer button { padding: 7px 10px; display: flex; gap: 5px; align-items: center; border: 0; border-radius: 4px; color: #555f5a; font-size: 11px; }
.paper-footer button:disabled { opacity: .35; cursor: default; }
.paper-footer svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.focus-hint { margin: 26px 0 0; color: #7b837f; font-size: 12px; text-align: center; }
.focus-hint > span:first-child { margin-right: 5px; padding: 3px 7px; border-radius: 3px; background: #dedbd2; color: #545d58; font: 9px 'DM Mono', monospace; text-transform: uppercase; }
.history { margin-top: 54px; }
.history-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 17px; }
.history-heading h2 { margin: 7px 0 0; font-size: 27px; letter-spacing: -.035em; }
.history-heading > span { color: var(--muted); font: 10px 'DM Mono', monospace; letter-spacing: .1em; text-transform: uppercase; }
.history-days { display: grid; gap: 11px; }
.day-card { border: 1px solid rgba(22,33,29,.14); border-radius: 4px; background: rgba(255,254,250,.82); }
.day-summary { min-height: 66px; padding: 11px 14px 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; list-style: none; }
.day-summary::-webkit-details-marker { display: none; }
.day-date { display: grid; gap: 4px; }
.day-date strong { font-size: 14px; }
.day-date span { color: var(--muted); font: 10px 'DM Mono', monospace; letter-spacing: .08em; }
.day-actions { display: flex; gap: 4px; align-items: center; }
.day-actions button { min-height: 38px; padding: 0 11px; border: 1px solid rgba(22,33,29,.14); border-radius: 3px; background: transparent; color: #555f5a; font-size: 10px; font-weight: 700; cursor: pointer; }
.day-actions button:hover { background: white; border-color: rgba(22,33,29,.34); }
.day-actions .delete-day { color: #a54e2b; border-color: rgba(165,78,43,.25); }
.day-card-list { margin: 0; padding: 0 18px 13px; border-top: 1px solid var(--line); list-style: none; }
.day-card-list li { min-height: 39px; display: grid; grid-template-columns: 34px 1fr; align-items: center; border-bottom: 1px solid rgba(73,84,77,.1); font: 12px 'DM Mono', monospace; }
.day-card-list li:last-child { border-bottom: 0; }
.day-card-list span:first-child { color: #9aa19d; font-size: 10px; }
.history-pagination { margin-top: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.history-pagination button { min-width: 42px; min-height: 42px; border: 1px solid rgba(22,33,29,.16); border-radius: 3px; background: transparent; cursor: pointer; }
.history-pagination button:hover:not(:disabled) { background: white; border-color: rgba(22,33,29,.35); }
.history-pagination button:disabled { opacity: .32; cursor: default; }
.history-pagination span { min-width: 86px; color: var(--muted); font: 10px 'DM Mono', monospace; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.confirm-modal { width: min(420px, calc(100% - 28px)); padding: 0; border: 1px solid rgba(22,33,29,.22); border-radius: 5px; background: var(--paper); color: var(--ink); box-shadow: 0 28px 80px rgba(16,24,20,.32); }
.confirm-modal::backdrop { background: rgba(15,24,20,.54); backdrop-filter: blur(4px); }
.modal-mark { width: 42px; height: 42px; margin: 27px 27px 0; display: grid; place-items: center; border: 1px solid rgba(165,78,43,.4); color: #a54e2b; font: 500 18px 'DM Mono', monospace; }
.modal-copy { padding: 19px 27px 25px; }
.modal-copy h2 { margin: 8px 0; font-size: 25px; letter-spacing: -.035em; }
.modal-copy > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.modal-actions { padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 1px solid var(--line); background: #f6f4ed; }
.modal-actions button { min-height: 46px; border-radius: 3px; font-size: 12px; font-weight: 700; cursor: pointer; }
.modal-cancel { border: 1px solid rgba(22,33,29,.18); background: transparent; }
.modal-confirm { border: 1px solid #a54e2b; background: #a54e2b; color: white; }
.modal-confirm:hover { background: #8e4023; }
.settings-modal { width: min(510px, calc(100% - 28px)); padding: 0; border: 1px solid rgba(22,33,29,.22); border-radius: 5px; background: var(--paper); color: var(--ink); box-shadow: 0 28px 80px rgba(16,24,20,.32); }
.settings-modal::backdrop { background: rgba(15,24,20,.54); backdrop-filter: blur(4px); }
.settings-header { padding: 24px 24px 20px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); }
.settings-header h2 { margin: 7px 0 0; font-size: 27px; letter-spacing: -.035em; }
.settings-close { width: 42px; height: 42px; border: 1px solid rgba(22,33,29,.16); border-radius: 50%; background: transparent; font-size: 24px; cursor: pointer; }
.settings-body { display: grid; }
.setting-row { min-height: 94px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 22px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row > span { display: grid; gap: 5px; }
.setting-row strong { font-size: 13px; }
.setting-row small { max-width: 335px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.setting-row select { min-width: 122px; height: 42px; padding: 0 34px 0 12px; border: 1px solid rgba(22,33,29,.2); border-radius: 3px; background: white; color: var(--ink); }
.setting-row > input[type="password"] { width: 170px; height: 42px; padding: 0 11px; border: 1px solid rgba(22,33,29,.2); border-radius: 3px; background: white; color: var(--ink); }
.setting-toggle input { width: 46px; height: 25px; flex: 0 0 auto; appearance: none; border: 1px solid #aeb6b1; border-radius: 20px; background: #d9ddda; position: relative; cursor: pointer; transition: background .18s; }
.setting-toggle input::after { content: ''; width: 19px; height: 19px; position: absolute; top: 2px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: transform .18s; }
.setting-toggle input:checked { background: var(--green); border-color: var(--green); }
.setting-toggle input:checked::after { transform: translateX(20px); }

body.minimal-ui .brand > span:last-child,
body.minimal-ui .intro,
body.minimal-ui .focus-hint,
body.minimal-ui .paper-kicker,
body.minimal-ui .history-heading .eyebrow,
body.minimal-ui .paper-footer > span #saveStatus,
body.minimal-ui .empty-state > span { display: none; }
body.minimal-ui .workspace { padding-top: 25px; }
body.minimal-ui .scanner-status { margin: 0 auto 18px; }
body.minimal-ui .paper-heading { min-height: 72px; padding-block: 14px; }
body.minimal-ui .history { margin-top: 30px; }
body.minimal-ui .history-heading h2 { margin-top: 0; font-size: 22px; }
body.minimal-ui .paper-footer > span { min-width: 7px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 20px); padding: 11px 17px; border-radius: 5px; background: var(--ink); color: white; box-shadow: 0 8px 25px rgba(0,0,0,.2); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.reactivate-scanner {
  position: fixed;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 30;
  min-height: 48px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: white;
  box-shadow: 0 10px 30px rgba(22, 33, 29, .24);
  font: 600 12px 'DM Mono', monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transform: translateY(calc(100% + 24px));
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.reactivate-scanner.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

@media (max-width: 640px) {
  .topbar {
    height: 60px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .brand { font-size: 11px; gap: 9px; }
  .brand-mark { height: 22px; }
  .icon-button { width: 44px; height: 44px; }
  .clear-button { min-height: 44px; padding-inline: 12px; }
  .topbar-actions { gap: 4px; }
  .workspace {
    width: calc(100% - 16px);
    padding-top: 25px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
  .eyebrow { font-size: 9px; }
  .intro h1 { margin: 8px 0 6px; font-size: 38px; }
  .intro-copy { padding-inline: 12px; font-size: 12px; line-height: 1.45; }
  .scanner-status { margin: 15px auto 17px; }
  .paper::before { left: 39px; }
  .paper-heading { min-height: 78px; padding: 16px 14px 14px 54px; }
  .date { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
  .scan-count { gap: 4px; }
  .scan-count strong { font-size: 25px; }
  .scan-count span { font-size: 8px; }
  .scanner-field {
    height: 64px;
    margin: 12px 10px 12px 49px;
    padding-inline: 12px;
    position: sticky;
    top: 70px;
    z-index: 5;
    box-shadow: 0 4px 14px rgba(36, 43, 39, .08);
  }
  .scanner-field kbd { display: none; }
  .scanner-field input { font-size: 16px; }
  .list-wrap, .empty-state { min-height: 232px; }
  .scan-item { padding-left: 54px; padding-right: 14px; grid-template-columns: 25px 1fr 28px; gap: 6px; }
  .remove-scan { width: 44px; height: 44px; margin-right: -8px; opacity: .55; }
  .paper-footer { padding-left: 54px; padding-right: 14px; }
  .paper-footer button { min-height: 44px; }
  .history { margin-top: 36px; }
  .history-heading { padding-inline: 4px; }
  .day-summary { padding-left: 13px; padding-right: 9px; align-items: flex-start; flex-direction: column; }
  .day-actions { width: 100%; }
  .day-actions button { min-height: 44px; flex: 1; }
  .modal-mark { margin: 21px 21px 0; }
  .modal-copy { padding: 16px 21px 21px; }
  .settings-header { padding: 20px 18px 16px; }
  .setting-row { padding: 17px 18px; align-items: flex-start; flex-direction: column; gap: 13px; }
  .setting-row select { width: 100%; }
  .setting-row > input[type="password"] { width: 100%; }
  .setting-toggle { flex-direction: row; align-items: center; }
}

@media (max-width: 410px) {
  .brand > span:last-child { display: none; }
  .intro h1 { font-size: 34px; }
  .paper-heading { min-height: 74px; }
  .paper-kicker { font-size: 9px; }
  .date { max-width: 155px; }
  .paper-footer > span { min-width: 8px; }
  .paper-footer > span #saveStatus { display: none; }
}

@media (max-width: 350px), (max-height: 620px) {
  .workspace { padding-top: 17px; }
  .intro-copy { display: none; }
  .scanner-status { margin-block: 12px 14px; }
  .paper-heading { min-height: 67px; padding-block: 12px; }
  .focus-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
