/* ============================================
   KMC Workstation Design System
   코리아모터사이클 사내 포털
   ============================================ */

:root {
  --kmc-primary: #1e3a8a;
  --kmc-primary-hover: #1e40af;
  --kmc-primary-light: #dbeafe;
  --kmc-secondary: #475569;
  --status-safe: #10b981;
  --status-safe-bg: #d1fae5;
  --status-safe-text: #065f46;
  --status-warning: #f59e0b;
  --status-warning-bg: #fef3c7;
  --status-warning-text: #92400e;
  --status-danger: #ef4444;
  --status-danger-bg: #fee2e2;
  --status-danger-text: #991b1b;
  --status-info: #3b82f6;
  --status-info-bg: #dbeafe;
  --status-info-text: #1e40af;
  --bg-body: #f1f5f9;
  --bg-surface: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --sidebar-width: 250px;
  --header-height: 56px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-family);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--kmc-primary); text-decoration: none; }
a:hover { color: var(--kmc-primary-hover); }

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--kmc-primary);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  overflow-y: auto;
}
.sidebar-brand {
  padding: var(--space-lg) var(--space-md);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.sidebar-brand::before {
  content: "";
  display: inline-block;
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.2);
  border-radius: 6px;
}
.sidebar-section {
  padding: var(--space-sm) var(--space-md) var(--space-xs);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.05em;
  margin-top: var(--space-sm);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.6rem var(--space-md);
  color: rgba(255,255,255,0.75);
  font-size: 0.875rem;
  border-radius: 0;
  transition: background 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 600; }
.nav-item .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-md);
  border-top: 1px solid rgba(255,255,255,0.15);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
}
.sidebar-user .avatar {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem;
}
.sidebar-user .user-info { flex: 1; }
.sidebar-user .user-info .name { font-weight: 600; }
.sidebar-user .user-info .role { font-size: 0.7rem; color: rgba(255,255,255,0.6); }

.main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: var(--space-md);
}
.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; }
.mobile-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: var(--space-sm); }

.page { padding: var(--space-lg); flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---- Grid ---- */
.grid { display: grid; gap: var(--space-md); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---- Card ---- */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.card-header h2, .card-header h3 { font-size: 0.95rem; font-weight: 600; }
.card-body { padding: var(--space-lg); }
.card-body.compact { padding: var(--space-md); }

/* ---- KPI Card ---- */
.kpi { padding: var(--space-lg); }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 1.75rem; font-weight: 700; margin-top: var(--space-xs); line-height: 1.2; }
.kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: var(--space-xs); }
.kpi-value.safe { color: var(--status-safe); }
.kpi-value.warning { color: var(--status-warning); }
.kpi-value.danger { color: var(--status-danger); }

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.safe { background: var(--status-safe-bg); color: var(--status-safe-text); }
.badge.warning { background: var(--status-warning-bg); color: var(--status-warning-text); }
.badge.danger { background: var(--status-danger-bg); color: var(--status-danger-text); }
.badge.info { background: var(--status-info-bg); color: var(--status-info-text); }
.badge.neutral { background: #f1f5f9; color: var(--text-muted); }

/* ---- Button ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 38px;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-primary { background: var(--kmc-primary); color: #fff; border-color: var(--kmc-primary); }
.btn-primary:hover { background: var(--kmc-primary-hover); color: #fff; }
.btn-danger { background: var(--status-danger); color: #fff; border-color: var(--status-danger); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; min-height: 30px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-main); background: #f1f5f9; }

/* ---- Form Controls ---- */
.input, .select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text-main);
  min-height: 38px;
  transition: border-color 0.15s;
}
.input:focus, .select:focus { outline: none; border-color: var(--kmc-primary); box-shadow: 0 0 0 3px var(--kmc-primary-light); }
.input::placeholder { color: var(--text-light); }
.input-lg { padding: 0.65rem 1rem; font-size: 0.95rem; min-height: 44px; }

