/* ============================================================================
   DJLC ERP — Classic macOS Clean Light Enterprise Design System
   ============================================================================ */
:root {
  --bg-canvas: #f5f5f7;
  --bg-surface: #ffffff;
  --bg-subtle: #f9f9fb;
  --bg-sidebar: #f2f2f7;
  --bg-sidebar-hover: #e5e5ea;
  --bg-sidebar-active: #0071e3;
  --border-color: #e2e2e7;
  --border-strong: #c7c7cc;

  --text-primary: #1d1d1f;
  --text-secondary: #48484a;
  --text-muted: #6e6e73;
  --text-inverse: #ffffff;

  --brand-primary: #1e5aa8;
  --brand-primary-hover: #164785;
  --brand-teal: #48484a;
  --brand-indigo: #4f46e5;

  --status-ok: #1e6b3a;
  --status-ok-bg: #f2f8f4;
  --status-warn: #8f4b08;
  --status-warn-bg: #fdf7ee;
  --status-danger: #b42318;
  --status-danger-bg: #fdf2f2;
  --status-info: #1e5aa8;
  --status-info-bg: #f2f6fc;

  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.14);

  --sidebar-w: 228px;
  --topbar-h: 48px;
  --tabbar-h: 35px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Pretendard", "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--bg-canvas);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---- App Shell ---- */
.erp-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---- Sidebar (Classic Light Source List) ---- */
.erp-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #d8d8df;
  user-select: none;
}

.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-sidebar);
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: transparent;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text h1 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-text span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #c7c7cc; border-radius: 3px; }

.nav-section {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #8e8e93;
  padding: 11px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 2px;
  border-radius: 6px;
  color: #3a3a3c;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

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

.nav-item.active {
  background: #e2e4ea;
  color: #1d1d1f;
  font-weight: 700;
}

.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.62;
  flex-shrink: 0;
}
.nav-item .nav-icon svg {
  width: 15px;
  height: 15px;
  display: block;
}
.nav-item.active .nav-icon { opacity: 0.92; }

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.06);
  color: #3a3a3c;
  font-weight: 600;
}

.nav-item.active .nav-badge {
  background: rgba(0,0,0,0.1);
  color: #1d1d1f;
}

