/* ===== GLOBAL RESET & BASE ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --sidebar-text: #475569;
  --sidebar-text-hover: #0f172a;
  --sidebar-text-active: #4f46e5;
  --sidebar-hover-bg: rgba(79, 70, 229, 0.07);
  --sidebar-active-bg: rgba(79, 70, 229, 0.12);
  --sidebar-border: #e2e8f0;
  --sidebar-label-color: #94a3b8;

  /* === Safe Area Insets (iPhone Notch, Dynamic Island, Android Navigation Bar) === */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);

  /* === Typography === */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", "Courier New", monospace;

  /* === Fluid Type Scale === */
  --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
  --text-sm: clamp(0.8rem, 0.75rem + 0.3vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.825rem + 0.35vw, 0.95rem);
  --text-md: clamp(0.95rem, 0.9rem + 0.4vw, 1.05rem);
  --text-lg: clamp(1.05rem, 0.95rem + 0.6vw, 1.25rem);
  --text-xl: clamp(1.2rem, 1.05rem + 0.8vw, 1.45rem);
  --text-2xl: clamp(1.35rem, 1.15rem + 1.2vw, 1.75rem);
  --text-3xl: clamp(1.6rem, 1.35rem + 1.6vw, 2.25rem);

  /* === Line Heights === */
  --leading-tight: 1.25;
  --leading-snug: 1.4;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  /* === Letter Spacing === */
  --tracking-tight: -0.02em;
  --tracking-normal: 0em;
  --tracking-wide: 0.04em;
  --tracking-widest: 0.1em;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f1f5f9;
  --sidebar-text-active: #ffffff;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(79, 70, 229, 0.25);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-label-color: #64748b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --gray-50: #1e293b;
  --gray-100: #2d3748;
  --gray-200: #3d4a5c;
  --gray-300: #64748b;
  --gray-400: #94a3b8;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --primary-bg: rgba(79, 70, 229, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  background: var(--bg-body);
  color: var(--text-primary);
  transition: var(--transition);
  line-height: var(--leading-normal);
  min-height: 100vh;
  min-height: 100dvh;
  font-weight: 400;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

body.sidebar-open,
body.modal-open {
  overflow: hidden !important;
  touch-action: none;
}

/* ===== GLOBAL TYPOGRAPHY ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

p {
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

code,
pre,
.monospace {
  font-family: var(--font-mono);
}

/* ===== SCROLLBAR — hidden but functional ===== */
/* Chrome, Safari, Edge */
::-webkit-scrollbar {
  width: 0px;
  height: 0px;
  background: transparent;
}
/* Firefox */
* {
  scrollbar-width: none;
}
/* IE / old Edge */
* {
  -ms-overflow-style: none;
}

/* ===== LOGIN / APP VISIBILITY ===== */
/* Sidebar & app-container: SELALU tersembunyi saat belum login */
.app-container {
  display: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* Pastikan sidebar tidak pernah muncul di luar app-container */
.sidebar {
  display: none !important;
}

html.authenticated .sidebar {
  display: flex !important;
}

#login-panel {
  display: flex;
}

html.authenticated #login-panel {
  display: none !important;
}

html.authenticated .app-container {
  display: flex !important;
  opacity: 1;
}

/* ===== LOGIN PANEL ===== */
#login-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg-body);
  z-index: 9999;
  overflow-y: auto;
}

#login-panel .login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem 1.8rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

#login-panel .login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.login-badge {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.login-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  margin-bottom: 0.4rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: var(--leading-relaxed);
  margin-bottom: 1.15rem;
}

.login-input {
  width: 100%;
  padding: 0.72rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 500;
  transition: var(--transition);
  background: var(--bg-body);
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.login-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.login-btn {
  width: 100%;
  padding: 0.72rem;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(79, 70, 229, 0.35);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  background: #fef2f2;
  border: 2px solid #fca5a5;
  color: #991b1b;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  display: none;
}

[data-theme="dark"] .login-error {
  background: #2d1b1b;
  border-color: #7f1d1d;
  color: #fca5a5;
}

/* ===== LAYOUT: SIDEBAR + CONTENT ===== */
.app-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: var(--sidebar-text);
  padding: calc(1.5rem + var(--sat)) 1rem calc(1.5rem + var(--sab))
    calc(1rem + var(--sal));
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-brand .brand-icon {
  font-size: 1.85rem;
}

.sidebar-brand .brand-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: var(--tracking-tight);
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand .brand-badge {
  background: var(--primary-bg);
  font-family: var(--font-sans);
  font-size: 0.58rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  color: var(--sidebar-label-color);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.15rem;
  color: var(--sidebar-text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  touch-action: manipulation;
}

.sidebar-close-btn:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-nav .nav-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--sidebar-label-color);
  padding: 0.75rem 0.75rem 0.5rem;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  touch-action: manipulation;
}

