:root {
  --cream: #f7f3eb;
  --cream-dark: #ebe4d6;
  --wood: #8b6914;
  --green: #2d4a3e;
  --green-light: #3d6354;
  --red-soft: #a63d3d;
  --text: #2a2520;
  --text-muted: #534c44;
  --white: #fdfcfa;
  --border: #d4c9b8;
  --focus: #1e5f4a;
  --shadow: rgba(42, 37, 32, 0.08);
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-display: "Lora", "Georgia", serif;
  --radius: 6px;
  --max: 40rem;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.header-inner {
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--green);
  text-decoration: none;
}

.brand span {
  color: var(--red-soft);
}

.nav-main {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.nav-main a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
}

.nav-main a:hover {
  background: var(--cream-dark);
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--green);
  margin: 0 0 0.75rem;
}

.lead {
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
}

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

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 2px 12px var(--shadow);
  margin-bottom: 1.5rem;
}

.panel-narrow {
  max-width: var(--max);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-header h2 {
  font-family: var(--font-display);
  margin: 0;
  color: var(--green);
  font-size: 1.25rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1.2;
}

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

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: var(--max);
}

.form-stack label {
  font-weight: 600;
  margin-top: 0.75rem;
}

.form-stack input {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
}

.form-stack input:focus {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.btn {
  display: inline-block;
  margin-top: 0.75rem;
  margin-right: 0.5rem;
  padding: 0.65rem 1.25rem;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  text-align: center;
}

.btn-primary {
  background: var(--green);
  color: var(--white);
}

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

.btn-secondary {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}

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

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-error {
  background: #fdeaea;
  border: 1px solid #e8b4b4;
  color: var(--red-soft);
}

.alert-success {
  background: #eaf5ef;
  border: 1px solid #a8d4b8;
  color: var(--green);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 700;
  color: var(--green);
}

.data-table a {
  color: var(--wood);
  word-break: break-all;
}

.row-inactive {
  opacity: 0.55;
}

.qr-layout {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .qr-layout {
    grid-template-columns: auto 1fr;
    align-items: start;
  }
}

.qr-preview {
  text-align: center;
  max-width: 20rem;
}

.qrcode-wrap {
  display: flex;
  justify-content: center;
  margin: 0 auto 1rem;
  min-height: 280px;
}

.qrcode-wrap svg {
  display: block;
  width: 280px;
  height: 280px;
  max-width: 100%;
  margin: 0 auto;
}

.qr-url {
  font-weight: 700;
  word-break: break-all;
  margin: 0 0 0.25rem;
}

.qr-destination {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-all;
}

.qr-actions .btn {
  display: block;
  width: 100%;
  max-width: 14rem;
}

.inline-form {
  margin-top: 1rem;
}

@media print {
  .site-header,
  .site-footer,
  .qr-actions,
  .panel:last-of-type,
  .alert,
  .page-title {
    display: none !important;
  }

  .main-content {
    padding: 0;
    max-width: none;
  }

  .qr-preview {
    border: none;
    box-shadow: none;
    max-width: none;
  }

  body {
    background: white;
  }
}
