:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --line: #d9e1dd;
  --text: #17211d;
  --muted: #65736d;
  --accent: #087f5b;
  --accent-2: #0ca678;
  --danger: #d92d20;
  --warning: #b76e00;
  --shadow: 0 18px 48px rgba(23, 33, 29, 0.11);
  --radius: 8px;
  --radius-sm: 6px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background:
    linear-gradient(180deg, rgba(8, 127, 91, 0.08), transparent 260px),
    var(--bg);
}

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

button {
  border: 0;
}

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

.screen {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.screen.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px 0;
}

.login-panel {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-panel p,
.page-title p,
.empty-state,
.muted {
  color: var(--muted);
}

.login-panel p {
  margin: 8px 0 24px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.field label {
  color: #33423c;
  font-size: 0.9rem;
  font-weight: 700;
}

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

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.13);
}

.password-step {
  display: none;
}

.password-step.visible {
  display: grid;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn.primary:hover {
  background: #066f50;
}

.btn.danger {
  color: #fff;
  background: var(--danger);
}

.btn.ghost {
  border: 1px solid var(--line);
  background: #fff;
}

.btn.icon-only {
  width: 42px;
  padding: 0;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 245, 0.9);
  backdrop-filter: blur(16px);
}

.topbar-inner {
  display: flex;
  width: min(1180px, calc(100% - 32px));
  min-height: 66px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.brand-inline .mini-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--accent);
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 0 20px;
}

.page-title p {
  margin: 6px 0 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.card,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  padding: 18px;
}

.panel h2,
.panel h3,
.card h3 {
  margin: 0 0 12px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel h2 {
  font-size: 1.2rem;
}

.panel h3,
.card h3 {
  font-size: 1rem;
}

.customer-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.identity-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.identity-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.identity-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.identity-row dt {
  color: var(--muted);
}

.identity-row dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.active {
  color: #05603a;
  background: #dff8ea;
}

.status-pill.expired {
  color: #9a3412;
  background: #ffedd5;
}

.status-pill.pending {
  color: #8a5a00;
  background: #fff4d5;
}

.status-pill.success {
  color: #05603a;
  background: #dff8ea;
}

.blink-warning {
  margin: 18px 0 12px;
  color: var(--danger);
  font-weight: 950;
  text-align: center;
  animation: blink 900ms steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.28;
  }
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.plan-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
}

.plan-card strong {
  display: block;
  font-size: 1.35rem;
}

.plan-card span {
  color: var(--muted);
}

.plan-card:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(8, 127, 91, 0.13);
}

.payment-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(310px, 1.1fr);
  gap: 16px;
}

.amount-box {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius);
  color: #fff;
  background: #163c32;
}

.amount-box strong {
  font-size: 2rem;
}

.method-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.method-tabs button {
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.method-tabs button.active {
  color: #fff;
  background: var(--accent);
}

.qr-wrap {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 14px;
  border: 1px dashed #b7c4be;
  border-radius: var(--radius);
  background: #fbfcfb;
}

.qr-wrap img {
  width: min(260px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #fff;
}

.waiting-state,
.success-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  text-align: center;
}

.state-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
}

.waiting-state .state-icon {
  color: var(--warning);
  background: #fff4d5;
}

.success-state .state-icon {
  color: var(--accent);
  background: #dff8ea;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}

.tabs button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.stat span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 1.55rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #42514c;
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: uppercase;
  background: #f7faf8;
}

tr:last-child td {
  border-bottom: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.compact-form .full {
  grid-column: 1 / -1;
}

.error {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: none;
  max-width: min(360px, calc(100% - 36px));
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #fff;
  background: #17211d;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.toast.visible {
  display: block;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #b7c4be;
  border-radius: var(--radius);
  text-align: center;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.small-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

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

@media (max-width: 920px) {
  .grid.two,
  .grid.three,
  .customer-summary,
  .payment-layout,
  .plans-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .screen,
  .topbar-inner {
    width: min(100% - 22px, 1180px);
  }

  .login-panel {
    padding: 22px;
  }

  .page-title {
    align-items: flex-start;
  }

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

  .identity-row {
    display: grid;
  }

  .identity-row dd {
    text-align: left;
  }

  .btn {
    width: 100%;
  }

  .btn.icon-only {
    width: 42px;
  }
}
