:root {
  --bg: #f1f5f4;
  --surface: #ffffff;
  --surface-subtle: #f8faf9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --emerald-900: #064e3b;
  --emerald-800: #075e54;
  --emerald-700: #0f766e;
  --emerald-600: #128c7e;
  --emerald-500: #16a34a;
  --wa-green: #25d366;
  --wa-bg: #efeae2;
  --wa-bubble: #d9fdd3;
  --amber-bg: #fef3c7;
  --amber-text: #b45309;
  --red-bg: #fee2e2;
  --red-text: #b91c1c;
  --blue-bg: #e0f2fe;
  --blue-text: #0369a1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #ecfdf5;
  color: var(--emerald-800);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOPBAR */
.topbar {
  background: linear-gradient(135deg, #064e3b 0%, #075e54 55%, #0f766e 100%);
  color: #ffffff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 2px 10px rgba(6, 78, 59, 0.22);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #25d366 0%, #16a34a 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.4px;
  line-height: 1.15;
}

.brand-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
}

.db-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s;
}

.db-pill:hover {
  background: rgba(255, 255, 255, 0.22);
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.28);
}

.pill-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wa-mode-switch {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 9px;
  padding: 3px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn.active {
  background: #ffffff;
  color: var(--emerald-800);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.tab-reuse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

/* SHEET TABS BAR */
.sheet-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.sheet-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.sheet-tab:hover {
  border-color: var(--emerald-600);
  background: #f0fdf9;
}

.sheet-tab.active {
  background: var(--emerald-800);
  border-color: var(--emerald-800);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(7, 94, 84, 0.22);
}

.tab-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
}

.tab-tag.has-name {
  background: #dcfce7;
  color: #166534;
}

.sheet-tab.active .tab-tag {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.tab-count {
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.82;
}

.schema-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: #f8fafc;
  border: 1px solid #eef2f6;
  border-radius: 8px;
  padding: 6px 12px;
  flex-wrap: wrap;
}

.schema-info strong {
  color: var(--text);
}

/* WORKSPACE SPLIT */
.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 44%) minmax(460px, 56%);
  gap: 18px;
  padding: 16px 20px 24px;
  flex: 1;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.composer-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.panel-desc {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* BUTTONS & INPUTS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-xs {
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.btn-xs:hover {
  background: #f8fafc;
}

.btn-xs-danger {
  color: var(--red-text);
  border-color: #fecaca;
}

.btn-xs-danger:hover {
  background: #fef2f2;
}

.btn-emerald {
  background: var(--emerald-600);
  color: #fff;
}

.btn-emerald:hover {
  background: var(--emerald-800);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-primary-outline {
  background: #25d366;
  color: #052e16;
  font-weight: 700;
}

.btn-primary-outline:hover {
  background: #4ade80;
}

.btn-ghost-danger {
  background: transparent;
  color: var(--red-text);
  border-color: #fecaca;
}

.btn-ghost-danger:hover {
  background: #fef2f2;
}

.btn-link {
  border: none;
  background: none;
  color: var(--emerald-700);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
}

.input-text,
.input-select,
.input-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-text:focus,
.input-select:focus,
.input-textarea:focus,
#messageEditor:focus {
  outline: none;
  border-color: var(--emerald-600);
  box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.14);
}

.template-bar {
  display: flex;
  gap: 6px;
  align-items: center;
}

.template-bar .input-select {
  flex: 1;
}

.template-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.template-name-row label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

/* GREETING CARD */
.greeting-card {
  background: #f0fdf9;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.greeting-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--emerald-900);
}

.hint-badge {
  font-size: 11px;
  background: #dcfce7;
  color: #166534;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.greeting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #a7f3d0;
  background: #ffffff;
  color: var(--emerald-800);
  cursor: pointer;
  transition: all 0.12s;
}

.chip:hover {
  background: var(--emerald-800);
  color: #ffffff;
  border-color: var(--emerald-800);
}

.greeting-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 2px;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

/* EDITOR BOX */
.editor-box {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.format-btns,
.var-btns {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.tool-btn {
  width: 28px;
  height: 26px;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
}

.tool-btn:hover {
  background: #e2e8f0;
}

.var-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--emerald-800);
  cursor: pointer;
}

.var-chip:hover {
  background: #ecfdf5;
  border-color: var(--emerald-600);
}

#messageEditor {
  width: 100%;
  border: none;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 160px;
  display: block;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* LIVE WHATSAPP PREVIEW */
.wa-preview-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #075e54;
  color: #ffffff;
}

.preview-title {
  font-size: 12.5px;
  font-weight: 700;
}

.preview-tabs {
  display: flex;
  gap: 4px;
}

