:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
  --soft: #f8fafc;
  --accent: #111827;
  --danger: #b91c1c;
  --success: #047857;
  --warning: #b45309;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(15, 23, 42, .06), transparent 26rem),
    var(--bg);
  color: var(--ink);
}

button, input, textarea { font: inherit; }

.topbar {
  min-height: 92px;
  padding: 20px clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.025em; }
h3 { margin-bottom: 8px; }

.eyebrow, .section-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: .13em;
  font-weight: 800;
  color: #64748b;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .12);
}

.status-dot.ok {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, .12);
}

.status-dot.bad {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .12);
}

.layout {
  padding: 28px clamp(18px, 4vw, 56px) 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  max-width: 1680px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .055);
}

.composer { padding: 28px; }
.side-panel { padding: 24px; align-self: start; position: sticky; top: 120px; }

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

.section-heading.compact { margin-bottom: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 750;
  color: #334155;
  margin-bottom: 15px;
}

input, textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid #dbe1e8;
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, textarea:focus {
  border-color: #64748b;
  box-shadow: 0 0 0 4px rgba(100, 116, 139, .12);
}

textarea { resize: vertical; min-height: 105px; }

.variables {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

code {
  background: #eef2f7;
  border-radius: 5px;
  padding: 2px 5px;
  color: #334155;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 26px 0;
}

.button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s, opacity .12s, background .12s;
  white-space: nowrap;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.button.primary { background: var(--accent); color: white; padding: 12px 18px; }
.button.secondary { background: #eef2f7; color: #1e293b; }
.file-button { margin: 0; display: inline-flex; align-items: center; }
.file-button input { display: none; }

.text-button, .icon-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}
.icon-button { font-size: 30px; line-height: 1; }

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 12px 10px;
  text-align: left;
  color: #64748b;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .055em;
  text-transform: uppercase;
}

td {
  padding: 8px 6px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }
td input { margin: 0; min-width: 120px; padding: 9px 10px; }
td:nth-child(1) input { min-width: 145px; }
td:nth-child(2) input { min-width: 205px; }
td:nth-child(4) input { min-width: 170px; }
td:nth-child(6) input { min-width: 220px; }

.remove-row {
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 20px;
}
.remove-row:hover { color: var(--danger); }

.sendbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  background: var(--soft);
  border-radius: 12px;
  padding: 14px 16px;
}

.sendbar strong { display: block; }
.sendbar span { color: var(--muted); font-size: 13px; }

.log-list {
  max-height: 430px;
  overflow-y: auto;
  display: grid;
  gap: 9px;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
}

.log-item.ok { border-left: 4px solid #10b981; }
.log-item.fail { border-left: 4px solid #ef4444; }
.log-item strong { display: block; font-size: 13px; }
.log-item span, .log-item small { color: var(--muted); display: block; margin-top: 3px; }
.log-item small { font-size: 11px; }

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 16px 0;
}

.security-card {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.security-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.password-row input { margin: 0; }

dialog {
  width: min(760px, calc(100vw - 28px));
  height: min(760px, calc(100vh - 40px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, .28);
}

dialog::backdrop { background: rgba(15, 23, 42, .62); backdrop-filter: blur(4px); }

.dialog-header {
  height: 78px;
  padding: 17px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

#previewFrame { width: 100%; height: calc(100% - 78px); border: 0; background: #f1f5f9; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #111827;
  color: #fff;
  padding: 13px 16px;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .25);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 1fr; }
  .side-panel { position: static; }
}

@media (max-width: 680px) {
  .topbar { padding: 16px 18px; min-height: 80px; }
  .status-wrap { max-width: 140px; text-align: right; }
  .layout { padding: 18px 12px 36px; }
  .composer, .side-panel { padding: 18px; border-radius: 14px; }
  .grid.two { grid-template-columns: 1fr; gap: 0; }
  .section-heading, .sendbar { align-items: flex-start; flex-direction: column; }
  .sendbar .button { width: 100%; }
}


.sheet-button {
  background: #0f766e;
  color: #ffffff;
}

.sheet-button:hover {
  background: #115e59;
}

.sheet-note {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: -4px 0 14px;
  padding: 11px 13px;
  border: 1px solid #ccfbf1;
  border-radius: 10px;
  background: #f0fdfa;
  color: #475569;
  font-size: 12px;
}

.sheet-note strong {
  color: #0f766e;
  white-space: nowrap;
}

.field-stack {
  display: grid;
  gap: 5px;
}

.source-badge {
  color: #0f766e;
  font-weight: 750;
  font-size: 10px;
  padding-left: 2px;
}

@media (max-width: 680px) {
  .sheet-note {
    align-items: flex-start;
    flex-direction: column;
  }
}
