:root {
  color-scheme: light;
  font-family:
    "Avenir Next", "Helvetica Neue", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f6f7f8;
  color: #111827;
  --ink: #111827;
  --muted: #5b6677;
  --line: #d9dee7;
  --line-soft: #e9edf2;
  --panel: #ffffff;
  --canvas: #f6f7f8;
  --active: #121827;
  --accent: #2f7a59;
  --accent-soft: #d7f5de;
  --warn: #9a3d20;
  --shadow: 0 2px 8px rgb(17 24 39 / 8%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--canvas);
}

html,
body,
#root {
  height: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a.secondary-button {
  cursor: pointer;
  text-decoration: none;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 46px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 18px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 650;
  letter-spacing: 0;
}

.page-frame {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--canvas);
  overflow: hidden;
}

.brand-header {
  position: relative;
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 24px;
  padding: 28px clamp(28px, 6.5vw, 132px);
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
}

.brand-logo {
  display: block;
  width: 76px;
  height: auto;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.brand-title {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-actions {
  position: absolute;
  right: clamp(28px, 6.5vw, 132px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.loading {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 17px;
}

.app-shell,
.login-page {
  width: min(1500px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 32px clamp(24px, 6.5vw, 132px) 72px;
}

.login-page {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 28px;
  text-align: center;
}

.app-shell {
  display: grid;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.page-intro {
  margin-bottom: 30px;
  text-align: center;
}

.login-intro {
  margin-bottom: 0;
}

.page-intro p {
  max-width: 960px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.45;
}

.login-intro p {
  margin-top: 14px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
  color: var(--muted);
  font-size: 17px;
}

.filter-pill,
.prefix-group label,
.payment-group label {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: #3f4858;
  padding: 0 18px;
  line-height: 1.1;
}

.filter-pill.active,
.prefix-group label.selected {
  border-color: var(--active);
  background: var(--active);
  color: #ffffff;
}

.login-panel,
.capture-form,
.receipt-list {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  text-align: left;
}

.workspace {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: start;
  justify-content: center;
  gap: 22px;
}

.capture-form {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.receipt-list {
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

select {
  appearance: none;
  padding-right: 44px;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6L8 10L12 6' stroke='%235B6677' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px 16px;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7c8798;
  box-shadow: 0 0 0 3px rgb(91 102 119 / 15%);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 18px;
  border: 1px solid transparent;
  letter-spacing: 0;
}

.primary-button {
  background: var(--active);
  color: #ffffff;
}

.primary-button:hover {
  background: #273044;
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: #3f4858;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: #bfc7d3;
  background: #f9fafb;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: #3f4858;
}

.fixed-action-bar {
  background: rgb(255 255 255 / 94%);
  border-top: 1px solid var(--line-soft);
  box-shadow: 0 -8px 28px rgb(17 24 39 / 8%);
  padding: 14px clamp(20px, 6.5vw, 132px);
  backdrop-filter: blur(10px);
}

.fixed-action-inner {
  width: min(1500px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto;
}

.fixed-action-secondary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.piece-preview {
  min-width: 0;
  max-width: min(420px, 42vw);
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f9fafb;
  color: #3f4858;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fixed-submit {
  min-width: min(360px, 45vw);
}

.login-panel .primary-button {
  width: 100%;
}

.dropzone {
  position: relative;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #b8c0cc;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.dropzone span {
  width: min(360px, 86%);
  font-size: 17px;
  line-height: 1.45;
}

.dropzone.has-file {
  background: #0f172a;
}

.dropzone img {
  width: 100%;
  height: 100%;
  max-height: 560px;
  object-fit: contain;
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.prefix-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr);
  gap: 10px 12px;
  align-items: end;
}

.prefix-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prefix-group label {
  cursor: pointer;
  min-height: 34px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 650;
}

.prefix-group label:hover,
.prefix-group label:focus-within {
  z-index: 4;
}

.prefix-code {
  pointer-events: none;
}

.prefix-tooltip {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline: 0;
  width: auto;
  transform: translateY(2px);
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 16px 34px rgba(22, 29, 40, 0.14);
  color: #263241;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: normal;
}

.prefix-tooltip::after {
  content: "";
  position: absolute;
  inset-block-end: 100%;
  inset-inline-start: 18px;
  width: 8px;
  height: 8px;
  border-inline-start: 1px solid #d7dee8;
  border-block-start: 1px solid #d7dee8;
  background: #ffffff;
  transform: translate(-50%, -4px) rotate(45deg);
}

.prefix-group label:hover .prefix-tooltip,
.prefix-group label:focus-within .prefix-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.prefix-group input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.payment-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.payment-group label {
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.payment-group label.selected {
  border-color: var(--active);
  background: var(--active);
  color: #ffffff;
}

.payment-group input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 120px;
  gap: 12px;
}

.status,
.error {
  margin: 0;
  color: var(--warn);
  font-size: 14px;
}

.archive-toggle {
  width: 100%;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 18px 22px;
  text-align: left;
}

.archive-toggle span:first-child {
  display: grid;
  gap: 3px;
  font-size: 15px;
  font-weight: 650;
}

.archive-toggle small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.archive-chevron {
  width: 12px;
  height: 12px;
  border-right: 2px solid #6b7280;
  border-bottom: 2px solid #6b7280;
  transform: rotate(45deg);
  transition: transform 160ms ease, border-color 160ms ease;
}

.archive-toggle[aria-expanded="true"] .archive-chevron {
  transform: rotate(225deg);
}

.archive-toggle:hover .archive-chevron {
  border-color: #111827;
}

.receipt-list ul {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0 22px 20px;
  list-style: none;
}

.receipt-list > .muted {
  margin: 0;
  padding: 0 22px 20px;
}

.archive-export-panel {
  display: grid;
  gap: 12px;
  padding: 0 22px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.archive-period-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.archive-period-grid .secondary-button {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding-inline: 12px;
}

.archive-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
}

.receipt-list li {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-top: 1px solid var(--line-soft);
}

.receipt-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.receipt-list img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  background: #edf0f4;
}

.receipt-row-body {
  min-width: 0;
}

.receipt-title {
  margin-bottom: 5px;
  color: var(--ink);
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.receipt-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.receipt-title-row .receipt-title {
  flex: 1;
}

.receipt-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2f7;
  color: #3f4858;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.status-ready {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-needs_review {
  background: #fff2df;
  color: var(--warn);
}

.status-exported {
  background: #edf0f4;
  color: #5b6677;
}

.receipt-delete-button {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #7a2f1b;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.receipt-actions {
  min-width: 84px;
  display: grid;
  justify-items: stretch;
  gap: 6px;
}

.receipt-cancel-button {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #3f4858;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.receipt-delete-button:hover {
  border-color: #d9b7ab;
  background: #fff7f4;
}

.receipt-cancel-button:hover {
  border-color: #bfc7d3;
  background: #f9fafb;
}

.receipt-delete-button:disabled,
.receipt-cancel-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.receipt-meta,
.muted {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 920px) {
  .brand-header {
    min-height: 116px;
    flex-wrap: wrap;
  }

  .app-shell,
  .login-page {
    padding-top: 30px;
  }

  h1 {
    font-size: 36px;
  }

  .page-intro p {
    font-size: 18px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .brand-actions {
    position: static;
    width: 100%;
    justify-content: center;
  }

  .brand-title {
    font-size: 26px;
  }

  .brand-subtitle {
    font-size: 15px;
  }
}

@media (max-width: 640px) {
  .brand-header {
    align-items: center;
    padding: 22px 20px;
  }

  .brand-logo {
    width: 64px;
  }

  .brand-title {
    font-size: 23px;
  }

  .brand-subtitle {
    font-size: 14px;
  }

  .app-shell,
  .login-page {
    padding: 26px 20px 24px;
  }

  h1 {
    font-size: 31px;
  }

  .page-intro {
    margin-bottom: 22px;
  }

  .filter-row {
    font-size: 15px;
  }

  .filter-pill {
    min-height: 40px;
    padding: 0 14px;
  }

  .payment-group label {
    min-height: 34px;
    padding: 0 12px;
  }

  .prefix-row,
  .archive-period-grid {
    grid-template-columns: 1fr;
  }

  .archive-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .capture-form,
  .login-panel {
    padding: 18px;
  }

  .archive-toggle {
    padding: 16px 18px;
  }

  .receipt-list ul {
    padding: 0 18px 18px;
  }

  .receipt-list > .muted {
    padding: 0 18px 18px;
  }

  .dropzone {
    min-height: 280px;
  }

  .compact-grid {
    grid-template-columns: 1fr;
  }

  .fixed-action-bar {
    padding: 12px 20px max(12px, env(safe-area-inset-bottom));
  }

  .fixed-action-inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .fixed-action-secondary {
    justify-content: center;
  }

  .piece-preview {
    width: 100%;
    max-width: 100%;
    text-align: center;
  }

  .fixed-submit {
    width: 100%;
    min-width: 0;
  }
}
