/* ═══════════════════════════════════════════════════════════════════
   老白健康 AI 法律助手 — 全局样式
   设计系统: 微信绿 #07c160 · 卡片式 · 宽松留白 · 移动适配
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  --primary: #07c160;
  --primary-light: #e8f8ef;
  --primary-dark: #06ad56;
  --primary-active: #059048;
  --danger: #fa5151;
  --danger-light: #fef0f0;
  --warning: #fa9d3b;
  --warning-light: #fef7f0;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #b0b0b0;
  --bg: #f5f5f5;
  --card: #fff;
  --border: #e8e8e8;
  --border-light: #f0f0f0;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 24px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
           "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Shell ── */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  box-shadow: var(--shadow-lg);
}

/* ═══════════════════════════════════════════════════════════════════
   Header & Navigation
   ═══════════════════════════════════════════════════════════════════ */
.app-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.city-dropdown {
  padding: 6px 32px 6px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.city-dropdown:focus { outline: none; border-color: var(--primary); }
.btn-clear {
  padding: 6px 14px;
  border: 1px solid #ddd;
  border-radius: 20px;
  background: var(--card);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.btn-clear:hover { border-color: var(--primary); color: var(--primary); }

/* Nav tabs — pill style */
.app-nav {
  display: flex;
  gap: 6px;
}
.app-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 7px 20px;
  border-radius: 20px;
  transition: all 0.2s;
  background: transparent;
}
.app-nav a:hover { color: var(--text); background: var(--border-light); }
.app-nav a.active {
  color: #fff;
  background: var(--primary);
  font-weight: 600;
}
.app-nav a.active:hover { background: var(--primary-dark); }

/* ═══════════════════════════════════════════════════════════════════
   Chat Area
   ═══════════════════════════════════════════════════════════════════ */
.chat-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  min-height: 400px;
  background: #fafafa;
}

