:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --text: #172026;
  --muted: #6b7785;
  --line: #dce3ea;
  --primary: #126b57;
  --primary-strong: #0b4f40;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c24136;
  --green: #16845f;
  --shadow: 0 18px 45px rgba(21, 32, 43, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.nav-links a,
.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
}

.nav-links a {
  padding: 8px 12px;
  color: var(--muted);
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--primary-strong);
  background: #e8f3ef;
}

.shell {
  width: min(1180px, calc(100% - 36px));
  margin: 30px auto 56px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(18, 107, 87, 0.14), rgba(37, 99, 235, 0.08)),
    var(--bg);
}

.login-panel,
.panel,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(430px, 100%);
  padding: 28px;
}

.page-heading,
.panel-header,
.actions,
.form-actions,
.toolbar,
.pagination,
.row-actions {
  display: flex;
  align-items: center;
}

.page-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-heading h1,
.panel-header h2,
.login-panel h1 {
  margin: 0;
  line-height: 1.15;
}

.page-heading h1 {
  font-size: 30px;
}

.panel-header h2,
.login-panel h1 {
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel {
  padding: 22px;
}

.panel.narrow {
  max-width: 760px;
}

.panel-header {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

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

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

.stat-card {
  padding: 18px;
}

.stat-card span,
.muted-text,
.hint,
small,
dt {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.button {
  padding: 9px 14px;
  background: var(--surface);
  color: var(--text);
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

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

.button.ghost {
  border-color: var(--line);
}

.button.danger,
.icon-button.danger {
  color: #fff;
  background: var(--red);
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
}

svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

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

label,
.label-text {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: var(--blue);
}

.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

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

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-form .callout,
.settings-form .form-actions {
  grid-column: 1 / -1;
}

.toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.search-field {
  position: relative;
  flex: 1;
}

.compact-field {
  min-width: 190px;
}

.compact-field span {
  font-size: 12px;
  color: var(--muted);
}

.search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input {
  padding-left: 38px;
}

.actions,
.form-actions,
.row-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

.check-column {
  width: 44px;
  text-align: center;
}

.check-column input {
  width: 18px;
  height: 18px;
}

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

td strong,
td small {
  display: block;
}

.right {
  text-align: right;
}

.right .row-actions {
  justify-content: flex-end;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success,
.status-text.success {
  color: var(--green);
  background: #e7f5ef;
}

.badge.info,
.status-text.info {
  color: var(--blue);
  background: #e8efff;
}

.badge.warning,
.status-text.warning {
  color: var(--amber);
  background: #fff4dc;
}

.badge.danger,
.status-text.danger {
  color: var(--red);
  background: #ffe9e6;
}

.badge.muted,
.status-text.muted {
  color: var(--muted);
  background: var(--surface-2);
}

.status-text {
  border-radius: var(--radius);
  padding: 4px 8px;
}

.flash {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-weight: 700;
}

.flash-success {
  color: var(--green);
  background: #e7f5ef;
}

.flash-danger {
  color: var(--red);
  background: #ffe9e6;
}

.flash-warning {
  color: var(--amber);
  background: #fff4dc;
}

.progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 999px;
}

.progress.large {
  height: 14px;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}

.list {
  display: grid;
  gap: 8px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.list-row:hover {
  border-color: rgba(18, 107, 87, 0.45);
  background: #fbfefd;
}

.key-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.key-list span,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.chip {
  cursor: pointer;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented label {
  display: inline-grid;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-weight: 800;
}

.segmented input:checked + span {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.preview-phone {
  display: grid;
  align-items: end;
  min-height: 260px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(18, 107, 87, 0.08), rgba(37, 99, 235, 0.08)),
    #eef4f2;
}

.preview-bubble {
  width: min(88%, 420px);
  margin-left: auto;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #d9fdd3;
  white-space: pre-wrap;
}

.campaign-image {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.message-template {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.meta-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
}

dt,
dd {
  margin: 0;
}

.status-icon {
  width: 34px;
  height: 34px;
}

.status-icon.success {
  color: var(--green);
}

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

.callout {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid #b9d8ce;
  border-radius: var(--radius);
  background: #edf8f4;
}

.callout p {
  margin: 0;
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.qr-box {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
}

.qr-box img {
  width: min(280px, 100%);
  height: auto;
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.qr-box p {
  margin: 0;
  color: var(--muted);
}

.pagination {
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

@media (max-width: 880px) {
  .topbar {
    grid-template-columns: 1fr auto;
    align-items: start;
    padding: 12px 16px;
  }

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

  .shell {
    width: min(100% - 24px, 1180px);
    margin-top: 22px;
  }

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

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

@media (max-width: 620px) {
  .panel,
  .login-panel {
    padding: 18px;
  }

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

  .actions,
  .form-actions {
    width: 100%;
  }

  .actions .button,
  .form-actions .button {
    flex: 1;
  }

  th,
  td {
    padding: 11px 10px;
  }

  .meta-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