.sidebar-nav .nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}

.sidebar-nav .nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.sidebar-nav .nav-item .nav-icon {
  width: 1.25rem;
  text-align: center;
  font-size: 1rem;
}

.sidebar-nav .nav-item .nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-footer .nav-item {
  color: var(--sidebar-text);
}

.sidebar-footer .nav-item:hover {
  color: var(--sidebar-text-hover);
}

.sidebar-footer .nav-item.danger:hover {
  color: var(--danger);
}

/* Dark Mode Toggle inside Sidebar */
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--sidebar-hover-bg);
  margin-top: 0.5rem;
}

.theme-toggle-wrap span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sidebar-text);
}

.theme-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  background: #334155;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  flex-shrink: 0;
}

.theme-toggle .toggle-dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle.active {
  background: var(--primary);
}

.theme-toggle.active .toggle-dot {
  transform: translateX(22px);
}

/* ===== LOGOUT MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 2rem 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  position: relative;
  transform: translateY(24px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-box.modal-box-large {
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem 2rem;
}

.modal-backdrop.open .modal-box {
  transform: translateY(0) scale(1);
}

/* Template Modal Custom Elements */
.modal-header-custom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.modal-icon-badge-round {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ecfdf5;
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

[data-theme="dark"] .modal-icon-badge-round {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.modal-title-left {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.modal-subtitle-left {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

[data-theme="dark"] .modal-close-btn:hover {
  background: #2d3748;
}

.modal-body-custom {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-subheading {
  display: block;
  font-size: 0.825rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.template-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .template-options-grid {
    grid-template-columns: 1fr;
  }
}

.template-option-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-body);
  cursor: pointer;
  transition: var(--transition);
}

.template-option-card input[type="radio"] {
  position: absolute;
  top: 1rem;
  right: 1rem;
  accent-color: var(--primary);
  width: 1.1rem;
  height: 1.1rem;
}

.template-option-card.active {
  border-color: var(--primary);
  background: var(--primary-bg);
}

[data-theme="dark"] .template-option-card {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .template-option-card.active {
  border-color: #818cf8;
  background: rgba(79, 70, 229, 0.22);
}

.option-card-content {
  padding-right: 1.5rem;
}

.option-card-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
}

.option-icon {
  font-size: 1.1rem;
}

.option-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-primary);
}

.option-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  background: var(--warning);
  color: #1e293b;
  text-transform: uppercase;
}

.option-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
}

.template-preview-box {
  background: var(--gray-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

[data-theme="dark"] .template-preview-box {
  background: #0f172a;
  border-color: #334155;
}

.preview-box-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.preview-box-note {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.template-cols-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 120px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.col-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-primary);
}

[data-theme="dark"] .col-chip {
  background: #1e293b;
  border-color: #475569;
  color: #e2e8f0;
}

.col-chip i {
  color: var(--primary);
  font-size: 0.65rem;
}

[data-theme="dark"] .col-chip i {
  color: #818cf8;
}

.download-btns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 600px) {
  .download-btns-grid {
    grid-template-columns: 1fr;
  }
}

.btn-dl-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.btn-dl-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-dl-card.excel {
  border-color: #10b981;
}

.btn-dl-card.excel .btn-dl-icon {
  background: #ecfdf5;
  color: #10b981;
}

.btn-dl-card.excel:hover {
  background: #f0fdf4;
  border-color: #059669;
}

.btn-dl-card.csv {
  border-color: #0ea5e9;
}

.btn-dl-card.csv .btn-dl-icon {
  background: #f0f9ff;
  color: #0ea5e9;
}

.btn-dl-card.csv:hover {
  background: #f8fafc;
  border-color: #0284c7;
}

[data-theme="dark"] .btn-dl-card {
  background: #1e293b;
}

[data-theme="dark"] .btn-dl-card.excel {
  border-color: #059669;
}

[data-theme="dark"] .btn-dl-card.excel .btn-dl-icon {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

[data-theme="dark"] .btn-dl-card.excel:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
}

[data-theme="dark"] .btn-dl-card.csv {
  border-color: #0284c7;
}

[data-theme="dark"] .btn-dl-card.csv .btn-dl-icon {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
}

[data-theme="dark"] .btn-dl-card.csv:hover {
  background: rgba(14, 165, 233, 0.12);
  border-color: #0ea5e9;
}

.btn-dl-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.btn-dl-text {
  flex: 1;
}

.btn-dl-text strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.btn-dl-text span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.btn-dl-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: var(--gray-100);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

[data-theme="dark"] .btn-dl-badge {
  background: #2d3748;
  color: #cbd5e1;
}

.template-instructions-card {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

[data-theme="dark"] .template-instructions-card {
  background: rgba(245, 158, 11, 0.12);
  border-color: #b45309;
}

.instructions-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #92400e;
  margin-bottom: 0.4rem;
}