.ptab {
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.ptab.active {
  background: #ffffff;
  color: #075e54;
}

.wa-chat-canvas {
  background-color: var(--wa-bg);
  background-image: radial-gradient(rgba(7, 94, 84, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.wa-recipient-bar {
  align-self: center;
  background: rgba(255, 255, 255, 0.85);
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.wa-bubble {
  align-self: flex-end;
  max-width: 94%;
  background: var(--wa-bubble);
  color: #111b21;
  padding: 9px 12px 6px;
  border-radius: 10px 2px 10px 10px;
  box-shadow: 0 1px 2px rgba(11, 20, 26, 0.13);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.wa-bubble-text {
  white-space: pre-wrap;
}

.wa-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 10.5px;
  color: #667781;
}

.wa-checks {
  color: #53bdeb;
  font-weight: 800;
}

/* RIGHT PANEL: RECIPIENTS */
.recipients-panel {
  display: flex;
  flex-direction: column;
}

.blast-hero {
  padding: 16px;
  background: linear-gradient(180deg, #f8faf9 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.blast-stats-col {
  flex: 1;
  min-width: 240px;
}

.blast-progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.blast-progress-top strong {
  font-size: 15.5px;
  font-weight: 800;
}

.progress-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald-700);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #128c7e 0%, #25d366 100%);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.stat-badges {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.sbadge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sbadge-neutral { background: #f1f5f9; color: #334155; }
.sbadge-pending { background: #e0f2fe; color: #0369a1; }
.sbadge-sent { background: #dcfce7; color: #166534; }
.sbadge-warn { background: #fef3c7; color: #b45309; }

.blast-cta-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.btn-blast-next {
  background: linear-gradient(135deg, #16a34a 0%, #128c7e 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: 11px;
  box-shadow: 0 5px 14px rgba(18, 140, 126, 0.28);
}

.btn-blast-next:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgba(18, 140, 126, 0.35);
}

.blast-sub-actions {
  display: flex;
  gap: 6px;
}

/* FILTER BAR */
.filter-bar {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid #f1f5f9;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 210px;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search-wrap input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--emerald-600);
}

.filter-pills {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 9px;
}

.fpill {
  border: none;
  background: transparent;
  color: #475569;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.fpill.active {
  background: #ffffff;
  color: var(--emerald-800);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.subfilter-bar {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: #fafcfb;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.range-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 600;
}

.input-num {
  width: 64px;
  padding: 4px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
}

/* CONTACTS TABLE */
.table-container {
  overflow-x: auto;
  max-height: 610px;
  overflow-y: auto;
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.contacts-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f8fafc;
  color: #475569;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.contacts-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.1s;
}

.contacts-table tbody tr:hover {
  background: #f8fafc;
}

.contacts-table tbody tr.selected-row {
  background: #ecfdf5;
}

.contacts-table tbody tr.sent-row {
  background: #f6fef9;
}

.contacts-table tbody tr.invalid-row {
  background: #fffbeb;
}

.contacts-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.row-num {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.contact-name {
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.contact-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.no-name-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: #0f766e;
  background: #ccfbf1;
  padding: 2px 7px;
  border-radius: 6px;
}

.dupe-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: #6d28d9;
  background: #ede9fe;
  padding: 1px 6px;
  border-radius: 5px;
}

.phone-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12.5px;
  color: #1e293b;
}

.phone-warn {
  display: inline-block;
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--amber-bg);
  color: var(--amber-text);
  padding: 2px 6px;
  border-radius: 5px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pending { background: #f1f5f9; color: #475569; }
.status-sent { background: #dcfce7; color: #166534; }
.status-invalid { background: #fef3c7; color: #b45309; }

.sent-time {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.action-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.btn-send-wa {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: #25d366;
  color: #052e16;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn-send-wa:hover {
  background: #16a34a;
  color: #ffffff;
}

.btn-send-wa.is-sent {
  background: #e2e8f0;
  color: #334155;
}

.btn-send-wa.is-sent:hover {
  background: #128c7e;
  color: #ffffff;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  font-size: 12.5px;
}

.icon-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}

.empty-cell {
  text-align: center;
  padding: 36px 16px !important;
  color: var(--text-muted);
}

.table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: #fafcfb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-indicator {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.muted-text {
  color: var(--text-muted);
  font-size: 12px;
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.hidden {
  display: none !important;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal-lg { max-width: 680px; }
.modal-sm { max-width: 420px; }

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
}

.modal-close {
  border: none;
  background: #f1f5f9;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  color: #475569;
}

.modal-close:hover {
  background: #e2e8f0;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
}

.info-banner {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
}

.sync-option-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  background: #fafcfb;
}

.sync-option-box h4 {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 800;
}

.steps-list {
  margin: 6px 0 10px;
  padding-left: 18px;
  font-size: 12.5px;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.code-box-wrap {
  position: relative;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

pre#appsScriptCode {
  margin: 0;
  padding: 12px;
  border-radius: 9px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 11.5px;
  overflow-x: auto;
  line-height: 1.45;
}

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

.sync-status {
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
}

.sync-status.ok { background: #dcfce7; color: #166534; }
.sync-status.err { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

.import-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.itab {
  border: 1px solid var(--border);
  background: #f8fafc;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.itab.active {
  background: var(--emerald-800);
  border-color: var(--emerald-800);
  color: #ffffff;
}

.schema-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.sample-preview-wrap {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  background: #f8fafc;
}

.sample-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sample-table-scroll {
  overflow-x: auto;
}

.sample-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.sample-table th,
.sample-table td {
  border: 1px solid var(--border);
  padding: 5px 7px;
  text-align: left;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-table th {
  background: #e2e8f0;
  font-weight: 700;
}

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  animation: slideIn 0.18s ease-out;
}

.toast.success { background: #065f46; }
.toast.warn { background: #b45309; }
.toast.error { background: #991b1b; }

@keyframes slideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* LOGIN OVERLAY (Optional APP_PASSWORD on Vercel) */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: linear-gradient(135deg, #064e3b 0%, #075e54 55%, #0f766e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 390px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.login-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--emerald-900);
}

.login-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.login-error {
  background: var(--red-bg);
  color: var(--red-text);
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .greeting-grid,
  .schema-form-grid {
    grid-template-columns: 1fr;
  }
}
