:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #64748b;
  --border: #d9e2ec;
  --primary: #116149;
  --primary-dark: #0c4937;
  --danger: #b42318;
  --warning: #b35c00;
  --ok: #16784f;
  --used: #687385;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.4;
}

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

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand h1,
.panel h1 {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 2rem);
  letter-spacing: 0;
}

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

.panel,
.toolbar,
.stat,
.voucher-card,
.table-wrap,
.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

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

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

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

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  margin-bottom: 16px;
}

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

.form {
  display: grid;
  gap: 12px;
}

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

.field label {
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
  color: var(--text);
}

.btn {
  border: 0;
  border-radius: 6px;
  padding: 11px 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  min-height: 44px;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: #e7eef5;
  color: var(--text);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  position: relative;
  opacity: 0.85;
}

.btn[aria-busy="true"]::after {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: spin 0.8s linear infinite;
}

.btn.secondary[aria-busy="true"]::after {
  border-color: rgba(31, 41, 51, 0.3);
  border-top-color: var(--text);
}

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

.muted {
  color: var(--muted);
}

.stat {
  padding: 16px;
}

.stat strong {
  display: block;
  font-size: 1.8rem;
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}

.status.NEW,
.status.VALID {
  background: var(--ok);
}

.status.USED {
  background: var(--used);
}

.status.EXPIRED {
  background: var(--warning);
}

.status.CANCELLED,
.status.INVALID {
  background: var(--danger);
}

.voucher-card {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 22px;
  text-align: center;
}

.qr {
  width: min(260px, 72vw);
  aspect-ratio: 1;
  margin: 18px auto;
  display: block;
}

.code {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.notice {
  padding: 14px;
  border-left: 5px solid var(--primary);
}

.notice.error {
  border-left-color: var(--danger);
}

.notice.warning {
  border-left-color: var(--warning);
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .panel {
    padding: 16px;
  }

  .grid.two,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .btn {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .toolbar,
  .no-print {
    display: none !important;
  }

  .voucher-card {
    border: 0;
    box-shadow: none;
  }
}
