:root {
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #e04f0d;
  --accent-hover: #c2420a;
  --border-color: #e2e8f0;
  --border-focus: #cbd5e1;
  --danger: #ef4444;
  --success: #10b981;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --ring: 0 0 0 3px rgba(224, 79, 13, 0.15);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  background: var(--bg-color);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Scroll is handled per-pane */
}

/* --- Header & Tabs --- */

.epwp-header {
  padding: 16px 16px 0;
  background: var(--surface-color);
}

.epwp-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.epwp-header p {
  margin: 2px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.epwp-tabs {
  display: flex;
  padding: 0 16px;
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
}

.epwp-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.epwp-tab:hover {
  color: var(--text-main);
}

.epwp-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Main Layout --- */

.epwp-main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.epwp-pane {
  display: none;
  flex: 1;
  flex-direction: column;
  height: 100%;
}

.epwp-pane-scan {
  position: relative;
}

.epwp-pane.is-active {
  display: flex;
}

.epwp-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.epwp-scan-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .26s ease, visibility 0s linear .26s;
}

.epwp-scan-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .26s ease;
}

.epwp-scan-overlay-logo {
  width: min(72%, 420px);
  min-width: 220px;
  max-width: 520px;
  aspect-ratio: 4 / 1;
}

.epwp-scan-overlay-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Cards & Forms --- */

.epwp-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.epwp-card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.muted-inline {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-color);
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder, textarea::placeholder {
  color: #94a3b8;
}

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

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.epwp-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

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

.epwp-form-grid .full {
  grid-column: 1 / -1;
}

/* --- Accordions --- */

.epwp-accordion {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.epwp-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.epwp-accordion summary::-webkit-details-marker {
  display: none;
}

.epwp-accordion summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1;
}

.epwp-accordion[open] summary::after {
  content: "−";
}

.epwp-accordion[open] summary {
  border-bottom: 1px solid var(--border-color);
}

.epwp-accordion-content {
  padding: 16px;
  background: #fafcff;
}

/* --- Toggles (replaces checkboxes) --- */

.epwp-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.epwp-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}

.epwp-toggle-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

.epwp-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.epwp-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.epwp-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 20px;
}

.epwp-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.epwp-switch input:checked + .epwp-slider {
  background-color: var(--accent);
}

.epwp-switch input:checked + .epwp-slider:before {
  transform: translateX(16px);
}

/* --- Buttons & Actions --- */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  background: var(--surface-color);
  color: var(--text-main);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.secondary {
  background: #f1f5f9;
  border-color: transparent;
}

button.secondary:hover {
  background: #e2e8f0;
}

button.text-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 12px;
}

button.text-link:hover {
  color: var(--text-main);
  text-decoration: underline;
}

button.text-danger {
  color: var(--danger);
}

button.text-danger:hover {
  background: #fee2e2;
  color: #b91c1c;
}

button.full-width {
  width: 100%;
}

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

/* --- Sticky Footers --- */

.epwp-sticky-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface-color);
  padding: 16px;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.03);
  z-index: 10;
}

.epwp-primary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.epwp-actions-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.epwp-secondary-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Status & Test Indicators --- */

.status-text {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.epwp-test-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.epwp-test-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-color);
}

.epwp-test-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.epwp-test-status[data-state="success"] .epwp-test-dot { background: var(--success); }
.epwp-test-status[data-state="error"] .epwp-test-dot { background: var(--danger); }

.epwp-test-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Logs Pane --- */

.epwp-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.epwp-log-header h2 {
  margin: 0;
  font-size: 14px;
}

.epwp-badge {
  background: var(--text-main);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.epwp-logs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.epwp-log-item {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  border-left: 4px solid #cbd5e1;
}

/* Targets the parent card based on the badge class created by JS */
.epwp-log-item:has(.error) { border-left-color: var(--danger); }
.epwp-log-item:has(.warn) { border-left-color: #f59e0b; }
.epwp-log-item:has(.info) { border-left-color: #3b82f6; }

.epwp-log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.epwp-log-level {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.epwp-log-level.info { background: #eff6ff; color: #1d4ed8; }
.epwp-log-level.warn { background: #fef3c7; color: #b45309; }
.epwp-log-level.error { background: #fef2f2; color: #b91c1c; }

.epwp-log-time {
  font-size: 11px;
  color: var(--text-muted);
}

.epwp-log-message {
  margin: 0;
  font-size: 12px;
  color: var(--text-main);
  word-break: break-word;
}

/* --- Help Pane --- */

.empty-state {
  text-align: center;
  padding: 32px 16px;
}

.icon-wrapper {
  color: var(--accent);
  margin-bottom: 16px;
}

.epwp-help-list {
  text-align: left;
  margin: 16px 0 24px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.epwp-help-list li { margin-bottom: 8px; }

.epwp-help-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.epwp-help-links a {
  display: block;
  padding: 12px;
  background: var(--bg-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
}

.epwp-help-links a:hover {
  background: #e2e8f0;
}

/* --- Bulk Import --- */

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

.epwp-custom-actions {
  margin-bottom: 10px;
}

.epwp-dynamic-fields {
  display: grid;
  gap: 10px;
}

.epwp-dynamic-empty {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  background: #fff;
}

.epwp-bulk-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.epwp-bulk-actions button:first-child {
  grid-column: 1 / -1;
}

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

.epwp-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f97316);
  transition: width .22s ease;
}

.epwp-bulk-current-url {
  margin: 0 0 10px;
  font-size: 11px;
  color: #475569;
  word-break: break-word;
}

.epwp-bulk-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.epwp-bulk-result {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  background: #fff;
}

.epwp-bulk-result-success {
  border-left: 4px solid var(--success);
}

.epwp-bulk-result-error {
  border-left: 4px solid var(--danger);
}

.epwp-bulk-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.epwp-bulk-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1f2937;
}

.epwp-bulk-time {
  font-size: 10px;
  color: #64748b;
}

.epwp-bulk-url {
  margin: 0 0 4px;
  font-size: 11px;
  color: #334155;
  word-break: break-all;
}

.epwp-bulk-message {
  margin: 0;
  font-size: 12px;
  color: #0f172a;
}

.epwp-bulk-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.epwp-bulk-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* --- Import Notify Modal --- */

.epwp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 999;
}

.epwp-modal-backdrop.is-open {
  display: flex;
}

.epwp-modal {
  width: min(100%, 420px);
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 16px;
}

.epwp-modal h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.epwp-modal p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.epwp-modal .epwp-modal-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

.epwp-modal .epwp-modal-checkbox input[type="checkbox"] {
  margin: 0;
}

.epwp-modal-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Toasts --- */

.epwp-toast-stack {
  position: fixed;
  right: 14px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(320px, calc(100vw - 20px));
  z-index: 1200;
  pointer-events: none;
}

.epwp-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  border: 1px solid #dbe1ea;
  border-left-width: 4px;
  border-radius: 10px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
  padding: 10px 11px;
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}

.epwp-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.epwp-toast.is-success {
  border-left-color: var(--success);
}

.epwp-toast.is-error {
  border-left-color: var(--danger);
}

.epwp-toast.is-info {
  border-left-color: #3b82f6;
}

.epwp-toast-icon {
  font-size: 14px;
  line-height: 1;
  margin-top: 1px;
}

.epwp-toast-message {
  margin: 0;
  word-break: break-word;
}