[data-theme="dark"] .instructions-header {
  color: #fde68a;
}

.instructions-list {
  padding-left: 1.2rem;
  margin: 0;
  font-size: 0.75rem;
  color: #78350f;
  line-height: 1.5;
}

[data-theme="dark"] .instructions-list {
  color: #cbd5e1;
}

.instructions-list code {
  background: rgba(0, 0, 0, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-primary);
}

[data-theme="dark"] .instructions-list code {
  background: rgba(255, 255, 255, 0.12);
  color: #fde68a;
}

.modal-footer-custom {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.modal-btn.confirm-upload {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.modal-btn.confirm-upload:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.modal-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 1.75rem;
}

[data-theme="dark"] .modal-icon-wrap {
  background: rgba(239, 68, 68, 0.15);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: var(--tracking-tight);
  margin-bottom: 0.5rem;
}

.modal-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
  line-height: var(--leading-relaxed);
  margin-bottom: 1.75rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.modal-btn {
  flex: 1;
  padding: 0.72rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  letter-spacing: 0.01em;
}

.modal-btn.cancel {
  background: var(--gray-100);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-color);
}

.modal-btn.cancel:hover {
  background: var(--gray-200);
  color: var(--text-primary);
}

[data-theme="dark"] .modal-btn.cancel {
  background: #2d3748;
  color: #cbd5e1;
  border-color: #475569;
}

[data-theme="dark"] .modal-btn.cancel:hover {
  background: #3d4a5c;
  color: #f1f5f9;
}

.modal-btn.confirm {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.modal-btn.confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.modal-btn.confirm:active {
  transform: translateY(0);
}

/* ===== MAIN CONTENT ===== */
/* ===== MAIN CONTENT ===== */
.main-content-wrap {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
  width: calc(100% - 260px);
  min-width: 0;
  box-sizing: border-box;
  padding: 1.5rem calc(2rem + var(--sar)) calc(3rem + var(--sab))
    calc(2rem + var(--sal));
  transition: var(--transition);
}

/* ===== HEADER ===== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: calc(0.6rem + var(--sat)) calc(1rem + var(--sar)) 0.6rem
    calc(1rem + var(--sal));
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.88);
  transition: var(--transition);
  width: 100%;
  box-sizing: border-box;
}

[data-theme="dark"] .site-header {
  background: rgba(15, 23, 42, 0.92);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header-left .logo-icon {
  font-size: 1.5rem;
}

.header-left .logo-text {
  font-size: var(--text-lg);
  font-weight: 900;
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-left .logo-badge {
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.55rem;
  font-weight: 800;
  padding: 0.1rem 0.6rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-right .header-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  touch-action: manipulation;
}

.header-right .header-btn:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.header-right .header-btn.logout-btn:hover {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fca5a5;
}

[data-theme="dark"] .header-right .header-btn:hover {
  background: var(--gray-800);
}

[data-theme="dark"] .header-right .header-btn.logout-btn:hover {
  background: #2d1b1b;
  color: #fca5a5;
  border-color: #7f1d1d;
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.15rem;
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: var(--transition);
  touch-action: manipulation;
}

.hamburger-btn:hover {
  background: var(--gray-100);
}

[data-theme="dark"] .hamburger-btn:hover {
  background: var(--gray-800);
}

/* ===== STEP INDICATOR ===== */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  max-width: 700px;
  margin: 1.25rem auto 1.75rem;
  padding: 0.5rem 1rem;
  box-sizing: border-box;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.45;
  transition: var(--transition);
  cursor: default;
  flex-shrink: 0;
}

.step-item.active {
  opacity: 1;
}

.step-item.done {
  opacity: 0.75;
}

.step-bubble {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.step-item.active .step-bubble {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.35);
}

.step-item.done .step-bubble {
  background: var(--success);
  color: white;
}

.step-label {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.step-line {
  flex: 1 1 1rem;
  min-width: 0.5rem;
  max-width: 3.5rem;
  height: 2px;
  background: var(--gray-300);
  margin: 0 0.35rem;
  transition: var(--transition);
}

/* ===== PANELS ===== */
.step-panel {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
}

.step-panel.active {
  display: block;
  animation: fadeInUp 0.4s ease;
}

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

.panel-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.panel-icon-badge {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.panel-header-text h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin: 0;
}

.panel-header-text p {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin: 0.3rem 0 0;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-accent-top {
  border-top: 4px solid var(--primary);
}

.card-accent-yellow {
  border-top-color: var(--warning);
}

.card-accent-blue {
  border-top-color: var(--secondary);
}

.card-accent-green {
  border-top-color: var(--success);
}

.card-accent-red {
  border-top-color: var(--danger);
}

/* ===== FORM ELEMENTS ===== */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  letter-spacing: 0.01em;
  margin-bottom: 0.3rem;
}

/* Universal Input and Textarea Styling (Light & Dark Theme) */
input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
textarea,
select,
.form-group input,
.form-group textarea,
.field-card textarea,
[id^="tv-"] {
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-color);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: var(--transition);
  background: var(--bg-body);
  color: var(--text-primary);
  box-sizing: border-box;
}

