:root {
  color-scheme: light;
  --bg: #f4efe6;
  --panel: #fffdf8;
  --raised: #f8f2e8;
  --ink: #232f28;
  --muted: #6d7c71;
  --faint: #9aa79d;
  --line: #ebe1d1;
  --line-2: #d8cab4;
  --green: #3f7f52;
  --green-2: #2f6540;
  --red: #b0473f;
  --red-soft: #f8ece9;
  --focus: color-mix(in srgb, var(--green) 22%, transparent);
  --shadow: 0 8px 24px rgb(74 55 30 / 0.07);
  --radius: 14px;
  --radius-sm: 10px;
  accent-color: var(--green);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.subtitle {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12.5px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.hidden {
  display: none !important;
}

/* ---------- Shell ---------- */
.shell {
  width: min(1120px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--green-2);
  color: #fbf6ec;
  font-size: 19px;
  font-weight: 800;
}

.brand h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 15px 18px;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 700;
}

.panel-body {
  padding: 18px;
}

/* ---------- Form ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0 11px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input::placeholder {
  color: var(--faint);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--focus);
}

/* ---------- Schedule ---------- */
.schedule {
  display: grid;
  grid-template-columns: auto minmax(0, 1.25fr) minmax(0, 0.85fr) auto;
  align-items: center;
  gap: 9px 10px;
}

.schedule-tag {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--green-2);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.linkbtn:hover {
  color: var(--green);
}

.segmented {
  grid-column: 2 / 4;
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.segmented button {
  height: 34px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
  transition: background-color 120ms ease, color 120ms ease;
}

.segmented button:first-child {
  border-left: 0;
}

.segmented button:hover {
  background: var(--raised);
  color: var(--ink);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--raised);
}

.btn-primary {
  border-color: var(--green);
  background: var(--green);
  color: #fbf6ec;
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--green-2);
  background: var(--green-2);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--red) 35%, var(--line-2));
  color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-soft);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--raised);
  color: var(--ink);
}

.btn-small {
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar input {
  flex: 1;
  min-width: 180px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.checkbox input {
  width: 16px;
  height: 16px;
}

/* ---------- Promo list ---------- */
.list {
  display: grid;
  gap: 10px;
}

.promo-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px 15px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.promo-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow);
}

.promo-card[data-inactive="true"] {
  background: var(--raised);
  opacity: 0.9;
}

.promo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.promo-id {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.code {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.status-on {
  color: var(--green-2);
}

.status-on::before {
  background: var(--green);
}

.status-off {
  color: var(--red);
}

.status-off::before {
  background: var(--red);
}

.promo-label {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.promo-meta {
  margin-top: 9px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.promo-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  color: var(--line-2);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- Empty / notice ---------- */
.empty {
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.notice {
  margin-bottom: 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--raised);
  padding: 11px 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.notice-error {
  border-color: color-mix(in srgb, var(--red) 40%, var(--line-2));
  background: var(--red-soft);
  color: var(--red);
}

/* ---------- Redemptions ---------- */
.redemptions {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.redemptions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.redemptions-head h3 {
  font-size: 14px;
  font-weight: 700;
}

.redemption-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 11px 0;
}

.redemption-row:first-of-type {
  border-top: 0;
}

/* ---------- Login ---------- */
.login-wrap {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.login {
  width: min(400px, 100%);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell {
    width: min(100vw - 24px, 680px);
  }

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

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

  .schedule {
    grid-template-columns: auto 1fr 1fr;
  }

  .linkbtn {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .segmented {
    grid-column: 1 / -1;
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
