:root {
  color-scheme: light;
  --bg: #edf2f8;
  --panel: #ffffff;
  --ink: #09213f;
  --muted: #61738b;
  --line: #c6d3e7;
  --blue: #174ea6;
  --blue-dark: #0a2346;
  --gold: #f4c95d;
  --green: #15803d;
  --red: #b42318;
  --shadow: 0 20px 50px rgb(8 32 62 / 12%);
  font-family: Aptos, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 78%), rgb(237 242 248 / 94%)),
    radial-gradient(circle at 100% 0%, rgb(244 201 93 / 20%), transparent 32%),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px 14px calc(26px + env(safe-area-inset-bottom, 0px));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -14px -14px 14px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
  background: rgb(246 249 253 / 88%);
  border-bottom: 1px solid rgb(198 211 231 / 78%);
  backdrop-filter: blur(18px);
}

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

.brand img {
  width: 44px;
  height: 44px;
  border: 2px solid #ffffff;
  border-radius: 14px;
  box-shadow: 0 12px 26px rgb(23 78 166 / 18%);
}

.brand strong,
.brand span {
  display: block;
  line-height: 1.05;
}

.brand strong {
  font-size: 1.22rem;
  font-weight: 950;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.icon-button,
.icon-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--blue);
}

.icon-button {
  gap: 3px;
}

.icon-button span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.hero-card,
.connect-panel,
.capture-panel,
.queue-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  gap: 12px;
  overflow: hidden;
  margin-bottom: 14px;
  padding: 18px;
  background:
    linear-gradient(135deg, #ffffff 0%, #f4f8ff 62%, #fff7dc 100%);
}

.status-row,
.section-heading,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff3cf;
  color: #9a5b13;
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.status-pill.ready {
  background: #ecfdf3;
  color: var(--green);
}

.status-pill.error {
  background: #fff1f0;
  color: var(--red);
}

.install-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 950;
}

.text-button.danger {
  color: var(--red);
}

.hero-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 11vw, 3.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-card p {
  margin: 0;
  max-width: 32rem;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 760;
  line-height: 1.45;
}

.capture-panel,
.connect-panel,
.queue-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
}

.connect-panel {
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.connect-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 760;
  line-height: 1.42;
}

.section-heading span {
  display: block;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.section-heading h2 {
  margin: 2px 0 0;
  font-size: 1.18rem;
  line-height: 1.05;
}

.section-heading small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.capture-stage {
  display: grid;
  min-height: 330px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(145deg, #08182f 0%, #0a2346 62%, #174ea6 100%);
  color: #ffffff;
}

.receipt-plate {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 11px;
  min-height: 100%;
  padding: 22px;
  text-align: center;
}

.receipt-plate.has-preview {
  padding: 0;
  background: #f8fbff;
}

.receipt-plate img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.receipt-plate svg {
  width: 64px;
  height: 64px;
  color: #d8e3f8;
}

.receipt-plate strong {
  font-size: 1.18rem;
  font-weight: 950;
}

.receipt-plate span {
  max-width: 25ch;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1.35;
}

.capture-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button,
.upload-button {
  min-height: 52px;
  border-radius: 8px;
  font-weight: 950;
}

.primary-button,
.upload-button {
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #ffffff;
  box-shadow: 0 16px 32px rgb(23 78 166 / 20%);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button svg {
  width: 20px;
  height: 20px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #f8fbff;
  color: var(--ink);
}

.secondary-button.danger {
  color: var(--red);
}

.upload-button {
  width: 100%;
}

.feedback {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
}

.feedback.error {
  color: var(--red);
}

.feedback.ok {
  color: var(--green);
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 780;
  line-height: 1.4;
}

.document-list {
  display: grid;
  gap: 10px;
}

.document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 66px;
  padding: 12px;
  border: 1px solid #dbe5f4;
  border-radius: 8px;
  background: #fbfdff;
}

.document-row strong,
.document-row span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
}

.document-row b {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 999px;
  background: #fff3cf;
  color: #9a5b13;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.document-row.done b {
  background: #ecfdf3;
  color: var(--green);
}

.document-row.error b {
  background: #fff1f0;
  color: var(--red);
}

.settings-dialog,
.install-dialog {
  width: min(440px, calc(100% - 22px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.settings-dialog::backdrop,
.install-dialog::backdrop {
  background: rgb(8 20 38 / 48%);
  backdrop-filter: blur(8px);
}

.settings-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.icon-close {
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--ink);
  outline: 0;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgb(23 78 166 / 12%);
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.4;
}

.install-card {
  gap: 16px;
}

.install-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.25rem;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 830;
  line-height: 1.35;
}

.install-steps li::marker {
  color: var(--blue);
  font-weight: 950;
}

@media (min-width: 760px) {
  body {
    display: grid;
    place-items: start center;
  }

  .app-shell {
    padding-top: 22px;
  }

  .app-header {
    border: 1px solid rgb(198 211 231 / 78%);
    border-radius: 8px;
  }
}