input:focus,
textarea:focus,
select:focus,
.form-group input:focus,
.form-group textarea:focus,
.field-card textarea:focus,
[id^="tv-"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

textarea,
.form-group textarea,
.field-card textarea,
[id^="tv-"] {
  resize: vertical;
  min-height: 90px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}

::placeholder,
textarea::placeholder,
input::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .field-card textarea,
[data-theme="dark"] [id^="tv-"] {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] .field-card textarea:focus,
[data-theme="dark"] [id^="tv-"]:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.25);
}

[data-theme="dark"] ::placeholder,
[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] input::placeholder {
  color: #94a3b8;
  opacity: 0.75;
}

.hint-text {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.warning-box {
  background: #fffbeb;
  border: 2px solid #fcd34d;
  border-radius: var(--radius);
  padding: 0.8rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #92400e;
  margin-top: 0.75rem;
}

[data-theme="dark"] .warning-box {
  background: #2d2416;
  border-color: #92400e;
  color: #fcd34d;
}

.status-box {
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  font-weight: 600;
  margin: 1rem 0;
  border: 2px solid transparent;
  display: none;
}

.status-box.loading {
  display: block;
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

.status-box.success {
  display: block;
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.status-box.error {
  display: block;
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

[data-theme="dark"] .status-box.loading {
  background: #1e293b;
  border-color: #4338ca;
  color: #818cf8;
}

[data-theme="dark"] .status-box.success {
  background: #1b2d2b;
  border-color: #065f46;
  color: #6ee7b7;
}

[data-theme="dark"] .status-box.error {
  background: #2d1b1b;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 3px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== BUTTONS ===== */
.btn {
  padding: 0.6rem 1.5rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  font-family: inherit;
}

.btn-large {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--gray-300);
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

.btn-warning {
  background: var(--warning);
  color: #1e293b;
}

.btn-warning:hover {
  background: #d97706;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-outline:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
  transform: none !important;
}

/* ===== METHOD TABS ===== */
.method-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.method-tab {
  padding: 0.5rem 1.2rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--gray-100);
  color: var(--text-secondary);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.method-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.method-tab:hover:not(.active) {
  background: var(--gray-200);
}

.method-tab .tab-badge {
  background: var(--warning);
  color: #1e293b;
  font-size: 0.5rem;
  font-weight: 900;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  margin-left: 0.3rem;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ===== IMPORT CARD & DROP AREA ===== */
.import-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.badge-file-type {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: var(--primary-bg);
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

[data-theme="dark"] .badge-file-type {
  background: rgba(79, 70, 229, 0.25);
  color: #a5b4fc;
}

.btn-template {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
}

.btn-template:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 16px rgba(16, 185, 129, 0.4);
}

.btn-template:active {
  transform: translateY(0);
}

.template-quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  background: var(--gray-50);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

[data-theme="dark"] .template-quick-bar {
  background: #0f172a;
  border-color: #334155;
}

.template-quick-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.template-quick-buttons {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-quick-dl {
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-quick-dl.excel {
  color: #059669;
  border-color: #6ee7b7;
}

.btn-quick-dl.excel:hover {
  background: #ecfdf5;
  border-color: #10b981;
  transform: translateY(-1px);
}

.btn-quick-dl.csv {
  color: #0284c7;
  border-color: #7dd3fc;
}

.btn-quick-dl.csv:hover {
  background: #f0f9ff;
  border-color: #0ea5e9;
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-quick-dl {
  background: #1e293b;
}

[data-theme="dark"] .btn-quick-dl.excel {
  color: #34d399;
  border-color: #059669;
}

[data-theme="dark"] .btn-quick-dl.excel:hover {
  background: rgba(16, 185, 129, 0.15);
}

[data-theme="dark"] .btn-quick-dl.csv {
  color: #38bdf8;
  border-color: #0284c7;
}

[data-theme="dark"] .btn-quick-dl.csv:hover {
  background: rgba(14, 165, 233, 0.15);
}

/* ===== DROP AREA ===== */
.drop-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.drop-area:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.drop-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
  transform: scale(1.01);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

[data-theme="dark"] .drop-area {
  background: #0f172a;
  border-color: #475569;
}

[data-theme="dark"] .drop-area:hover {
  border-color: #818cf8;
  background: rgba(79, 70, 229, 0.15);
}

[data-theme="dark"] .drop-area.drag-over {
  border-color: #818cf8;
  background: rgba(79, 70, 229, 0.25);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.3);
}

.drop-area-icon {
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

[data-theme="dark"] .drop-area-icon {
  color: #818cf8;
}

.drop-area-action-btn {
  margin-top: 0.5rem;
}

/* Loaded State in Drop Area */
.drop-area.loaded {
  border-style: solid;
  border-color: #10b981;
  background: #ecfdf5;
  cursor: default;
  padding: 1rem 1.25rem;
  text-align: left;
  align-items: stretch;
}

[data-theme="dark"] .drop-area.loaded {
  border-color: #059669;
  background: rgba(16, 185, 129, 0.12);
}

.loaded-file-card {
  width: 100%;
}

.loaded-file-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.loaded-file-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .loaded-file-icon {
  background: #1e293b;
}

.icon-excel {
  color: #10b981;
}

.icon-csv {
  color: #0ea5e9;
}

.loaded-file-meta {
  flex: 1;
  min-width: 0;
}

.loaded-file-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-success-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: #10b981;
  color: white;
  flex-shrink: 0;
}

.loaded-file-sub {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.file-stat-badge {
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.05);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

[data-theme="dark"] .file-stat-badge {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.loaded-file-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-loaded-action {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-loaded-action.danger {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

.btn-loaded-action.danger:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

[data-theme="dark"] .btn-loaded-action.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: #991b1b;
}

[data-theme="dark"] .btn-loaded-action.danger:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}

.btn-loaded-action.outline {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-loaded-action.outline:hover {
  background: var(--gray-100);
}

[data-theme="dark"] .btn-loaded-action.outline {
  background: #1e293b;
  border-color: #475569;
  color: #f1f5f9;
}

[data-theme="dark"] .btn-loaded-action.outline:hover {
  background: #2d3748;
}

.loaded-file-columns {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(16, 185, 129, 0.25);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

[data-theme="dark"] .loaded-file-columns {
  border-top-color: rgba(16, 185, 129, 0.18);
}

.loaded-col-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-right: 0.25rem;
}

.col-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

[data-theme="dark"] .col-pill {
  background: #1e293b;
  border-color: #059669;
  color: #6ee7b7;
}

.col-pill.more {
  background: #e2e8f0;
  border-color: transparent;
  color: #475569;
}

[data-theme="dark"] .col-pill.more {
  background: #334155;
  color: #cbd5e1;
}

/* Status Notice Box */
.import-status-box {
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.75rem;
  border: 1.5px solid transparent;
}

.import-status-box.success {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.import-status-box.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.import-status-box.info {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

[data-theme="dark"] .import-status-box.success {
  background: rgba(16, 185, 129, 0.15);
  border-color: #059669;
  color: #6ee7b7;
}

[data-theme="dark"] .import-status-box.error {
  background: rgba(239, 68, 68, 0.18);
  border-color: #b91c1c;
  color: #fca5a5;
}

[data-theme="dark"] .import-status-box.info {
  background: rgba(79, 70, 229, 0.2);
  border-color: #6366f1;
  color: #a5b4fc;
}

.import-footer-hint {
  margin-top: 0.65rem;
}

/* ===== CONFIG GRID ===== */
.config-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.counter-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.counter-btn {
  background: var(--gray-100);
  border: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 9999px;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
}

.counter-btn:hover {
  background: var(--gray-300);
}

.counter-btn:active {
  transform: scale(0.95);
}

#user-count {
  width: 5rem;
  text-align: center;
  font-weight: 900;
  font-size: 1.1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.3rem 0;
  background: var(--bg-body);
  color: var(--text-primary);
}

/* ===== FIELD CONFIG ===== */
.fields-config-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  transition: var(--transition);
}

.field-card:hover {
  box-shadow: var(--shadow-md);
}

.field-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.field-num-badge {
  background: var(--gray-100);
  font-weight: 900;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.field-card-meta {
  flex: 1;
}

.field-card-title {
  font-weight: 800;
  color: var(--text-primary);
}

.field-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field-type-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.type-tag {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.15rem 0.7rem;
  border-radius: 9999px;
  text-transform: uppercase;
  background: var(--gray-100);
  color: var(--text-secondary);
}

.tag-text {
  background: #eef2ff;
  color: #4338ca;
}

.tag-radio {
  background: #fffbeb;
  color: #92400e;
}

.tag-checkbox {
  background: #e0f2fe;
  color: #0369a1;
}

.tag-dropdown {
  background: #f3e8ff;
  color: #6b21a8;
}

.tag-scale {
  background: #d1fae5;
  color: #065f46;
}

.tag-rating {
  background: #fce7f3;
  color: #9d174d;
}

.tag-date {
  background: #e0e7ff;
  color: #3730a3;
}

.tag-time {
  background: #fef9c3;
  color: #854d0e;
}

.tag-file {
  background: #fef2f2;
  color: #991b1b;
}

.tag-required {
  background: #fef2f2;
  color: #dc2626;
}

[data-theme="dark"] .tag-text {
  background: #1e293b;
  color: #818cf8;
}
[data-theme="dark"] .tag-radio {
  background: #2d2416;
  color: #fcd34d;
}
[data-theme="dark"] .tag-checkbox {
  background: #1b2d3d;
  color: #7dd3fc;
}
[data-theme="dark"] .tag-dropdown {
  background: #2d1b3d;
  color: #c4b5fd;
}
[data-theme="dark"] .tag-scale {
  background: #1b2d2b;
  color: #6ee7b7;
}
[data-theme="dark"] .tag-rating {
  background: #2d1b2b;
  color: #f9a8d4;
}
[data-theme="dark"] .tag-date {
  background: #1b1b3d;
  color: #a5b4fc;
}
[data-theme="dark"] .tag-time {
  background: #2d2416;
  color: #fde047;
}
[data-theme="dark"] .tag-file {
  background: #2d1b1b;
  color: #fca5a5;
}
[data-theme="dark"] .tag-required {
  background: #2d1b1b;
  color: #fca5a5;
}

/* ===== TABS INSIDE FIELD ===== */
.tab-row {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.tab-btn {
  background: var(--gray-100);
  border: none;
  padding: 0.3rem 1rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.tab-btn:hover:not(.active) {
  background: var(--gray-200);
}

/* ===== DISTRIBUTION TABLE ===== */
.dist-table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0;
}

.dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.dist-table th {
  background: var(--gray-50);
  text-align: left;
  font-weight: 800;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-secondary);
}

.dist-table td {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.dist-table input[type="number"] {
  width: 4.5rem;
  padding: 0.2rem 0.4rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-weight: 700;
  text-align: center;
  background: var(--bg-body);
  color: var(--text-primary);
}

.dist-table input:focus {
  border-color: var(--primary);
  outline: none;
}

.dist-total-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.progress-mini {
  flex: 1;
  height: 0.5rem;
  background: var(--gray-200);
  border-radius: 9999px;
  overflow: hidden;
  min-width: 60px;
}

.progress-mini-fill {
  height: 100%;
  background: var(--success);
  border-radius: 9999px;
  transition: var(--transition);
}

.dist-total-bar.over .progress-mini-fill {
  background: var(--danger);
}

.dist-total-bar.exact .progress-mini-fill {
  background: var(--warning);
}

.scale-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.5rem;
  margin: 0.5rem 0;
}

.scale-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.scale-label {
  font-weight: 800;
  min-width: 1.8rem;
  color: var(--text-primary);
}

.scale-item input[type="number"] {
  width: 4rem;
  padding: 0.2rem 0.4rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-weight: 700;
  text-align: center;
  background: var(--bg-body);
  color: var(--text-primary);
}

.col-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.col-btn {
  background: var(--gray-100);
  border: none;
  padding: 0.2rem 0.8rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-family: inherit;
}

.col-btn.active {
  background: var(--primary);
  color: white;
}

.col-btn:hover:not(.active) {
  background: var(--gray-200);
}

/* ===== DELAY ===== */
.delay-radio-group {
  display: flex;
  gap: 0.8rem 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.delay-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  transition: var(--transition);
  user-select: none;
}

.delay-radio-label:hover {
  border-color: var(--primary-light);
  background: var(--gray-50);
}

[data-theme="dark"] .delay-radio-label:hover {
  background: rgba(255, 255, 255, 0.05);
}

.delay-radio-label:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}

[data-theme="dark"] .delay-radio-label:has(input[type="radio"]:checked) {
  background: rgba(79, 70, 229, 0.2);
  border-color: var(--primary-light);
  color: #ffffff;
}

.delay-radio-label input[type="radio"] {
  accent-color: var(--primary);
  cursor: pointer;
}

.delay-radio-dynamic {
  position: relative;
  border-color: rgba(79, 70, 229, 0.4);
}

/* Dynamic Delay Info Card (PRD 4.1) */
.delay-dynamic-box {
  margin-top: 0.8rem;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.06) 0%,
    rgba(14, 165, 233, 0.06) 100%
  );
  border: 1.5px solid rgba(79, 70, 229, 0.25);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: fadeIn 0.25s ease-out;
}

[data-theme="dark"] .delay-dynamic-box {
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.15) 0%,
    rgba(14, 165, 233, 0.1) 100%
  );
  border-color: rgba(129, 140, 248, 0.35);
}

.dynamic-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dynamic-badge-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--primary);
  font-weight: 800;
}

[data-theme="dark"] .dynamic-badge-title {
  color: var(--primary-light);
}

.dynamic-pulsing-badge {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--primary);
  box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7);
  animation: pulse-ring 1.8s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(79, 70, 229, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
  }
}

.dynamic-badge-pill {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
}

.dynamic-helper-quote {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-primary);
  font-weight: 600;
  font-style: italic;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.75);
  border-left: 3.5px solid var(--primary);
  border-radius: 6px;
}

[data-theme="dark"] .dynamic-helper-quote {
  background: rgba(15, 23, 42, 0.65);
}

.dynamic-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.6rem;
}