.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.health-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.ok { background: #28a745; }
.dot.err { background: #d70015; }
.dot.warn { background: #e67e22; }

/* ---- Main Area ---- */
.erp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

/* ---- Topbar ---- */
.erp-topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid #d8d8df;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

.global-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 120px;
  max-width: 300px;
  height: 30px;
  padding: 0 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}
.global-search-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.global-search-btn:hover {
  border-color: var(--brand-primary);
  background: #fff;
  color: var(--text-primary);
}
.global-search-btn kbd {
  margin-left: auto;
  font-family: inherit;
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #e5e5ea;
  color: #48484a;
  font-weight: 600;
  flex-shrink: 0;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-right .btn,
.topbar-right .select {
  height: 30px;
  white-space: nowrap;
  flex-shrink: 0;
}

.branch-switch {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
}
.branch-switch button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.branch-switch button.active {
  background: var(--brand-primary);
  color: #fff;
}

/* ---- MDI Tab Bar ---- */
.erp-tabbar {
  height: var(--tabbar-h);
  background: #ebebef;
  border-bottom: 1px solid #d8d8df;
  display: flex;
  align-items: flex-end;
  padding: 0 10px;
  gap: 3px;
  overflow-x: auto;
  flex-shrink: 0;
}

.mdi-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 29px;
  padding: 0 12px;
  background: #e2e2e7;
  color: #48484a;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: none;
}
.mdi-tab:hover { background: #dadadf; }
.mdi-tab.active {
  background: var(--bg-canvas);
  color: var(--brand-primary);
  border-color: #d8d8df;
  position: relative;
}
.mdi-tab .tab-close {
  font-size: 13px;
  line-height: 1;
  color: #6e6e73;
  padding: 1px 3px;
  border-radius: 4px;
}
.mdi-tab .tab-close:hover {
  background: rgba(215,0,21,0.12);
  color: var(--status-danger);
}

/* ---- Workspace Content ---- */
.erp-workspace {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 24px;
  position: relative;
}

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-title-wrap h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}
.page-title-wrap p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Buttons (Classic macOS Light Precision Controls) ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 31px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid #d1d1d6;
  background: linear-gradient(180deg, #ffffff 0%, #f8f8fa 100%);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s, transform 0.06s;
  white-space: nowrap;
  box-shadow: 0 1px 1.5px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.9);
  user-select: none;
}
.btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #efeff4 100%);
  border-color: #b4b4bd;
}
.btn:active {
  background: #e9e9ef;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
  transform: translateY(0.5px);
}
.btn:focus-visible,
.btn-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2.5px rgba(30,90,168,0.28);
}
.btn:disabled,
.btn-icon:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  pointer-events: none;
}
.btn svg { width: 13px; height: 13px; display: block; flex-shrink: 0; pointer-events: none; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 5px; }
.btn-xs { height: 22px; padding: 0 7px; font-size: 11px; border-radius: 4px; }
.btn-primary {
  background: linear-gradient(180deg, #2565b8 0%, #1b5097 100%);
  border-color: #164482;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(22,68,130,0.22), inset 0 1px 0 rgba(255,255,255,0.16);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #1f5aa6 0%, #164482 100%);
  border-color: #13396e;
}
.btn-primary:active {
  background: #143d75;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}
.btn-teal {
  background: linear-gradient(180deg, #f8f8fa 0%, #efeff4 100%);
  border-color: #c5c5ce;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 1px 1.5px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.85);
}
.btn-teal:hover { background: #e6e6ee; border-color: #aeaeb8; }
.btn-danger {
  background: linear-gradient(180deg, #ffffff 0%, #fdf8f8 100%);
  border-color: #e3b8b5;
  color: var(--status-danger);
}
.btn-danger:hover { background: #fef2f2; border-color: #d9827c; color: #912018; }
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}
.btn-ghost:hover {
  background: rgba(0,0,0,0.055);
  color: var(--text-primary);
  border-color: transparent;
}
.btn-status-ok {
  background: #f2f8f4;
  border-color: #bfe0c9;
  color: #1e6b3a;
  font-weight: 600;
}
.btn-status-ok:hover {
  background: #e5f3ea;
  border-color: #9ecfae;
  color: #16522c;
}

/* ---- Square Icon Action Buttons (Table Management & Compact Tools) ---- */
.btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid #d1d1d6;
  background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 100%);
  color: #48484a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.06s;
  box-shadow: 0 1px 1px rgba(0,0,0,0.03), inset 0 1px 0 rgba(255,255,255,0.9);
  user-select: none;
}
.btn-icon:hover { background: #efeff4; border-color: #b4b4bd; color: #1d1d1f; }
.btn-icon:active { background: #e5e5ec; transform: translateY(0.5px); }
.btn-icon svg { width: 13px; height: 13px; display: block; pointer-events: none; }
.btn-icon.btn-icon-primary {
  background: linear-gradient(180deg, #2565b8 0%, #1b5097 100%);
  border-color: #164482;
  color: #fff;
  box-shadow: 0 1px 1.5px rgba(22,68,130,0.22), inset 0 1px 0 rgba(255,255,255,0.16);
}
.btn-icon.btn-icon-primary:hover {
  background: linear-gradient(180deg, #1f5aa6 0%, #164482 100%);
  border-color: #13396e;
  color: #fff;
}
.btn-icon.btn-icon-danger {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #8e8e93;
}
.btn-icon.btn-icon-danger:hover {
  background: #fef2f2;
  border-color: #e3b8b5;
  color: #b42318;
}
.btn-icon.btn-icon-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #48484a;
}
.btn-icon.btn-icon-ghost:hover {
  background: rgba(0,0,0,0.055);
  border-color: transparent;
  color: #1d1d1f;
}
.btn-icon.sz-26 { width: 26px; height: 26px; }
.btn-icon.sz-26 svg { width: 13.5px; height: 13.5px; }
.btn-icon.sz-22 { width: 22px; height: 22px; border-radius: 4px; }
.btn-icon.sz-22 svg { width: 12px; height: 12px; }
.cell-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  vertical-align: middle;
}

/* ---- KPI Grid ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }

/* ---- Cards & Panels ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-header {
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-body { padding: 14px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  width: 100%;
}
.grid-2 > .card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}
@media (max-width: 1150px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---- Filter Bar (Strict Baseline Horizontal Alignment) ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.filter-bar .input,
.filter-bar .select,
.filter-bar .btn:not(.btn-icon),
.filter-bar .btn-sm:not(.btn-icon) {
  height: 31px !important;
  line-height: 1;
  margin: 0;
  vertical-align: middle;
  box-sizing: border-box;
}

.input, .select, .textarea {
  height: 31px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.14);
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; }

/* ---- Sub-tabs inside views ---- */
.sub-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.sub-tab {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  user-select: none;
}
.sub-tab:hover { color: var(--brand-primary); }
.sub-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* ---- Enterprise Data Table ---- */
.erp-table-wrap {
  width: 100%;
  overflow-x: auto;
  max-height: clamp(420px, calc(100vh - 280px), 780px);
  overflow-y: auto;
}
.erp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.erp-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f5f5f7;
  color: #3a3a3c;
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.erp-table thead th:hover { background: #ebebef; }
.erp-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f4;
  color: var(--text-primary);
  vertical-align: middle;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.erp-table tbody tr:nth-child(even) { background: #fbfbfd; }
.erp-table tbody tr:hover { background: #f3f5f8; }
.erp-table tbody tr.clickable { cursor: pointer; }
.erp-table td.num, .erp-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background: #fff;
  gap: 8px;
  flex-wrap: wrap;
}
.table-toolbar .input,
.table-toolbar .select,
.table-toolbar .btn-sm,
.table-toolbar .barcode-scan-inp {
  height: 26px;
  box-sizing: border-box;
}
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--status-ok-bg); color: var(--status-ok); border-color: #cfe6d6; }
.badge-warn { background: var(--status-warn-bg); color: var(--status-warn); border-color: #eedbb9; }
.badge-danger { background: var(--status-danger-bg); color: var(--status-danger); border-color: #f0c9c6; }
.badge-info { background: var(--status-info-bg); color: var(--status-info); border-color: #cddcf0; }
.badge-slate { background: #f0f0f4; color: #48484a; border-color: #dfdfe6; }

/* ---- Modal & Drawer ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 680px;
  max-width: 96vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-box.modal-lg { width: 960px; }
.modal-header {
  padding: 14px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 800; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 18px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 11.5px; font-weight: 700; color: var(--text-secondary); }

/* ---- Log Viewer ---- */
.log-box {
  background: #0f172a;
  color: #e2e8f0;
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 12px;
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  font-weight: 600;
  border-left: 4px solid var(--brand-primary);
  animation: slideUp 0.2s ease;
  max-width: calc(100vw - 36px);
  word-break: break-word;
}
.toast.ok { border-left-color: #10b981; }
.toast.warn { border-left-color: var(--status-warn); }
.toast.err { border-left-color: #ef4444; }
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---- Command Palette ---- */
.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.cmd-item:hover { background: #e0f2fe; }

/* ---- Mini Bar Chart ---- */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 12px;
}
.bar-label { width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); font-weight: 600; }
.bar-track { flex: 1; height: 14px; background: #f1f5f9; border-radius: 4px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: var(--brand-primary); }
.bar-fill.teal { background: var(--brand-teal); }
.bar-val { width: 65px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- Collapsible Sidebar ---- */
.erp-sidebar { transition: width 0.16s ease; }
.erp-shell.sidebar-collapsed .erp-sidebar { width: 58px; }
.erp-shell.sidebar-collapsed .brand-text,
.erp-shell.sidebar-collapsed .nav-section,
.erp-shell.sidebar-collapsed .nav-item span:not(.nav-icon),
.erp-shell.sidebar-collapsed .sidebar-footer span:not(.dot) { display: none; }
.erp-shell.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 0; }
.erp-shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }

/* ---- Cockpit (한눈에 보기 오늘업무) ---- */
.cockpit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
@media (min-width: 1550px) {
  .cockpit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
  .cockpit-grid { grid-template-columns: 1fr; }
}
.panel-empty-slim {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ---- EMR Master-Detail (한눈에 보기 수급자 통합 차트) ---- */
.emr-split {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 130px);
  min-height: 540px;
}
@media (max-width: 1050px) {
  .emr-split { grid-template-columns: 1fr; height: auto; }
}
.emr-list-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.emr-list-body {
  flex: 1;
  overflow-y: auto;
}
.emr-cust-row {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.12s;
}
.emr-cust-row:hover { background: #f0f9ff; }
.emr-cust-row.selected {
  background: #e0f2fe;
  border-left: 3px solid var(--brand-primary);
}
.emr-chart-pane {
  overflow-y: auto;
  padding-right: 4px;
}
.profile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.profile-kv-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eef2f6;
  font-size: 12px;
}
@media (max-width: 1280px) {
  .profile-kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.pkv-label { font-size: 11px; color: var(--text-muted); font-weight: 600; display: block; }
.pkv-val { font-weight: 600; color: var(--text-primary); word-break: keep-all; }
.glance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 1250px) {
  .glance-grid { grid-template-columns: 1fr; }
}
.mini-list {
  max-height: 220px;
  overflow-y: auto;
}
.mini-row {
  padding: 7px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.mini-row:last-child { border-bottom: none; }

/* ---- Excel-like Inline Editable Grid & Barcode Scanner Bar ---- */
.excel-table input[type="text"],
.excel-table input[type="number"],
.excel-table input[type="date"],
.excel-table input.excel-cell,
.excel-table select {
  width: 100%;
  height: 25px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font-size: 11.5px;
  font-family: inherit;
  color: var(--text-primary);
}
.excel-table input:hover,
.excel-table select:hover {
  border-color: #cbd5e1;
  background: #fff;
}
.excel-table input:focus,
.excel-table select:focus {
  border-color: var(--brand-primary);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(2,132,199,0.18);
}
.excel-table tbody td {
  padding: 2px 4px;
}
.excel-table tr.row-saved {
  animation: rowFlash 0.9s ease;
}
@keyframes rowFlash {
  0% { background: #bbf7d0 !important; }
  100% { background: transparent; }
}
.excel-new-row td {
  background: #f7f8fa !important;
  border-bottom: 1px solid #d8d8df !important;
}
.excel-new-row input,
.excel-new-row select {
  background: #fff !important;
  border-color: #d1d1d6 !important;
}
.barcode-scan-inp {
  height: 30px;
  width: 195px;
  padding: 0 9px;
  border: 1px solid #1e5aa8;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
  color: #1d1d1f;
}
.barcode-scan-inp:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(30,90,168,0.16);
}

/* ---- 전역 테이블 정렬 & 칼럼 너비 드래그 리사이즈 ---- */
.erp-table thead th,
.excel-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f5f5f7;
  box-shadow: inset 0 -1px 0 var(--border-strong);
  user-select: none;
}
.erp-table thead th.th-sortable,
.excel-table thead th.th-sortable {
  cursor: pointer;
  padding-right: 18px;
}
.erp-table thead th.th-sortable:hover,
.excel-table thead th.th-sortable:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.sort-ind {
  display: inline-block;
  margin-left: 3px;
  font-size: 10px;
  color: var(--brand-primary);
  font-weight: 800;
}
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
  background: transparent;
  transition: background 0.12s;
}
.col-resizer:hover,
.col-resizer.resizing {
  background: rgba(2, 132, 199, 0.55);
}
table.col-resized {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}
table.col-resized td,
table.col-resized th {
  overflow: hidden;
  text-overflow: ellipsis;
}



/* 칼럼 순서 드래그 변경 피드백 */
.erp-table th.th-dragging,
.excel-table th.th-dragging {
  opacity: 0.45;
  background: #dbeafe !important;
}
.erp-table th.th-drag-over,
.excel-table th.th-drag-over {
  box-shadow: inset 3px 0 0 #2563eb;
  background: #eff6ff !important;
}

/* 표 헤더 줄바꿈(세로 꺾임) 방지 + 스크롤 고정 */
.erp-table thead th,
.excel-table thead th,
.erp-table th,
.excel-table th {
  white-space: nowrap !important;
  position: sticky;
  top: 0;
  z-index: 5;
}
.excel-table td {
  white-space: nowrap;
}
.excel-table select.excel-cell,
.excel-table input.excel-cell {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* 입력 박스 넘침·정렬 보정 */
.profile-card .input,
.profile-card .select,
.excel-table .excel-cell {
  max-width: 100%;
  box-sizing: border-box;
}
.excel-table input.excel-cell,
.excel-table select.excel-cell {
  height: 24px;
  padding: 0 4px;
  font-size: 11.5px;
  line-height: 22px;
}
.excel-table td {
  padding: 2px 3px;
  vertical-align: middle;
}

/* 고객관리(.emr-split) 데스크톱 2단 분할 시 바깥쪽 이중 스크롤 원천 제거 (flex:1 + min-height:0) */
@media (min-width: 1051px) {
  .erp-workspace:has(> .tab-pane.active .emr-split) {
    overflow: hidden !important;
    padding: 8px 12px !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .erp-workspace:has(> .tab-pane.active .emr-split) > .tab-pane.active {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  .erp-workspace:has(> .tab-pane.active .emr-split) .emr-split {
    flex: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  .erp-workspace:has(> .tab-pane.active .emr-split) .emr-list-pane,
  .erp-workspace:has(> .tab-pane.active .emr-split) .emr-chart-pane {
    min-height: 0 !important;
    height: 100% !important;
  }
}
.nhis-split {
  grid-template-columns: 420px 1fr;
}
@media (max-width: 1050px) {
  .emr-split { grid-template-columns: 1fr; height: auto; min-height: auto; }
  .emr-list-pane { max-height: 300px; }
  .emr-chart-pane { overflow: visible; padding-right: 0; }
  .nhis-split { grid-template-columns: 1fr; }
}

.sales-mgmt-split {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(380px, 1.5fr) minmax(260px, 1.05fr);
  gap: 12px;
  align-items: stretch;
  width: 100%;
}
@media (max-width: 1180px) {
  .sales-mgmt-split { grid-template-columns: 1fr; }
}

/* ---- 오늘업무 풀폭 균일 대시보드 그리드 ---- */
.today-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
}
.today-kpi-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s, transform 0.08s;
  box-shadow: var(--shadow-sm);
}
.today-kpi-tile:hover {
  border-color: var(--brand-primary);
  background: #f8fbff;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.today-kpi-tile .tkt-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.today-kpi-tile .tkt-val {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.today-kpi-tile .tkt-sub {
  font-size: 10.5px;
  font-weight: 600;
  color: #0369a1;
}
.today-kpi-tile.is-danger {
  background: #fef2f2;
  border-color: #f0c9c6;
}
.today-kpi-tile.is-danger .tkt-label,
.today-kpi-tile.is-danger .tkt-val { color: var(--status-danger); }
.today-kpi-tile.is-warn {
  background: #fdf7ee;
  border-color: #eedbb9;
}
.today-kpi-tile.is-warn .tkt-label,
.today-kpi-tile.is-warn .tkt-val { color: var(--status-warn); }
.today-kpi-tile.is-info {
  background: #f2f6fc;
  border-color: #cddcf0;
}
.today-kpi-tile.is-info .tkt-val { color: var(--brand-primary); }

.today-board-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  width: 100%;
}
.today-board-grid > .today-span-full {
  grid-column: 1 / -1;
}
.today-board-grid > div,
.today-board-grid > div > .card {
  height: 100%;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-width: 0;
}
.today-board-grid .erp-table-wrap {
  flex: 1 1 auto;
}
@media (max-width: 1120px) {
  .today-board-grid { grid-template-columns: 1fr; }
}

.today-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  width: 100%;
}
.today-3col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  width: 100%;
}
@media (max-width: 1420px) {
  .today-3col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .today-2col,
  .today-3col { grid-template-columns: 1fr; }
}

.copay-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 10px;
  align-items: start;
}
@media (max-width: 1120px) {
  .copay-split { grid-template-columns: 1fr; }
}

.as-receipt-split {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.as-board-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
  align-items: stretch;
  width: 100%;
}
.as-board-3col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  width: 100%;
}
.as-board-2col > div,
.as-board-2col > div > .card,
.as-board-3col > div,
.as-board-3col > div > .card {
  height: 100%;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-width: 0;
}
@media (max-width: 1280px) {
  .as-board-3col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .as-receipt-split,
  .as-board-2col,
  .as-board-3col { grid-template-columns: 1fr; }
}

.inbound-wb-split {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 290px;
  gap: 10px;
  align-items: start;
}
@media (max-width: 1240px) {
  .inbound-wb-split { grid-template-columns: 260px minmax(0, 1fr); }
  .inbound-wb-split > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .inbound-wb-split { grid-template-columns: 1fr; }
}

.extra-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  width: 100%;
}
.disinfection-split {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.needs-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}
.needs-env-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 1050px) {
  .extra-2col,
  .disinfection-split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .needs-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .needs-env-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .needs-env-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.cust-top-split {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 10px;
  margin-bottom: 10px;
  align-items: stretch;
}
.cust-basic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 7px;
}
.cust-panel-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
  align-items: stretch;
  width: 100%;
}
.cust-panel-2col.last-row {
  margin-bottom: 0;
}
.cust-modal-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1080px) {
  .cust-top-split,
  .cust-panel-2col { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .global-search-btn kbd { display: none; }
}
@media (max-width: 720px) {
  .cust-basic-grid,
  .cust-modal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .modal-backdrop { padding: 10px; }
  .form-grid:not(.cust-modal-grid) { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .cust-basic-grid,
  .cust-modal-grid { grid-template-columns: 1fr; }
  .cust-basic-grid > * { grid-column: auto !important; }
}

/* ---- Reusable Barcode Cell with Click-to-Copy ---- */
.bc-cell {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  vertical-align: middle;
}
.bc-cell .bc-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bc-cell .bc-text:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}
.bc-cell .bc-copy-btn { opacity: 0.42; }
tr:hover .bc-cell .bc-copy-btn,
.bc-cell:hover .bc-copy-btn { opacity: 1; }

@keyframes ncBarPulse {
  0% { opacity: 1; }
  50% { opacity: 0.48; }
  100% { opacity: 1; }
}
.nc-bar-indeterminate {
  width: 100% !important;
  animation: ncBarPulse 1.2s ease-in-out infinite;
}
