/* ═══════════════════════════════════════════════════════════
   ĐKKD Agent — Professional Design System
   Calm palette + Classical serif typography
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────── */
:root {
  /* Calm off-white palette */
  --bg-primary:     #F7F5F1;
  --bg-surface:     #FFFFFF;
  --bg-hover:       rgba(60, 90, 120, 0.04);
  --border:         #E7E3DA;
  --border-light:   #F0EDE6;

  /* Typography colors */
  --text-primary:   #1E2227;
  --text-secondary: #6B7077;
  --text-muted:     #9CA3AF;

  /* Muted slate-blue accent */
  --accent:         #3C5A78;
  --accent-hover:   #2E4760;
  --accent-light:   rgba(60, 90, 120, 0.08);
  --accent-border:  rgba(60, 90, 120, 0.15);

  /* Status colors */
  --success:        #16A34A;
  --success-light:  #DCFCE7;
  --error:          #DC2626;
  --error-light:    #FEE2E2;
  --warning:        #F59E0B;
  --warning-light:  #FEF3C7;

  /* Spacing & Layout */
  --radius:         8px;
  --radius-sm:      6px;
  --radius-lg:      12px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.08);

  --sidebar-w:      300px;
  --topbar-h:       64px;
  --form-panel-w:   400px;

  --transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Fonts ──────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App layout ─────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition), opacity var(--transition);
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-w));
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-light);
}

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

.brand-icon {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.sidebar-actions {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.btn-new-chat {
  width: 100%;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn-new-chat:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.sidebar-info {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.sidebar-info::-webkit-scrollbar {
  width: 4px;
}

.sidebar-info::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.info-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.info-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info-list {
  list-style: none;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.info-list li {
  padding: 6px 0 6px 18px;
  position: relative;
}

.info-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}

.tool-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-badge {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  border: 1px solid var(--accent-border);
  font-weight: 500;
}

.btn-checklist {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-checklist:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-light);
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Main area ──────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

/* ── Top bar ────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.topbar-status {
  font-size: 11px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topbar-status.loading {
  color: var(--accent);
}

.topbar-status.loading::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.btn-toggle-sidebar,
.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-toggle-sidebar:hover,
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-border);
}

/* ── Chat area ──────────────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Welcome screen ─────────────────────────────────────── */
.welcome {
  text-align: center;
  padding: 80px 32px 48px;
  max-width: 640px;
  margin: 0 auto;
  animation: fadeInUp 0.6s ease-out;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 24px;
}

.welcome h2 {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.welcome p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 40px;
  line-height: 1.6;
}

.welcome-suggestions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  color: var(--text-primary);
  font-size: 14px;
}

.suggestion:hover {
  background: var(--bg-surface);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.suggestion-icon {
  font-size: 24px;
  flex-shrink: 0;
}

/* ── Messages ───────────────────────────────────────────── */
.messages {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 32px;
}

.msg {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
  animation: fadeInUp 0.4s ease-out;
}

.msg-user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.msg-user .msg-avatar {
  background: var(--accent-light);
  border-color: var(--accent-border);
}

.msg-bubble {
  max-width: 70%;
  min-width: 80px;
  animation: messageFadeIn 0.3s ease-out;
}

@keyframes messageFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.msg-user .msg-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}

.msg-assistant .msg-bubble {
  background: linear-gradient(135deg, #FAFAFA 0%, #FFFFFF 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease;
}

.msg-assistant .msg-bubble:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.msg-error .msg-bubble {
  background: var(--error-light);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  padding: 14px 18px;
  border: 1px solid rgba(220, 38, 38, 0.2);
  animation: errorShake 0.4s ease-out;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.msg-content {
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  color: var(--text-primary);
}

.msg-error .msg-content {
  color: var(--error);
}

.msg-content .auto-filled {
  color: var(--success);
  font-weight: 500;
}

.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
}

/* ── Typing indicator ───────────────────────────────────── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
}

.typing-dots {
  display: flex;
  gap: 5px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-8px); opacity: 1; }
}

.typing-text {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Input area ─────────────────────────────────────────── */
.input-area {
  padding: 20px 32px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.02);
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.input-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(60, 90, 120, 0.12);
  background: #FFFFFF;
}
  margin: 0 auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  padding: 10px 12px;
  max-height: 180px;
}

.chat-input::placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(60, 90, 120, 0.2);
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(60, 90, 120, 0.3);
}

.btn-send:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(60, 90, 120, 0.2);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--text-muted);
  box-shadow: none;
}

.btn-attach {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-attach:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

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

.btn-send svg {
  transform: rotate(-90deg);
}

.input-hint {
  max-width: 800px;
  margin: 8px auto 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Attach button ──────────────────────────────────────── */
.btn-attach {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-attach:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-border);
}

/* ── Upload Panel ───────────────────────────────────────── */
.upload-panel {
  max-width: 800px;
  margin: 0 auto 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin 0.3s ease;
  margin-bottom: 0;
  box-shadow: var(--shadow-sm);
}

.upload-panel.open {
  max-height: 450px;
  opacity: 1;
  margin-bottom: 14px;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

.upload-panel-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition);
}

