:root {
  --ink: #122a24;
  --muted: #667b74;
  --line: #dce6e1;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --primary: #168f93;
  --primary-dark: #0b6f73;
  --primary-soft: #e4f5f5;
  --amber: #9a6010;
  --amber-soft: #fff5df;
  --danger: #a33a3a;
  --shadow: 0 20px 60px rgba(16, 83, 86, 0.09);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 4%, rgba(46, 179, 179, 0.14), transparent 26rem),
    var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }

.page-shell {
  width: min(100% - 40px, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.site-header {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(18, 42, 36, 0.1);
}

.brand {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  background: #2eb3b3;
  border-radius: 11px;
  box-shadow: 0 7px 18px rgba(22, 143, 147, 0.16);
  text-decoration: none;
}

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

.secure-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.secure-label svg { width: 18px; height: 18px; }

main { flex: 1; }

.hero {
  max-width: 690px;
  padding: 68px 4px 36px;
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; font-family: Inter, ui-sans-serif, system-ui, sans-serif; }

h1 {
  max-width: 640px;
  font-size: clamp(2.1rem, 5.7vw, 3.55rem);
  line-height: 1.07;
  letter-spacing: -0.045em;
}

.hero p {
  max-width: 585px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.invoice-panel {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(18, 42, 36, 0.09);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 102px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 { font-size: 1.25rem; letter-spacing: -0.02em; }

.panel-heading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.refresh-button {
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--primary);
  background: var(--primary-soft);
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.refresh-button:hover { background: #d9ebe3; }
.refresh-button:active { transform: translateY(1px); }
.refresh-button svg { width: 17px; height: 17px; }
.refresh-button.is-loading svg { animation: spin 800ms linear infinite; }

.loading-state, .message-state {
  min-height: 260px;
  padding: 42px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-state strong, .message-state strong { margin-top: 17px; }
.loading-state span, .message-state p { margin: 7px 0 0; color: var(--muted); font-size: 0.9rem; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.message-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 15px;
  font-size: 1.35rem;
  font-weight: 700;
}

.message-state.error .message-icon { color: var(--danger); background: #fbecec; }

.invoice-list { margin: 0; padding: 0; list-style: none; }

.invoice-item {
  min-height: 105px;
  padding: 20px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 30px;
  border-bottom: 1px solid var(--line);
}

.invoice-item:last-child { border-bottom: 0; }

.invoice-identity { min-width: 0; display: flex; align-items: center; gap: 15px; }

.document-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 13px;
}

.document-icon svg { width: 24px; height: 24px; }

.invoice-name { display: block; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.invoice-caption { display: block; margin-top: 5px; color: var(--muted); font-size: 0.82rem; }

.status {
  min-width: 104px;
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.status::before { content: ""; width: 7px; height: 7px; background: currentColor; border-radius: 50%; }
.status.processing { color: var(--amber); background: var(--amber-soft); }

.invoice-action {
  min-width: 116px;
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: white;
  background: var(--primary);
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.invoice-action:hover { background: var(--primary-dark); box-shadow: 0 7px 15px rgba(22, 143, 147, 0.18); }
.invoice-action:active { transform: translateY(1px); }
.invoice-action svg { width: 17px; height: 17px; }
.invoice-action.processing { color: var(--amber); background: var(--amber-soft); }
.invoice-action.processing:hover { box-shadow: none; background: #ffedc7; }

.help-card {
  margin: 22px 0 68px;
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(18, 42, 36, 0.08);
  border-radius: 15px;
}

.help-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 50%;
  font-weight: 700;
}

.help-card strong { color: var(--ink); font-size: 0.88rem; }
.help-card p { margin: 4px 0 0; font-size: 0.83rem; line-height: 1.5; }

footer {
  min-height: 76px;
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #82928d;
  border-top: 1px solid rgba(18, 42, 36, 0.08);
  font-size: 0.76rem;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 520px);
  padding: 15px 17px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  background: #18382f;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 13px;
  box-shadow: 0 18px 48px rgba(9, 31, 25, 0.25);
  font-size: 0.86rem;
  line-height: 1.45;
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast-icon { width: 23px; height: 23px; display: grid; place-items: center; flex: 0 0 auto; color: var(--ink); background: #b9e1d1; border-radius: 50%; font-weight: 800; }

@media (max-width: 700px) {
  .page-shell { width: min(100% - 28px, 1040px); }
  .site-header { height: 72px; }
  .secure-label { font-size: 0; }
  .secure-label svg { width: 20px; height: 20px; }
  .hero { padding: 48px 2px 28px; }
  .hero p { font-size: 0.96rem; line-height: 1.6; }
  .panel-heading { min-height: 94px; padding: 20px; }
  .invoice-item { padding: 19px 20px; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
  .status { grid-column: 1; grid-row: 2; width: fit-content; min-width: 0; margin-left: 61px; }
  .invoice-action { grid-column: 2; grid-row: 1 / span 2; min-width: 46px; width: 46px; padding: 0; font-size: 0; }
  .invoice-action svg { width: 19px; height: 19px; }
  .help-card { margin-bottom: 44px; }
}

@media (max-width: 430px) {
  .page-shell { width: min(100% - 24px, 1040px); }
  .brand-logo { width: 140px; }
  .hero { padding-top: 40px; }
  h1 { font-size: 2rem; }
  .invoice-panel { border-radius: 17px; }
  .panel-heading { padding: 18px; }
  .panel-heading p { max-width: 190px; }
  .refresh-button { width: 42px; padding: 0; font-size: 0; }
  .invoice-item { padding: 18px; }
  .document-icon { width: 43px; height: 43px; }
  .invoice-name { font-size: 0.92rem; }
  .status { margin-left: 58px; }
  footer { flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
