* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #1f2937;
  background: #EEF0FF;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

[hidden] { display: none !important; }

/* --- Login screen --- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #EEF0FF;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.15);
  padding: 40px 48px;
  text-align: center;
}
.login-title { margin: 0 0 4px; font-size: 24px; color: #4F46E5; }
.login-subtitle { margin: 0 0 20px; color: #6b7280; font-size: 13px; }
.login-error {
  margin-top: 14px;
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
}

/* --- App shell / toolbar --- */

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

.toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  padding: 8px 16px;
  z-index: 20;
}
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar-row-presets { margin-top: 6px; }
.toolbar-spacer { flex: 1; }

.rows-count-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  color: #6b7280;
  background: #f9fafb;
  white-space: nowrap;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
  margin-left: 8px;
  white-space: nowrap;
}
.btn-link {
  background: none;
  border: none;
  color: #4F46E5;
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
}

/* --- Buttons --- */

.btn {
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  height: 32px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-outline { background: #fff; border-color: #e5e7eb; color: #374151; }
.btn-outline:hover { background: #f9fafb; }
.btn-primary { background: #4F46E5; color: #fff; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-amber { background: #F59E0B; color: #fff; height: 24px; padding: 2px 8px; }
.btn-violet { background: #EDE9FE; color: #5B21B6; border-color: #C4B5FD; }
.btn-green { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
.btn-danger-outline { background: #fff; color: #dc2626; border-color: #fca5a5; }
.btn-danger-outline:hover { background: #fef2f2; }
.btn-danger-solid { background: #dc2626; color: #fff; }
.btn-green-solid { background: #059669; color: #fff; }
.btn-pink-solid { background: #DB2777; color: #fff; }
.btn-purple-solid { background: #7C3AED; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-plain {
  background: none; border: none; color: #9ca3af; font-size: 16px;
  line-height: 1; padding: 0 4px;
}
.btn-plain:hover { color: #4b5563; }

.btn-preset { color: #fff; font-weight: 600; padding: 6px 16px; }
.btn-preset-purple { background: #7C3AED; }
.btn-preset-green { background: #059669; }
.btn-preset-pink { background: #DB2777; }
.btn-preset-blue { background: #2563EB; }

/* --- Quick create --- */

.quick-create {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 4px 8px; background: #fff; height: 32px;
}
.quick-create-icon { color: #f59e0b; }
.quick-create-select { border: none; background: transparent; font-size: 12px; font-weight: 500; outline: none; }
.quick-create-date { font-size: 12px; border: 1px solid #e5e7eb; border-radius: 4px; padding: 2px 4px; }

/* --- Table --- */

.table-wrap { flex: 1; overflow: auto; padding: 96px 24px 24px; background: #a78bfa; }
.table-scroll {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
table { border-collapse: collapse; font-size: 12px; width: max-content; min-width: 100%; }

thead tr { background: #EEF0FF; }
th {
  text-align: left; padding: 10px 8px; font-weight: 600;
  white-space: nowrap; border-right: 1px solid #C7D2FE; border-bottom: 2px solid #C7D2FE;
  color: #4338ca;
}
th:last-child { border-right: none; }
.col-select { width: 44px; }

td.cell {
  padding: 6px 8px;
  border-right: 1px solid #f3f4f6;
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
td:last-child.cell { border-right: none; }

.promo-row { transition: background-color 0.1s; }
.promo-row.selected { background-color: #EEF2FF !important; }
.promo-row.dragging { opacity: 0.4; }

.select-drag-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 2px; }
.drag-handle { cursor: grab; color: #d1d5db; font-size: 14px; user-select: none; }
.drag-handle:active { cursor: grabbing; }

.sticky-col { position: sticky; left: 44px; z-index: 5; }

.cell-input {
  width: 100%; background: transparent; border: 1px solid transparent;
  border-radius: 4px; padding: 3px 4px; font-size: 12px;
  outline: none; color: #1f2937;
}
.cell-input:focus { border-color: #818cf8; background: rgba(99, 102, 241, 0.06); }
.cell-input::placeholder { color: #d1d5db; }
.cell-input.right { text-align: right; }
.cell-input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.cell-input.uppercase { text-transform: uppercase; }
.cell-input.disabled { opacity: 0.4; cursor: not-allowed; }
textarea.cell-input { resize: none; min-height: 28px; white-space: pre-wrap; word-wrap: break-word; }

/* Chrome/Edge paint their own opaque control chrome on date/datetime-local
   inputs regardless of `background: transparent` on the input itself --
   color-scheme tells the native widget to render as a light control instead
   of falling back to a boxy default, and the picker-indicator needs its own
   transparent background since it's a separate sub-element. */
input.cell-input[type="datetime-local"],
input.cell-input[type="date"] {
  color-scheme: light;
}
input.cell-input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input.cell-input[type="date"]::-webkit-calendar-picker-indicator {
  background: transparent;
  padding: 0;
}

.row-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  background: none; border: none; color: #9ca3af;
  width: 24px; height: 24px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn svg { display: block; }
.icon-btn:hover { color: #4f46e5; background: #eef2ff; }
.icon-btn-danger { color: #f87171; }
.icon-btn-danger:hover { color: #dc2626; background: #fef2f2; }
.icon-btn-emerald { color: #34d399; }
.icon-btn-emerald:hover { color: #059669; background: #ecfdf5; }
.icon-btn.copied { color: #10b981; }

/* --- Modals --- */

dialog.modal {
  border: none; border-radius: 14px; padding: 24px;
  max-width: 420px; width: 90vw;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
dialog.modal::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog.modal h2 { margin: 0 0 14px; font-size: 16px; color: #111827; }
.modal-title-danger { color: #dc2626; }
.modal-label { display: block; font-size: 12px; font-weight: 500; color: #374151; margin-bottom: 4px; }
.modal-input { width: 100%; padding: 6px 8px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; }
.modal-help { font-size: 11px; color: #6b7280; margin-top: 12px; line-height: 1.5; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.load-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 12px;
  font-size: 13px;
}

.duplicate-code-list { list-style: none; padding: 0; margin: 12px 0; max-height: 200px; overflow-y: auto; }
.duplicate-code-item {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; background: #fef2f2; border: 1px solid #fecaca;
  color: #b91c1c; border-radius: 6px; padding: 4px 10px; margin-bottom: 4px;
}