.toolbar {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--space-md);
}
.toolbar .input, .toolbar .select { flex: 1; min-width: 140px; }
.toolbar .input-search { flex: 2; min-width: 200px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}
.table th, .table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr { transition: background 0.1s; content-visibility: auto; contain-intrinsic-size: 44px; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr.row-danger { background: #fff5f5; }
.table tbody tr.row-warning { background: #fffbeb; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.table .col-center { text-align: center; }

/* ---- Notification List ---- */
.notif-list { list-style: none; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}
.notif-item:last-child { border-bottom: none; }
.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.notif-dot.safe { background: var(--status-safe); }
.notif-dot.warning { background: var(--status-warning); }
.notif-dot.danger { background: var(--status-danger); }
.notif-time { color: var(--text-light); font-size: 0.75rem; white-space: nowrap; }

/* ---- Quick Actions ---- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-sm);
}
.quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-surface);
  text-decoration: none;
}
.quick-tile:hover { border-color: var(--kmc-primary); background: var(--kmc-primary-light); color: var(--kmc-primary); }
.quick-tile .tile-icon { font-size: 1.5rem; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: var(--space-sm); opacity: 0.4; }
.empty-state h3 { font-size: 1rem; color: var(--text-main); margin-bottom: var(--space-xs); }
.empty-state p { font-size: 0.85rem; margin-bottom: var(--space-md); }

/* ---- Skeleton Loading ---- */
.skeleton {
  background: #e2e8f0;
  background: linear-gradient(90deg, #e2e8f0 25%, #cbd5e1 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Status Bar ---- */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.status-bar.ok { background: var(--status-safe-bg); color: var(--status-safe-text); }
.status-bar.warn { background: var(--status-warning-bg); color: var(--status-warning-text); }
.status-bar.error { background: var(--status-danger-bg); color: var(--status-danger-text); }

/* ---- Page Header ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; }
.page-header .breadcrumb { font-size: 0.8rem; color: var(--text-muted); }
.page-header .breadcrumb a { color: var(--text-muted); }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: var(--space-md);
  overflow-x: auto;
}
.tab {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text-main); }
.tab.active { color: var(--kmc-primary); border-bottom-color: var(--kmc-primary); font-weight: 600; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-md) 0;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--bg-surface);
  cursor: pointer;
}
.page-btn.active { background: var(--kmc-primary); color: #fff; border-color: var(--kmc-primary); }

/* ============= Legacy: 기존 포탈 호환 ============= */

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--space-md); }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
}
.login-card .brand { font-size: 1.1rem; font-weight: 700; color: var(--kmc-primary); margin-bottom: var(--space-lg); text-align: center; }
.login-card h1 { font-size: 1.1rem; margin-bottom: var(--space-sm); text-align: center; }
.login-card p { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-bottom: var(--space-md); }
.stack { display: flex; flex-direction: column; gap: var(--space-sm); }
.stack input, .stack select, .stack button { width: 100%; }
.stack input { padding: 0.6rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 0.9rem; }
.stack input:focus { outline: none; border-color: var(--kmc-primary); box-shadow: 0 0 0 3px var(--kmc-primary-light); }
.stack button { padding: 0.65rem; background: var(--kmc-primary); color: #fff; border: none; border-radius: var(--radius-md); font-size: 0.9rem; cursor: pointer; font-weight: 600; }
.stack button:hover { background: var(--kmc-primary-hover); }

/* Flash messages */
.flash { padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); font-size: 0.85rem; margin-bottom: var(--space-md); }
.flash.notice { background: var(--status-safe-bg); color: var(--status-safe-text); }
.flash.error { background: var(--status-danger-bg); color: var(--status-danger-text); }

/* Legacy portal compat */
.shell { display: flex; min-height: 100vh; }
.brand { font-size: 1.1rem; font-weight: 700; color: var(--kmc-primary); }
.ghost { background: transparent; border: 1px solid var(--border-color); padding: 0.4rem 0.8rem; border-radius: var(--radius-md); cursor: pointer; color: var(--text-muted); font-size: 0.8rem; }
.ghost:hover { background: #f1f5f9; }
.hint { font-size: 0.75rem; color: var(--text-muted); }
.inline-form { display: flex; gap: var(--space-xs); align-items: center; }
.inline-form input { font-size: 0.8rem; padding: 0.3rem 0.5rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.inline-form button { font-size: 0.78rem; padding: 0.3rem 0.5rem; }

/* Legacy sidebar (existing portal) */
.sidebar .user-card { padding: var(--space-sm) 0; font-size: 0.85rem; }
.sidebar .user-card strong { display: block; }
.sidebar .user-card span { font-size: 0.75rem; opacity: 0.7; }
.new-chat-link { display: block; padding: var(--space-sm) 0; color: rgba(255,255,255,0.8); font-size: 0.85rem; }
.new-chat-link:hover { color: #fff; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item { display: block; padding: var(--space-sm) 0; color: rgba(255,255,255,0.7); font-size: 0.82rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.chat-item.active { color: #fff; font-weight: 600; }
.chat-item:hover { color: #fff; }
.chat-title { display: block; }
.chat-meta { font-size: 0.7rem; opacity: 0.5; }
.empty-list { color: rgba(255,255,255,0.4); font-size: 0.8rem; padding: var(--space-md) 0; }

/* Legacy main content */
.hero { padding: var(--space-lg); background: linear-gradient(135deg, var(--kmc-primary) 0%, #2563eb 100%); color: #fff; border-radius: var(--radius-lg); margin-bottom: var(--space-md); }
.hero h1 { font-size: 1.3rem; margin-bottom: var(--space-xs); }
.hero p { font-size: 0.85rem; opacity: 0.85; }
.hero-actions { display: flex; gap: var(--space-sm); margin-top: var(--space-md); flex-wrap: wrap; }
.pill { background: rgba(255,255,255,0.15); padding: 0.3rem 0.8rem; border-radius: 999px; font-size: 0.78rem; }
.service-link {
  background: rgba(255,255,255,0.2);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  color: #fff;
  font-weight: 500;
  transition: background 0.15s;
}
.service-link:hover { background: rgba(255,255,255,0.3); color: #fff; }

.workspace-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
@media (min-width: 900px) { .workspace-grid { grid-template-columns: 1fr 1fr; } }
.panel { background: var(--bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); }
.panel-head { padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); }
.panel-head h2 { font-size: 0.95rem; font-weight: 600; }

/* Chat */
.chat-panel { display: flex; flex-direction: column; max-height: 500px; }
.messages { flex: 1; overflow-y: auto; padding: var(--space-md); }
.message { margin-bottom: var(--space-md); }
.message header { font-size: 0.78rem; font-weight: 600; margin-bottom: var(--space-xs); color: var(--text-muted); }
.message header span { font-weight: 400; margin-left: var(--space-sm); }
.message pre { white-space: pre-wrap; font-family: inherit; font-size: 0.85rem; background: #f8fafc; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); line-height: 1.5; }
.message.assistant pre { background: var(--kmc-primary-light); }
.message.pending pre { opacity: 0.6; }
.composer { display: flex; gap: var(--space-sm); padding: var(--space-md); border-top: 1px solid var(--border-color); }
.composer textarea { flex: 1; resize: none; padding: var(--space-sm); border: 1px solid var(--border-color); border-radius: var(--radius-md); font-family: inherit; font-size: 0.85rem; }
.composer textarea:focus { outline: none; border-color: var(--kmc-primary); }
.composer button { padding: 0.5rem 1rem; background: var(--kmc-primary); color: #fff; border: none; border-radius: var(--radius-md); cursor: pointer; font-weight: 500; font-size: 0.85rem; }

/* Files */
.files-panel .file-toolbar { display: flex; justify-content: space-between; align-items: center; padding: var(--space-sm) var(--space-lg); flex-wrap: wrap; gap: var(--space-sm); border-bottom: 1px solid var(--border-color); }
.pathbar { display: flex; align-items: center; gap: var(--space-xs); font-size: 0.8rem; color: var(--text-muted); }
.crumb.current { color: var(--text-main); font-weight: 500; }
.crumb-sep { color: var(--text-light); }
.upload-inline { display: flex; gap: var(--space-xs); align-items: center; }
.upload-inline input { font-size: 0.8rem; }
.upload-inline button { font-size: 0.78rem; padding: 0.3rem 0.6rem; background: var(--kmc-primary); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; }
.file-search { padding: var(--space-sm) var(--space-lg); }
.file-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.file-table th, .file-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-color); }
.file-table th { background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.file-row:hover { background: #f8fafc; }
.file-icon { font-size: 0.7rem; background: #f1f5f9; padding: 0.15rem 0.4rem; border-radius: var(--radius-sm); font-weight: 600; color: var(--text-muted); margin-right: var(--space-xs); }
.file-name-cell { display: flex; align-items: center; }
.table-wrap { overflow-x: auto; }

/* Admin panel */
.admin-panel { margin-top: var(--space-md); }
.admin-panel .admin-form { display: flex; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); flex-wrap: wrap; }
.admin-form input, .admin-form select { padding: 0.4rem 0.6rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 0.85rem; }
.admin-form button { padding: 0.4rem 0.8rem; background: var(--kmc-primary); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem; }

/* 2FA */
.twofa-grid { display: grid; grid-template-columns: auto 1fr; gap: var(--space-md); padding: var(--space-md); align-items: start; }
.qr-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: var(--space-sm); display: inline-block; }
.qr-card img { display: block; }
.secret-box { font-family: monospace; font-size: 0.8rem; background: #f8fafc; padding: var(--space-sm); border-radius: var(--radius-sm); word-break: break-all; border: 1px solid var(--border-color); }

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-toggle { display: block; }
  .page { padding: var(--space-md); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 1.3rem; }
  .twofa-grid { grid-template-columns: 1fr; }
  .workspace-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar .input, .toolbar .select, .toolbar .input-search { min-width: 100%; }
}
/* === ERP Progress & Result Cards === */
.erp-progress-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: #fafbfc;
}
.progress-header {
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--kmc-primary);
}
.progress-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-md) 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.progress-steps .step {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-steps .step.completed { color: var(--status-ok); }
.progress-steps .step.active { color: var(--text-primary); font-weight: 600; }
.progress-bar-container {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--kmc-primary);
  transition: width 0.4s ease;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--kmc-primary-light);
  border-top: 2px solid var(--kmc-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ERP Result Cards */
.erp-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
}
.erp-result-card {
  border: 1px solid;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
}
.erp-result-card.success {
  border-color: #a3cfbb;
  background: var(--status-ok-bg, #e8f5e9);
}
.erp-result-card.fail {
  border-color: #f1aeb5;
  background: var(--status-danger-bg, #ffebee);
}
.erp-result-card .card-header {
  padding: 12px var(--space-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 0.9rem;
}
.erp-result-card .card-body {
  padding: var(--space-md);
  font-size: 0.88rem;
}
.erp-result-card .info-row {
  display: flex;
  margin-bottom: 6px;
  line-height: 1.4;
}
.erp-result-card .info-row span:first-child {
  color: var(--text-muted);
  width: 80px;
  flex-shrink: 0;
  font-weight: 500;
}
.erp-result-card .slip-link {
  color: var(--kmc-primary);
  text-decoration: none;
  font-weight: 600;
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--kmc-primary-light);
}
.erp-result-card .slip-link:hover {
  text-decoration: underline;
  background: var(--kmc-primary-light);
}
.erp-result-card .error-reason {
  color: var(--status-danger);
  font-weight: 600;
}
.erp-result-card .card-footer {
  padding: 10px var(--space-md);
  background: rgba(255,255,255,0.6);
  border-top: 1px solid rgba(0,0,0,0.05);
  text-align: right;
}

/* Chat file attachment chip in messages */
.file-chip-in-msg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-top: 8px;
  font-size: 0.82rem;
  border: 1px solid rgba(255,255,255,0.3);
}

/* Quick action grid */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  text-align: center;
  transition: all 0.15s;
  background: var(--bg-surface);
}
.quick-tile:hover {
  border-color: var(--kmc-primary);
  background: var(--kmc-primary-light);
  color: var(--kmc-primary);
}
.tile-icon { font-size: 1.5rem; }

/* ERP action log on right panel */
.log-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.log-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.85rem;
}
.log-item:last-child { border-bottom: none; }
.log-item.success { border-left: 3px solid var(--status-ok); padding-left: 10px; }
.log-item.fail { border-left: 3px solid var(--status-danger); padding-left: 10px; }
.log-item .time { color: var(--text-muted); font-size: 0.75rem; }

/* Compact card body helper */
.card-body.compact { padding: var(--space-md); }