.dynamic-spec-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: var(--shadow-sm);
}

.spec-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.spec-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.delay-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  margin-top: 0.5rem;
}

.delay-inputs label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.delay-inputs input[type="number"] {
  width: 4.5rem;
  padding: 0.2rem 0.4rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-weight: 700;
  text-align: center;
  background: var(--bg-body);
  color: var(--text-primary);
}

/* Live Delay Countdown Indicator Card (PRD Section 6.1) */
.exec-delay-card {
  margin-bottom: 1.5rem;
  padding: 1.15rem 1.4rem;
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.08) 0%,
    rgba(245, 158, 11, 0.1) 100%
  );
  border: 2px solid var(--warning);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 20px -4px rgba(245, 158, 11, 0.25);
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

[data-theme="dark"] .exec-delay-card {
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.2) 0%,
    rgba(245, 158, 11, 0.18) 100%
  );
  border-color: var(--warning);
}

.exec-delay-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.exec-delay-status {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.exec-delay-beacon {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.beacon-pulse {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--warning);
  opacity: 0.4;
  animation: pulse-ring 1.5s infinite;
}

.beacon-core {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 10px var(--warning);
}

.exec-delay-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--warning);
  margin-bottom: 0.2rem;
}

.exec-delay-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.35;
}

.exec-delay-timer-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.exec-delay-timer-val {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--warning);
  line-height: 1;
  letter-spacing: -0.02em;
}

