:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --text: #18202b;
  --muted: #5d6877;
  --border: #d8dee8;
  --accent: #275df5;
  --accent-2: #0f8b6f;
  --pending: #b86e05;
  --danger: #bf3b36;
  --shadow: 0 8px 24px rgba(24, 32, 43, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  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: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #1f4ed4;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #1f4ed4;
}

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

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: #fbfcfe;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #18202b;
  color: #fff;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 30px;
}

.nav-item {
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 12px;
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  background: #e8edf7;
  color: var(--text);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(520px, 760px);
  gap: 24px;
  align-items: end;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

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

.config-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
}

.topbar-tools {
  display: grid;
  gap: 10px;
}

.auth-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.button-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #1f4ed4;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  text-decoration: none;
}

.button-link:hover {
  background: #1f4ed4;
}

.button-link.secondary {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
}

.button-link.secondary:hover {
  background: var(--surface-2);
}

.status-line {
  min-height: 36px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  margin-bottom: 14px;
  padding: 8px 12px;
}

.status-line.success {
  border-color: rgba(15, 139, 111, 0.32);
  color: var(--accent-2);
}

.status-line.error {
  border-color: rgba(191, 59, 54, 0.32);
  color: var(--danger);
}

.workflow-band {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  padding: 18px;
}

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

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

.grid-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.stacked-form {
  display: grid;
  gap: 12px;
}

.sender-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.checkbox-label {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-label input {
  width: 16px;
  min-height: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

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

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

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

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

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

.compact-table:empty,
.record-list:empty {
  display: none;
}

.key-result {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin-top: 14px;
  border: 1px solid rgba(15, 139, 111, 0.28);
  border-radius: 8px;
  background: #f0fbf7;
  color: var(--accent-2);
  padding: 10px 12px;
}

.key-result code {
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.setup-result {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.record-group header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  padding: 10px 12px;
}

.record-group strong {
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #e8edf7;
  color: var(--muted);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}

.pill.active {
  background: #dff4ed;
  color: var(--accent-2);
}

.pill.pending {
  background: #fff1d8;
  color: var(--pending);
}

.pill.failed {
  background: #fde8e6;
  color: var(--danger);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 16px;
  }

  .topbar,
  .config-form,
  .grid-form,
  .sender-grid {
    grid-template-columns: 1fr;
  }

  .grid-form .wide {
    grid-column: span 1;
  }
}
