:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #151923;
  --muted: #626b7a;
  --line: #d9dee8;
  --accent: #0d6b57;
  --accent-strong: #084c3d;
  --warn: #9a3412;
  --blue: #2454a6;
  --shadow: 0 12px 30px rgba(28, 39, 60, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: 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 {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
  padding: 10px 14px;
}

button.secondary {
  background: #eef1f6;
  color: var(--ink);
}

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

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

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

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

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

.hidden {
  display: none !important;
}

.auth {
  width: min(420px, 100%);
  margin: 10vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 650;
  gap: 6px;
}

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

textarea {
  resize: vertical;
}

.message {
  color: var(--muted);
  font-size: 14px;
  margin-top: 14px;
}

#top-up-message {
  margin-bottom: 14px;
  white-space: pre-line;
}

.top-up-history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px;
}

.ledger-history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px;
}

.top-up-item {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  padding-top: 10px;
}

.top-up-item span {
  color: var(--muted);
  font-size: 13px;
}

.top-up-item pre {
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  margin: 0;
  white-space: pre-wrap;
}

.ledger-item {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding-top: 10px;
}

.ledger-item small {
  color: var(--muted);
  grid-column: 1 / -1;
}

.ledger-item strong.credit {
  color: var(--accent-strong);
}

.ledger-item strong.debit {
  color: var(--warn);
}

.admin-shell {
  width: min(1320px, calc(100vw - 32px));
}

.admin-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 20px;
}

.summary-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
  padding: 14px;
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.summary-item strong {
  font-size: 22px;
  line-height: 1.1;
}

.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  padding: 16px;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 750;
}

td {
  max-width: 340px;
  overflow-wrap: anywhere;
}

.status {
  color: var(--muted);
  font-weight: 750;
}

.status.failed,
.status.skipped_insufficient_balance {
  color: var(--warn);
}

.status.completed,
.status.confirmed {
  color: var(--accent-strong);
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

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

#user-email {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

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

.balance span {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 750;
  padding: 10px 12px;
}

.creator {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  padding: 16px;
}

.creator form {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
}

.layout {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
}

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

.panel-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.switch {
  align-items: center;
  display: flex;
  grid-template-columns: none;
  gap: 8px;
}

.switch input {
  width: auto;
}

.tracker-list {
  display: grid;
  gap: 10px;
}

.tracker-item {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.tracker-item.active {
  border-color: var(--blue);
}

.tracker-title {
  font-weight: 750;
  line-height: 1.35;
}

.meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px;
}

.pill {
  background: #edf7f4;
  border-radius: 999px;
  color: var(--accent-strong);
  padding: 4px 8px;
}

.pill.paused {
  background: #fff4ed;
  color: var(--warn);
}

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

.detail.empty {
  align-items: center;
  color: var(--muted);
  display: grid;
  justify-items: center;
}

.detail-grid {
  display: grid;
  gap: 16px;
}

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

.chat-edit {
  display: grid;
  gap: 10px;
}

.chat-edit button {
  justify-self: start;
}

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

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

.history {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.result p {
  color: var(--muted);
  font-size: 14px;
}

.feedback-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-actions button.selected {
  background: #dcebe7;
  color: var(--accent-strong);
}

.feedback-state {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 820px) {
  .topbar,
  .balance,
  .creator form {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

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

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