:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #657282;
  --line: #dde3ea;
  --primary: #06c755;
  --primary-dark: #05a849;
  --danger: #d83b3b;
  --warning: #b7791f;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a {
  color: var(--primary-dark);
}

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

.coupon-hero {
  background: linear-gradient(135deg, #07c85a, #0a9f87);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}

.coupon-hero p {
  margin: 0 0 8px;
  font-weight: 700;
}

.coupon-hero h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.45;
}

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

.message.success {
  border-color: #9bd9b8;
  background: #effaf4;
}

.message.error {
  border-color: #efb5b5;
  background: #fff2f2;
  color: #9f2c2c;
}

.dialog-message {
  margin: 12px 0;
}

.coupon-list {
  display: grid;
  gap: 14px;
}

.coupon-card,
.panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.coupon-card h2 {
  margin: 10px 0 8px;
  font-size: 20px;
}

.coupon-card p {
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 16px;
}

.coupon-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.status {
  font-weight: 700;
}

.status.ready {
  color: var(--primary-dark);
}

.status.used,
.status.expired {
  color: var(--warning);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

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

.button:disabled {
  background: #c5ccd3;
  cursor: not-allowed;
}

.button.ghost {
  background: #eef2f5;
  color: var(--text);
}

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

.use-button {
  width: 100%;
}

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

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(246, 247, 249, .98);
  padding: 16px;
  overflow-y: auto;
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog {
  width: min(100%, 420px);
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.dialog h2 {
  margin: 0 0 8px;
}

.dialog label,
.stack-form label,
.grid-form label,
.filter-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.grid-form .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.grid-form .checkbox-label input {
  width: auto;
}

.dialog input,
.dialog select,
.stack-form input,
.grid-form input,
.grid-form select,
.grid-form textarea,
.filter-form input,
.filter-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.confirm-panel {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.confirm-panel p {
  line-height: 1.6;
  margin: 0;
}

.admin-body {
  min-width: 320px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.admin-brand {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.admin-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-nav a,
.admin-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}

.admin-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.admin-main h1 {
  margin: 0 0 18px;
  font-size: 28px;
}

.panel,
.login-panel {
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.login-panel {
  max-width: 420px;
}

.login-main {
  display: grid;
  align-content: center;
  min-height: calc(100vh - 64px);
}

.login-main h1,
.login-main .login-panel {
  width: min(420px, 100%);
  margin-left: auto;
  margin-right: auto;
}

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

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

.span-2 {
  grid-column: span 2;
}

.filter-form {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  align-items: end;
}

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

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

.stat-grid strong {
  display: block;
  font-size: 30px;
}

.stat-grid span {
  color: var(--muted);
}

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
}

.clip {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.actions-cell form {
  margin: 0;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

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

@media (max-width: 760px) {
  .admin-header,
  .admin-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-main {
    padding: 18px 14px;
  }

  .grid-form,
  .filter-form,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
