:root {
  color-scheme: light;
  --bg: #f2fbfb;
  --ink: #06354a;
  --muted: #5d7880;
  --panel: #ffffff;
  --line: #d7eeee;
  --accent: #27c2bd;
  --accent-strong: #168daf;
  --accent-deep: #0b4d73;
  --accent-soft: #dcf8f4;
  --mint: #8edfc0;
  --gold: #ffd966;
  --warning: #b33b3b;
  --shadow: 0 18px 55px rgba(6, 53, 74, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(39, 194, 189, 0.18), transparent 36%),
    linear-gradient(315deg, rgba(142, 223, 192, 0.22), transparent 42%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.workspace {
  display: grid;
  gap: 20px;
}

body:not(.is-authenticated) .workspace {
  display: none;
}

body.is-authenticated .auth-panel {
  display: none;
}

.auth-panel {
  display: grid;
  gap: 24px;
  margin: 8vh auto 0;
  max-width: 520px;
  padding: 24px;
}

.auth-brand {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}

.auth-logo {
  display: block;
  height: auto;
  max-width: min(100%, 340px);
}

.auth-brand p {
  color: var(--muted);
  font-weight: 700;
}

.auth-form {
  display: grid;
}

.auth-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--accent-deep);
  font-size: clamp(2.1rem, 4vw, 4.4rem);
  line-height: 0.92;
}

h2 {
  font-size: 1.05rem;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 10px;
}

.stats-strip > div {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.stats-strip strong {
  color: var(--accent-strong);
  display: block;
  font-size: 1.65rem;
  line-height: 1;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(39, 194, 189, 0.2);
  border-radius: 8px;
  box-shadow: 0 12px 35px rgba(22, 141, 175, 0.12);
  display: block;
  height: clamp(82px, 12vw, 132px);
  object-fit: contain;
  padding: 8px 10px;
  width: clamp(210px, 34vw, 380px);
}

.stats-strip span {
  color: var(--muted);
  font-size: 0.86rem;
}

.plan-panel {
  align-items: center;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(180px, 1fr) minmax(240px, 1fr) auto;
  padding: 16px 18px;
}

.plan-panel h2 {
  margin-top: 8px;
}

.plan-meter {
  display: grid;
  gap: 8px;
}

.plan-meter strong {
  color: var(--accent-deep);
  display: block;
  font-size: 1.2rem;
}

.plan-meter span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

progress {
  accent-color: var(--accent);
  height: 12px;
  width: 100%;
}

.grid {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel,
.preview-panel,
.list-panel,
.admin-panel {
  padding: 20px;
}

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

label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 8px;
  margin-bottom: 16px;
}

input,
textarea,
select {
  background: #fbfdfc;
  border: 1px solid #cfdad4;
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  padding: 12px 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(39, 194, 189, 0.16);
}

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

.primary-button,
.ghost-button,
.icon-button {
  align-items: center;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  min-height: 48px;
  padding: 0 18px;
  width: 100%;
}

.primary-button:hover {
  background: linear-gradient(135deg, #20aca8, var(--accent-deep));
}

.ghost-button {
  background: var(--accent-soft);
  color: var(--accent-deep);
  min-height: 36px;
  padding: 0 12px;
}

.ghost-button.danger {
  background: #fbe7e7;
  color: var(--warning);
}

.preview-panel {
  display: grid;
  justify-items: center;
  min-height: 100%;
}

.preview-panel .section-title {
  width: 100%;
}

.status-pill {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 7px 10px;
}

#qrCanvas {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 260px;
  image-rendering: pixelated;
  width: 260px;
}

.preview-info {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  text-align: center;
  width: 100%;
}

.preview-info p {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

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

.icon-button {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 1.3rem;
  height: 44px;
  width: 44px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

.link-cell {
  color: var(--accent-deep);
  font-weight: 800;
  max-width: 260px;
  overflow-wrap: anywhere;
}

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

.row-actions button {
  background: #f4fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 34px;
  padding: 0 10px;
}

.empty-state {
  color: var(--muted);
  padding: 18px 0 4px;
  text-align: center;
}

.toast {
  background: var(--ink);
  border-radius: 8px;
  bottom: 20px;
  color: white;
  left: 50%;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding: 18px 0;
  }

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

  .topbar {
    align-items: stretch;
    display: grid;
  }

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

  .plan-panel {
    grid-template-columns: 1fr;
  }

  .auth-actions {
    grid-template-columns: 1fr;
  }

  .brand-lockup {
    align-items: flex-start;
    display: grid;
  }

  .brand-logo {
    width: min(100%, 290px);
  }
}