.exec-delay-timer-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.exec-delay-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

[data-theme="dark"] .exec-delay-progress-bar {
  background: rgba(255, 255, 255, 0.1);
}

.exec-delay-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--warning), var(--primary));
  border-radius: 999px;
  transition: width 0.05s linear;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Human-like timing badges and rhythm indicators */
.rhythm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.rhythm-badge-flow {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.rhythm-badge-reading {
  background: rgba(14, 165, 233, 0.12);
  color: var(--secondary);
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.rhythm-badge-inspection {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Persisted Queue Alert Banner (Pause & Resume State Persistence) */
.persisted-queue-banner {
  margin-bottom: 1.5rem;
  padding: 1rem 1.35rem;
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.1) 0%,
    rgba(79, 70, 229, 0.08) 100%
  );
  border: 1.5px solid var(--warning);
  border-radius: var(--radius-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
  animation: slideDown 0.3s ease-out;
}

[data-theme="dark"] .persisted-queue-banner {
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.18) 0%,
    rgba(79, 70, 229, 0.15) 100%
  );
  border-color: var(--warning);
}

.persisted-banner-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.persisted-banner-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.persisted-banner-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.persisted-banner-text p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0;
}

.persisted-banner-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Action Bar & Buttons */
.exec-action-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.25rem;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius);
}