.upload-panel-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.upload-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 20px;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone.has-file {
  border-color: var(--success);
  border-style: solid;
  background: var(--success-light);
}

.upload-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  text-align: center;
  min-height: 130px;
}

.upload-zone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.upload-zone-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upload-zone-label .optional {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
}

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

.upload-zone.has-file .upload-zone-icon,
.upload-zone.has-file .upload-zone-hint {
  display: none;
}

.upload-zone-preview {
  width: 100%;
  max-height: 80px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.upload-zone-preview img {
  width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.upload-zone-filename {
  font-size: 11px;
  color: var(--success);
  font-weight: 500;
  word-break: break-all;
}

.btn-ocr {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: calc(100% - 40px);
  margin: 0 20px 20px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn-ocr:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

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

/* ── OCR Result Card ────────────────────────────────────── */
.ocr-result-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ocr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
}

.ocr-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.ocr-confidence {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 4px;
}

.ocr-confidence.high {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.ocr-confidence.mid {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.ocr-confidence.low {
  background: var(--error-light);
  color: var(--error);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.ocr-fields {
  padding: 10px 16px;
}

.ocr-field {
  display: flex;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.ocr-field:last-child {
  border-bottom: none;
}

.ocr-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 110px;
  flex-shrink: 0;
}

.ocr-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 22px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  animation: slideInRight 0.3s ease-out;
  box-shadow: var(--shadow-lg);
  border: 1px solid;
}

.toast-info {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}

.toast-error {
  background: var(--error-light);
  color: var(--error);
  border-color: rgba(220, 38, 38, 0.3);
}

.toast-success {
  background: var(--success-light);
  color: var(--success);
  border-color: rgba(22, 163, 74, 0.3);
}

.toast.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-12px); }
}

/* ── Form Panel (right side) ────────────────────────────── */
.form-panel {
  width: var(--form-panel-w);
  min-width: var(--form-panel-w);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.form-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.form-counter {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.btn-export-docx {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-export-docx:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-export-docx:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px;
}

.form-panel-body::-webkit-scrollbar {
  width: 5px;
}

.form-panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.fp-section {
  margin-bottom: 20px;
}

.fp-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.fp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.fp-row.full {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.fp-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 80px;
  flex-shrink: 0;
  font-weight: 500;
}

.fp-row.full .fp-label {
  min-width: unset;
}

.fp-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-secondary);
  outline: none;
  transition: all var(--transition);
  width: 100%;
}

.fp-input:focus {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.fp-input.fp-filled {
  color: var(--text-primary);
  background: var(--bg-surface);
  border-color: var(--accent-border);
  font-weight: 500;
}

@keyframes fpFlash {
  0% {
    background-color: var(--accent-light);
    transform: scale(1.02);
  }
  100% {
    background-color: var(--bg-surface);
    transform: scale(1);
  }
}

/* ── Industry Selection Card ────────────────────────────── */
.industry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 360px;
  max-width: 520px;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.4s ease-out;
}

.industry-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.industry-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.industry-group {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

.industry-group:last-of-type {
  border-bottom: none;
}

.industry-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.industry-group-title .empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.ind-candidate {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  background: var(--bg-primary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.ind-candidate:hover {
  background: var(--bg-surface);
  border-color: var(--border);
}

.ind-candidate:has(input[type="checkbox"]:checked) {
  background: var(--accent-light);
  border-color: var(--accent-border);
}

.ind-candidate input[type="checkbox"],
.ind-candidate input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.ind-candidate-main {
  flex: 1;
  min-width: 0;
}

.ind-code {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
  background: var(--success-light);
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 8px;
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.ind-name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.5;
}

.ind-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.ind-detail-with-name {
  margin-top: 7px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-line;
}

.ind-warn-note {
  font-size: 11px;
  color: var(--error);
  background: var(--error-light);
  border-left: 3px solid var(--error);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin: 8px 0 4px;
  line-height: 1.5;
}

.industry-card-footer {
  padding: 14px 18px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.industry-summary {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-confirm-industry {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-confirm-industry:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-confirm-industry:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1200px) {
  .form-panel {
    width: 320px;
    min-width: 320px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-w));
  }

  .form-panel {
    display: none;
  }

  .msg-bubble {
    max-width: 85%;
  }

  .welcome {
    padding: 60px 24px 32px;
  }

  .welcome h2 {
    font-size: 26px;
  }
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(30, 34, 39, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease-out;
}

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

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

.modal-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition);
}

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

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.btn-primary,
.btn-secondary {
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-border);
}

/* ── Preview Content ────────────────────────────────────── */
.preview-section {
  margin-bottom: 24px;
}

.preview-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.preview-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.preview-row:last-child {
  border-bottom: none;
}

.preview-label {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 140px;
  flex-shrink: 0;
}

.preview-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}

.preview-value.empty {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Validation Indicators ──────────────────────────────── */
.fp-input.valid {
  border-color: var(--success);
  background: var(--success-light);
}

.fp-input.invalid {
  border-color: var(--error);
  background: var(--error-light);
}

.validation-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.validation-badge.valid {
  background: var(--success);
  color: #fff;
}

.validation-badge.invalid {
  background: var(--error);
  color: #fff;
}
