:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-card: #1c2128;
  --bg-input: #0d1117;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #f0f3f6;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --danger: #f85149;
  --radius: 16px;
  --font: "Inter", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(34, 197, 94, 0.12), transparent),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.screen[hidden] {
  display: none !important;
}

/* ——— Login ——— */
#login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.login-icon svg {
  width: 28px;
  height: 28px;
}

.login-brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

#login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

#login-form input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}

#login-form input:focus {
  border-color: var(--accent);
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #052e16;
  padding: 14px 20px;
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-dark);
  color: #fff;
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-sm {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0 12px;
  min-width: 42px;
  border-radius: 0 8px 8px 0;
}

/* ——— App layout ——— */
#app-screen {
  min-height: 100vh;
  background: #111828;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(17, 24, 40, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 40px;
  align-items: start;
}

/* ——— Controls ——— */
.controls {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: sticky;
  top: 80px;
}

.controls h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus {
  border-color: var(--accent);
}

.field input[readonly] {
  color: var(--text-dim);
}

.input-with-action {
  display: flex;
}

.input-with-action input {
  border-radius: 8px 0 0 8px;
  border-right: none;
}

/* ——— Preview ——— */
.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ——— Receipt (identical to reference) ——— */
.receipt {
  width: 100%;
  max-width: 420px;
  padding-top: 36px;
  background: transparent;
}

.receipt-card {
  position: relative;
  background: #202938;
  border-radius: 16px;
  padding: 56px 28px 28px;
}

.receipt-pdf-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid #3a4558;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s, border-color 0.15s;
}

.receipt-pdf-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: #4b5568;
}

.receipt-pdf-btn svg {
  flex-shrink: 0;
}

.receipt-check {
  position: absolute;
  top: -36px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #22c55e;
  display: grid;
  place-items: center;
  z-index: 3;
}

.receipt-check svg {
  width: 34px;
  height: 34px;
}

.receipt-title {
  text-align: center;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin: 8px 0 8px;
  line-height: 1.25;
}

.receipt-subtitle {
  text-align: center;
  color: #9ca3af;
  font-size: 0.9375rem;
  font-weight: 400;
  margin-bottom: 32px;
  line-height: 1.4;
}

.receipt-amount {
  text-align: center;
  margin-bottom: 28px;
}

.receipt-amount-label {
  display: block;
  color: #9ca3af;
  font-size: 0.875rem;
  font-weight: 400;
  margin-bottom: 8px;
}

.receipt-amount-value {
  display: block;
  font-size: 2.125rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff;
  line-height: 1.2;
}

.receipt-section {
  border-top: 1px solid #2a3344;
  padding: 20px 0 18px;
}

.receipt-section-last {
  border-bottom: 1px solid #2a3344;
  margin-bottom: 22px;
}

.receipt-section h3 {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #9ca3af;
  margin-bottom: 16px;
  text-transform: uppercase;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  font-size: 0.9375rem;
  margin-bottom: 12px;
  line-height: 1.45;
}

.receipt-row:last-child {
  margin-bottom: 0;
}

.receipt-row span:first-child {
  color: #ffffff;
  flex-shrink: 0;
  font-weight: 400;
}

.receipt-row span:last-child {
  color: #ffffff;
  text-align: right;
  word-break: break-all;
  font-weight: 400;
}

.receipt-id {
  text-align: center;
  font-size: 0.75rem;
  color: #9ca3af;
  line-height: 1.45;
  font-weight: 400;
}

/* Hide PDF button when capturing */
.receipt.capturing .receipt-pdf-btn {
  visibility: hidden;
}

@media (max-width: 860px) {
  .app-main {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .controls {
    position: static;
  }
}

@media (max-width: 480px) {
  .receipt-card {
    padding: 52px 18px 24px;
  }

  .receipt-title {
    font-size: 1.4rem;
  }

  .receipt-amount-value {
    font-size: 1.75rem;
  }

  .receipt-check {
    width: 64px;
    height: 64px;
    top: -32px;
  }

  .receipt-check svg {
    width: 30px;
    height: 30px;
  }

  .login-card {
    padding: 32px 24px;
  }
}