/* ===== STEP ACTIONS ===== */
.step-actions {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* ===== TABLE ===== */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.table-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table-scroll th {
  background: var(--gray-50);
  font-weight: 800;
  padding: 0.5rem 0.8rem;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  color: var(--text-secondary);
}

.table-scroll td {
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.table-scroll tr:last-child td {
  border-bottom: none;
}

.log-row-success td:first-child {
  color: var(--success);
}
.log-row-error td:first-child {
  color: var(--danger);
}
.log-row-running td:first-child {
  color: var(--warning);
}
.log-row-pending td:first-child {
  color: var(--text-muted);
}
.log-row-stopped td:first-child {
  color: var(--gray-500);
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 0.8rem;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.s-total .stat-number {
  color: var(--text-primary);
}
.s-success .stat-number {
  color: var(--success);
}
.s-error .stat-number {
  color: var(--danger);
}
.s-pending .stat-number {
  color: var(--warning);
}

/* ===== PROGRESS ===== */
.progress-wrap {
  height: 0.8rem;
  background: var(--gray-200);
  border-radius: 9999px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 9999px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-text {
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.exec-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

/* ============================================================
   RESPONSIVE DESIGN & MULTI-DEVICE OPTIMIZATIONS
   ============================================================ */

/* Large Tablets & Small Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(85vw, 300px);
    padding-top: calc(1.5rem + var(--sat));
    padding-bottom: calc(1.5rem + var(--sab));
    padding-left: calc(1rem + var(--sal));
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: flex;
  }

  .main-content-wrap {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    padding: 1.25rem calc(1.25rem + var(--sar)) calc(3rem + var(--sab))
      calc(1.25rem + var(--sal));
  }

  .hamburger-btn {
    display: flex;
  }

  .header-inner {
    padding: 0 1rem;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Tablets Portrait (<= 768px) */
@media (max-width: 768px) {
  .config-top-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .step-indicator {
    padding: 0.5rem 0.5rem;
    gap: 0.25rem;
  }

  .step-line {
    flex: 1 1 0.75rem;
    min-width: 0.5rem;
    max-width: 2rem;
  }

  .step-label {
    font-size: var(--text-xs);
  }

  .step-bubble {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 0.85rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
  }

  .panel-header-text h2 {
    font-size: var(--text-xl);
  }

  .login-title {
    font-size: var(--text-2xl);
  }

  #login-panel .login-card {
    padding: 1.75rem 1.25rem;
    margin: 1rem;
    max-width: 100%;
  }

  .field-card {
    padding: 1.15rem 1rem;
  }

  .step-actions {
    flex-direction: column-reverse;
    gap: 0.75rem;
  }

  .step-actions .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .method-tabs {
    flex-direction: column;
    gap: 0.5rem;
  }

  .method-tab {
    width: 100%;
    justify-content: center;
  }

  .import-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .btn-template {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .template-quick-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .template-quick-buttons {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .btn-quick-dl {
    justify-content: center;
    min-height: 40px;
  }

  .modal-box {
    padding: 1.5rem 1.25rem;
    max-width: 95vw;
  }

  .modal-box-large {
    padding: 1.25rem 1rem;
  }

  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.6rem;
  }

  .modal-actions .modal-btn {
    width: 100%;
    min-height: 44px;
  }

  .modal-footer-custom {
    flex-direction: column-reverse;
    gap: 0.6rem;
  }

  .modal-footer-custom .modal-btn {
    width: 100%;
    min-height: 44px;
  }

  .download-btns-grid {
    grid-template-columns: 1fr;
  }

  .template-options-grid {
    grid-template-columns: 1fr;
  }

  .loaded-file-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .loaded-file-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .btn-loaded-action {
    justify-content: center;
    min-height: 40px;
  }

  .delay-radio-group {
    flex-direction: column;
    gap: 0.5rem;
  }

  .delay-inputs {
    flex-direction: column;
    gap: 0.75rem;
  }

  .delay-inputs label {
    flex-wrap: wrap;
    justify-content: space-between;
  }
}

/* Mobile Phones (<= 480px, iPhone SE, Galaxy, Xiaomi, Oppo, etc.) */
@media (max-width: 480px) {
  /* Prevent iOS Safari auto-zoom on input focus by keeping font-size >= 16px */
  input[type="text"],
  input[type="url"],
  input[type="password"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px !important;
  }

  .header-left .logo-text {
    font-size: 1.05rem;
  }

  .header-left .logo-badge {
    display: none;
  }

  .header-right .header-btn span {
    display: none;
  }

  /* Compact Step Indicator for Small Phone Screens */
  .step-indicator {
    padding: 0.4rem 0.2rem;
    gap: 0.2rem;
  }

  .step-item:not(.active) .step-label {
    display: none;
  }

  .step-item.active .step-label {
    font-size: 0.7rem;
    display: block;
  }

  .step-bubble {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 0.8rem;
  }

  .step-line {
    flex: 1 1 0.4rem;
    min-width: 0.4rem;
    max-width: 1.5rem;
    margin: 0 0.15rem;
  }

  .card {
    padding: 1rem 0.85rem;
    border-radius: var(--radius);
  }

  .field-card {
    padding: 1rem 0.85rem;
  }

  .field-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .field-num-badge {
    display: inline-flex;
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.75rem;
  }

  .counter-wrap {
    justify-content: center;
    gap: 0.35rem;
  }

  .counter-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  #user-count {
    width: 4.5rem;
  }

  .template-quick-buttons {
    grid-template-columns: 1fr;
  }

  .loaded-file-actions {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .stat-number {
    font-size: 1.4rem;
  }

  .stat-card {
    padding: 0.75rem 0.5rem;
  }

  .dist-total-bar {
    font-size: 0.75rem;
  }

  .modal-box {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-lg);
  }

  .modal-box-large {
    padding: 1rem 0.85rem;
  }
}

/* Ultra-Wide Monitors & 4K Displays (>= 1600px) */
@media (min-width: 1600px) {
  .main-content {
    max-width: 1400px;
    margin: 0 auto;
  }

  .site-header .header-inner {
    max-width: 1500px;
  }
}

/* Touch Device Ergonomics */
@media (pointer: coarse) {
  .btn,
  .counter-btn,
  .nav-item,
  .header-btn,
  .modal-close-btn,
  .method-tab {
    cursor: default;
  }

  .btn:hover,
  .counter-btn:hover {
    transform: none !important;
  }
}

/* ===== OVERLAY ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block;
}

@media (min-width: 1025px) {
  .sidebar-overlay {
    display: none !important;
  }
}