/* Welcome hint */
.welcome-hint {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.welcome-hint p { font-weight: 600; margin-bottom: 10px; font-size: 0.95rem; }
.welcome-hint ul { margin-left: 20px; margin-bottom: 12px; }
.welcome-hint li { margin-bottom: 6px; color: var(--text-secondary); font-size: 0.88rem; }
.hint-sub { color: var(--text-muted); font-size: 0.82rem; font-weight: 400 !important; }

/* ── User Query Bubble (right-aligned, green) ── */
.user-query {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  border-bottom-right-radius: 4px;
  padding: 12px 18px;
  margin-bottom: 8px;
  margin-left: auto;
  margin-right: 0;
  max-width: 80%;
  width: fit-content;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: 0 2px 6px rgba(7,193,96,0.2);
}
.user-query .query-label {
  display: block;
  font-weight: 700;
  font-size: 0.75rem;
  margin-bottom: 4px;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── AI Response Card (left-aligned) ── */
.result-container {
  margin-bottom: 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeInUp 0.25s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-container.agent-single { border-left: none; }
.result-container.agent-multi { border-left: none; }

.result-header {
  padding: 10px 18px;
  background: #fafafa;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}
.agent-badge {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.82rem;
}
.agent-multi .agent-badge { color: #722ed1; }
.session-id {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Blocked response */
.result-blocked {
  background: var(--danger-light);
  border: 1px solid #ffccc7;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  color: var(--danger);
  font-size: 0.9rem;
}

/* Result body — Markdown rendering */
.result-body {
  padding: 18px 22px;
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text);
}
.result-body h2 { font-size: 1.15rem; margin: 22px 0 10px; color: var(--text); }
.result-body h3 { font-size: 1.05rem; margin: 16px 0 8px; }
.result-body h4 { font-size: 0.98rem; margin: 12px 0 6px; }
.result-body p { margin-bottom: 10px; }
.result-body ul, .result-body ol { margin: 10px 0 10px 24px; }
.result-body li { margin-bottom: 6px; }
.result-body strong { color: var(--text); }
.result-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.result-body th, .result-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.result-body th {
  background: #fafafa;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.result-body blockquote {
  border-left: 3px solid var(--primary);
  padding: 10px 16px;
  margin: 12px 0;
  color: var(--text-secondary);
  background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
}
.result-body code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--danger);
}
.result-body pre {
  background: #282c34;
  color: #abb2bf;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 12px 0;
}
.result-body pre code { background: none; padding: 0; color: inherit; }
.result-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Audit warnings in result */
.result-warnings {
  padding: 10px 18px;
  background: var(--warning-light);
  border-top: 1px solid #ffe0b2;
  color: #c77700;
  font-size: 0.82rem;
}

/* ── Result Actions ── */
.result-actions {
  padding: 10px 18px;
  background: #fafafa;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.result-actions button {
  padding: 6px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  background: var(--card);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.result-actions button:hover { border-color: var(--primary); color: var(--primary); }

.dislike-picker {
  padding: 12px 18px;
  background: var(--warning-light);
  border-bottom: 1px solid #ffe0b2;
  font-size: 0.82rem;
}
.dislike-picker p { margin-bottom: 8px; font-weight: 500; }
.dislike-picker button {
  padding: 4px 14px;
  margin: 2px 6px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  background: var(--card);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 0.2s;
}
.dislike-picker button:hover { border-color: var(--danger); color: var(--danger); }
.dislike-cancel-btn { background: #fafafa !important; }
.hidden { display: none; }

.turn-separator { border: none; border-top: 1px dashed var(--border); margin: 16px 0; }

/* ── Reasoning Chain Section ── */
.reasoning-toggle {
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 12px;
  background: #f9f9f9;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  display: inline-block;
  margin: 6px 0;
  user-select: none;
  transition: all 0.2s;
}
.reasoning-toggle:hover { border-color: #ccc; color: var(--text-secondary); }
.reasoning-section { background: #f9f9f9; border-radius: var(--radius-sm); padding: 12px 16px; margin: 8px 0; display: none; }
.reasoning-section.open { display: block; }

/* ═══════════════════════════════════════════════════════════════════
   Input Area (sticky footer)
   ═══════════════════════════════════════════════════════════════════ */
.input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  bottom: 0;
}
.upload-row {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-label {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 6px 14px;
  border: 1px dashed #ccc;
  border-radius: 20px;
  transition: all 0.2s;
}
.file-label:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
#file-upload { display: none; }
.upload-msg { font-size: 0.78rem; }
.upload-msg.success { color: var(--primary); }
.upload-msg.error { color: var(--danger); }

.input-row { display: flex; gap: 10px; align-items: flex-end; }
.input-row textarea {
  flex: 1;
  padding: 12px 18px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-full);
  resize: none;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  transition: all 0.2s;
  background: #fafafa;
}
.input-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 4px rgba(7,193,96,0.08);
}
.btn-send {
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(7,193,96,0.25);
}
.btn-send:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(7,193,96,0.35); }
.btn-send:disabled { background: #ccc; box-shadow: none; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════════
   Scroll to Top
   ═══════════════════════════════════════════════════════════════════ */
.scroll-top-btn {
  position: fixed;
  bottom: 150px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #e0e0e0;
  background: var(--card);
  cursor: pointer;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  display: none;
  z-index: 99;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.scroll-top-btn:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-md); }

/* ═══════════════════════════════════════════════════════════════════
   Toast Notifications
   ═══════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
}
.toast {
  padding: 12px 28px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  box-shadow: var(--shadow-md);
}
.toast.success { background: var(--primary-light); border: 1px solid #b7eb8f; color: var(--primary-dark); }
.toast.warning { background: var(--warning-light); border: 1px solid #ffe0b2; color: #c77700; }
.toast.error { background: var(--danger-light); border: 1px solid #ffccc7; color: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════════
   Loading Spinner
   ═══════════════════════════════════════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-indicator {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request .btn-send { opacity: 0.6; pointer-events: none; }

/* ═══════════════════════════════════════════════════════════════════
   AUDIT PAGE
   ═══════════════════════════════════════════════════════════════════ */
.audit-area { flex: 1; padding: 24px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  align-items: center;
}
.filter-bar select,
.filter-bar input {
  padding: 8px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: 0.84rem;
  font-family: inherit;
  background: #fafafa;
  color: var(--text);
  transition: all 0.2s;
}
.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
}
.filter-bar .search-input {
  flex: 1;
  min-width: 160px;
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b0b0b0' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.filter-bar .filter-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.filter-bar .filter-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Audit section */
.audit-section { margin-bottom: 24px; }
.audit-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* Feedback summary */
.fb-summary { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.fb-count {
  font-size: 1rem;
  font-weight: 600;
  padding: 8px 16px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}
.fb-warnings {
  background: var(--danger-light);
  border: 1px solid #ffccc7;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
}
.fb-warnings h3 { font-size: 0.88rem; color: var(--danger); margin-bottom: 8px; }
.fb-warnings li { color: var(--danger); margin-left: 20px; margin-bottom: 4px; font-size: 0.84rem; }

/* Audit log cards */
.audit-cards { display: flex; flex-direction: column; gap: 10px; }
.audit-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.audit-card:hover { box-shadow: var(--shadow); border-color: var(--border); }
.audit-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.audit-card-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.audit-card-meta .time { color: var(--text-muted); font-size: 0.78rem; }
.audit-card-meta .agent-tag {
  background: #f0f0f0;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.76rem;
}
.status-badge {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
}
.status-badge.pass { background: var(--primary-light); color: var(--primary-dark); }
.status-badge.fail { background: var(--danger-light); color: var(--danger); }

.audit-card-query {
  font-size: 0.86rem;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.5;
}
.audit-card-rules {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.audit-card-rules .rule-tag {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}
.audit-card-detail {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.7;
}
.audit-card-detail.open { display: block; }
.audit-card-detail .warn-item { color: var(--warning); padding-left: 16px; position: relative; }
.audit-card-detail .warn-item::before { content: "⚠️"; position: absolute; left: 0; }

/* Audit table (fallback) */
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.audit-table th, .audit-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.audit-table th { background: #fafafa; font-weight: 600; color: var(--text-secondary); }
.audit-table .pass { color: var(--primary); font-weight: 600; }
.audit-table .fail { color: var(--danger); font-weight: 600; }
.audit-table .input-col { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-table tbody tr:nth-child(even) { background: #fafafa; }
.audit-table tbody tr:hover { background: var(--primary-light); }

/* ═══════════════════════════════════════════════════════════════════
   INGEST PAGE
   ═══════════════════════════════════════════════════════════════════ */
.ingest-main { flex: 1; padding: 24px; }

.page-hero { margin-bottom: 24px; }
.page-hero h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.page-hero .subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Form cards */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}
.form-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid.col-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-group .hint { font-size: 0.76rem; color: var(--text-muted); margin-top: 4px; }
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text);
  background: #fafafa;
  transition: all 0.2s;
}
.form-group input::placeholder { color: #ccc; }
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(7,193,96,0.08);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed #d0d0d0;
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: #fafafa;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 6px rgba(7,193,96,0.06);
  border-style: solid;
}
.upload-zone .upload-icon { font-size: 3rem; margin-bottom: 12px; display: block; }
.upload-zone .upload-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-zone .upload-hint { font-size: 0.82rem; color: var(--text-muted); }

/* File chips */
.file-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid #b7eb8f;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.84rem;
  color: var(--text);
}
.file-chip .file-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .file-size { color: var(--text-muted); font-size: 0.76rem; }
.file-chip .file-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
  transition: all 0.15s;
}
.file-chip .file-remove:hover { color: var(--danger); background: rgba(250,81,81,0.08); }

/* Submit */
.btn-submit {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(7,193,96,0.3);
}
.btn-submit:hover { background: var(--primary-dark); box-shadow: 0 6px 20px rgba(7,193,96,0.4); }
.btn-submit:disabled { background: #ccc; cursor: not-allowed; box-shadow: none; }

/* Progress */
.progress-section { display: none; margin: 16px 0; }
.progress-bar-wrap {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.6s ease;
}
.progress-text { text-align: center; color: var(--text-muted); font-size: 0.82rem; margin-top: 8px; }

/* Result panel */
.result-panel { margin-top: 20px; display: none; }
.result-panel.success {
  background: var(--primary-light);
  border: 1px solid #b7eb8f;
  border-radius: var(--radius);
  padding: 24px;
}
.result-panel.error {
  background: var(--danger-light);
  border: 1px solid #ffccc7;
  border-radius: var(--radius);
  padding: 24px;
}
.result-panel .summary { font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; }
.result-panel .summary.success-text { color: var(--primary-dark); }
.result-panel .summary.error-text { color: var(--danger); }
.result-panel .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.result-panel .stat {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
}
.result-panel .stat .num { font-size: 1.4rem; font-weight: 700; color: var(--primary); line-height: 1.3; }
.result-panel .stat .label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.result-panel .output-path {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  word-break: break-all;
}

/* Rules preview table */
.rules-preview { margin-top: 24px; }
.rules-preview h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.rule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.rule-table th, .rule-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-light); }
.rule-table th {
  background: #fafafa;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.rule-table td { font-size: 0.86rem; }
.rule-table tbody tr:last-child td { border-bottom: none; }
.rule-table tbody tr:hover { background: var(--primary-light); }
.rule-table .rule-id { font-weight: 700; color: var(--primary); white-space: nowrap; font-family: "SF Mono","Fira Code",monospace; font-size: 0.8rem; }
.rule-table .tag { display: inline-block; background: var(--primary-light); color: var(--primary-dark); padding: 2px 8px; border-radius: 12px; margin: 1px; font-size: 0.74rem; font-weight: 500; }
.rule-table .rule-summary { max-width: 340px; }

.error-list { margin-top: 8px; }
.error-item { color: var(--danger); font-size: 0.84rem; padding: 4px 0 4px 20px; position: relative; }
.error-item::before { content: "⚠"; position: absolute; left: 0; }

/* ═══════════════════════════════════════════════════════════════════
   Responsive — Mobile
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .app-container { max-width: 100%; }

  /* Header */
  .app-header { padding: 14px 16px; }
  .app-header h1 { font-size: 1.05rem; }
  .app-nav a { padding: 6px 14px; font-size: 0.82rem; }

  /* Chat */
  .chat-area { padding: 16px; }
  .user-query { max-width: 90%; font-size: 0.86rem; }
  .result-body { padding: 14px 16px; font-size: 0.88rem; }
  .result-body table { font-size: 0.72rem; }
  .result-body th, .result-body td { padding: 6px 8px; }

  /* Input */
  .input-area { padding: 12px 16px; }
  .input-row { flex-direction: column; }
  .btn-send { width: 100%; padding: 12px; }

  /* Audit */
  .audit-area { padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .search-input { min-width: auto; }
  .audit-card-header { flex-direction: column; align-items: flex-start; }

  /* Ingest */
  .ingest-main { padding: 16px; }
  .form-card { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.col-3 { grid-template-columns: 1fr; }
  .upload-zone { padding: 36px 18px; min-height: 150px; }
  .file-chip .file-name { max-width: 160px; }
  .result-panel .stats { grid-template-columns: 1fr 1fr; }
}


/* Upload Preview Card */
.upload-preview { margin-bottom: 10px; }
.upload-preview-card {
  background: #f8fbff;
  border: 1px solid #d0e4f5;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.84rem;
  animation: fadeInUp 0.2s ease;
}
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.86rem;
}
.preview-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  padding: 2px 6px; border-radius: 4px;
}
.preview-close:hover { background: #f0f0f0; color: var(--text); }
.preview-body {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 10px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.preview-truncated {
  font-size: 0.76rem; color: var(--text-muted);
  margin-bottom: 10px; text-align: center;
}
.preview-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.preview-actions .city-dropdown {
  flex: 1; min-width: 120px; padding: 6px 28px 6px 12px; font-size: 0.82rem;
}
.btn-confirm {
  padding: 8px 20px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-full); cursor: pointer;
  font-size: 0.85rem; font-weight: 600; transition: all 0.2s;
}
.btn-confirm:hover { background: var(--primary-dark); }
.btn-cancel-sm {
  padding: 8px 16px; background: var(--card); color: var(--text-secondary);
  border: 1px solid #e0e0e0; border-radius: var(--radius-full);
  cursor: pointer; font-size: 0.82rem; transition: all 0.2s;
}
.btn-cancel-sm:hover { border-color: var(--danger); color: var(--danger); }
