/* ============================================================
   RicoFood ERP — style.css
   Premium dark-mode ERP design system
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --c-bg: #0f1219;
  --c-surface: #161b27;
  --c-card: #1e2638;
  --c-border: #2a3349;
  --c-border-hi: #3b5bdb;

  --c-primary: #3b82f6;
  --c-primary-h: #60a5fa;
  --c-accent: #6366f1;
  --c-danger: #ef4444;
  --c-success: #22c55e;
  --c-warning: #f59e0b;

  --c-text: #e2e8f0;
  --c-text-mute: #94a3b8;
  --c-text-dim: #64748b;

  --sidebar-w: 240px;
  --header-h: 52px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);

  --anim: 0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Inter', 'Malgun Gothic', sans-serif;
  background: linear-gradient(135deg, #0a1628 0%, #0d1b3e 25%, #0f1628 55%, #101828 80%, #0c1118 100%);
  background-attachment: fixed;
  color: var(--c-text);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input,
select,
textarea {
  font-family: inherit;
}

a {
  color: var(--c-primary);
  text-decoration: none;
}

a:hover {
  color: var(--c-primary-h);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--c-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--c-border-hi);
}

/* ── #app shell ────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Login Screen ──────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(ellipse at 60% 40%, #1a2a5e 0%, #0f1219 70%);
}

.login-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 48px 44px;
  width: 380px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.4s ease;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 32px;
}

.login-logo .brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
}

.login-logo .sub {
  font-size: 11px;
  color: var(--c-text-mute);
  margin-top: 2px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-mute);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-field input {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color var(--anim);
}

.login-field input:focus {
  outline: none;
  border-color: var(--c-primary);
}

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  margin-top: 8px;
  transition: opacity var(--anim), transform var(--anim);
}

.btn-login:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.login-err {
  color: var(--c-danger);
  font-size: 12px;
  text-align: center;
}
.login-err:empty {
  display: none;
}

/* ── Top Header ─────────────────────────────────────────────── */
#header {
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}

#header .brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
}

#header .version {
  font-size: 11px;
  color: var(--c-text-dim);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--c-text-mute);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text-mute);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  transition: all var(--anim);
}

.btn-logout:hover {
  border-color: var(--c-danger);
  color: var(--c-danger);
}

/* ── Main Layout (sidebar + content) ───────────────────────── */
#main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px 0;
}

/* Collapsible Group */
.menu-group {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.menu-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--anim);
  color: var(--c-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.menu-group-header:hover {
  background: rgba(59, 130, 246, 0.07);
}

.mg-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.mg-label {
  flex: 1;
}

.mg-arrow {
  font-size: 10px;
  color: var(--c-text-dim);
}

.menu-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s ease;
  background: rgba(0, 0, 0, 0.16);
}

.menu-sub.open {
  max-height: 600px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 28px;
  cursor: pointer;
  transition: background var(--anim), color var(--anim);
  color: var(--c-text-mute);
  font-size: 12px;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background: var(--c-card);
  color: var(--c-text);
}

.menu-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--c-primary);
  border-left-color: var(--c-primary);
  font-weight: 600;
}

.menu-item .icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

/* ── Draggable sidebar menu items ───────────────────────────── */
.drag-handle {
  font-size: 13px;
  color: var(--c-text-dim);
  cursor: grab;
  opacity: 0;
  transition: opacity var(--anim);
  user-select: none;
  flex-shrink: 0;
  margin-left: -6px;
  width: 16px;
  text-align: center;
}

.menu-item[data-draggable]:hover .drag-handle {
  opacity: 0.7;
}

.menu-item[data-draggable]:hover {
  cursor: default;
}

.menu-item.drag-over {
  background: rgba(59, 130, 246, 0.18) !important;
  border-left-color: var(--c-primary) !important;
  outline: 1px dashed var(--c-primary);
}

.mg-drag-hint {
  font-size: 11px;
  color: var(--c-text-dim);
  opacity: 0.5;
  margin-right: 2px;
}


/* ── Content Area ───────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--c-bg);
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--c-text);
}

.page-header p {
  font-size: 13px;
  color: var(--c-text-mute);
  margin-top: 4px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-mute);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Dashboard Stats ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--anim), box-shadow var(--anim);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent, var(--c-primary));
}

.stat-card .val {
  font-size: 28px;
  font-weight: 800;
  color: var(--c-text);
}

.stat-card .lbl {
  font-size: 11px;
  color: var(--c-text-mute);
  margin-top: 4px;
}

.stat-card .icon {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 28px;
  opacity: 0.18;
}

/* ── Form ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 20px;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-mute);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  padding: 9px 11px;
  font-size: 13px;
  transition: border-color var(--anim);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.form-group.full {
  grid-column: 1 / -1;
}

select option {
  background: var(--c-card);
  color: var(--c-text);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: all var(--anim);
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--c-primary-h);
  transform: translateY(-1px);
}

.btn-focused {
  box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.6);
  border-color: #63b3ed;
  transform: scale(1.03);
  transition: all 0.15s ease;
}

/* Report views: date input readability (상품별/업체별/영업사원별 매출집계표 등) */
.report-view-card input[type="date"] {
  color: #ffffff;
  background-color: #2d3748;
  border: 1px solid #4a5568;
  padding: 6px 10px;
  border-radius: 6px;
}
/* 전역 달력 아이콘 흰색 */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.5);
  cursor: pointer;
}
.report-view-card input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.5);
  cursor: pointer;
}
.report-view-card input[type="date"]:focus {
  border-color: #63b3ed;
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 179, 237, 0.3);
}

.btn-danger {
  background: var(--c-danger);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.88;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text-mute);
}

.btn-ghost:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.btn-success {
  background: var(--c-success);
  color: #fff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-icon {
  padding: 7px;
}

.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Upload Zone ────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--anim);
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--c-primary);
  background: rgba(59, 130, 246, 0.05);
}

.upload-zone .upload-icon {
  font-size: 40px;
  opacity: 0.5;
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--c-text-mute);
  font-size: 13px;
}

.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── Table ──────────────────────────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  gap: 6px;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}

.search-box input {
  border: none;
  background: transparent;
  color: var(--c-text);
  padding: 8px 0;
  font-size: 13px;
  width: 100%;
}

.search-box input:focus {
  outline: none;
}

.search-box .icon {
  color: var(--c-text-dim);
}

.filter-select {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  padding: 8px 10px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 60vh;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-card);
}

thead th {
  background: var(--c-surface);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th:hover {
  color: var(--c-text);
}

tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--anim);
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.07);
}

tbody tr.selected {
  background: rgba(59, 130, 246, 0.14);
}

tbody td {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--c-text);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── History table column alignment ────────────────────────── */
/* Ensures <th> and <td> share the same padding and text-align  */
/* Column order: check | 입력일시 | 거래일자 | 매출업체 | 공급가액 | 세액 | 합계 | 액션 */
#sr-hist-table th,
#sr-hist-table td {
  padding: 10px 12px;
  text-align: left;
}

/* col 1: checkbox — center */
#sr-hist-table th:nth-child(1),
#sr-hist-table td:nth-child(1) {
  text-align: center !important;
  padding: 10px 6px !important;
}

/* col 5: 공급가액 — right */
#sr-hist-table th:nth-child(5),
#sr-hist-table td:nth-child(5) {
  text-align: right !important;
}

/* col 6: 세액 — right */
#sr-hist-table th:nth-child(6),
#sr-hist-table td:nth-child(6) {
  text-align: right !important;
}

/* col 7: 합계 — right */
#sr-hist-table th:nth-child(7),
#sr-hist-table td:nth-child(7) {
  text-align: right !important;
}

/* col 8: 액션 — center */
#sr-hist-table th:nth-child(8),
#sr-hist-table td:nth-child(8) {
  text-align: center !important;
}

/* checkbox size in history table */
#sr-hist-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.badge-yellow {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-gray {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
}

/* ── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--c-card);
  border-left: 4px solid var(--c-success);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  min-width: 280px;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  font-size: 13px;
}

.toast.err {
  border-left-color: var(--c-danger);
}

.toast.warn {
  border-left-color: var(--c-warning);
}

.toast.info {
  border-left-color: var(--c-primary);
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
  pointer-events: none;
}

.modal-backdrop > * {
  pointer-events: auto;
}

.modal {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--c-border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--c-text-mute);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--c-text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Upload Summary sections */
.upload-section {
  margin-bottom: 16px;
}

.upload-section h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.upload-section.ins h3 {
  color: var(--c-success);
}

.upload-section.upd h3 {
  color: var(--c-warning);
}

.upload-section.err h3 {
  color: var(--c-danger);
}

.upload-section ul {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
}

.upload-section ul li {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 4px;
  color: var(--c-text-mute);
}

/* ── Misc ───────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-text-dim);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.divider {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 20px 0;
}

.text-mute {
  color: var(--c-text-mute);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Hamburger Button ──────────────────────────────────────── */
#btn-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--c-text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
#btn-hamburger:hover { background: var(--c-surface); }

/* ── Sidebar Overlay (mobile) ─────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}
#sidebar-overlay.show { display: block; }

/* ── Manual Button ────────────────────────────────────────── */
.btn-manual {
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-manual:hover { background: var(--c-surface); color: var(--c-text); }

/* ── Home Page ────────────────────────────────────────────── */
.home-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h) - 80px);
  text-align: center;
  padding: 40px 20px;
}
.home-logo-wrap {
  margin-bottom: 24px;
}
.home-logo {
  max-height: 120px;
  max-width: 240px;
  object-fit: contain;
}
.home-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--c-text);
  margin: 0 0 8px;
}
.home-subtitle {
  font-size: 14px;
  color: var(--c-primary);
  margin: 0 0 4px;
  letter-spacing: 1px;
}
.home-desc {
  font-size: 13px;
  color: var(--c-text-dim);
  margin: 0 0 40px;
}
.home-quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.home-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 24px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  color: var(--c-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 130px;
}
.home-action-btn:hover {
  background: var(--c-surface);
  border-color: var(--c-primary);
  transform: translateY(-2px);
}
.home-action-icon { font-size: 28px; }

/* ── Manual Page ──────────────────────────────────────────── */
.manual-page { max-width: 800px; margin: 0 auto; padding: 20px 0; }
.manual-page .page-header { margin-bottom: 20px; }
.manual-toc { margin-bottom: 24px; }
.manual-toc ol { padding-left: 20px; line-height: 2; }
.manual-toc a { color: var(--c-primary); text-decoration: none; }
.manual-toc a:hover { text-decoration: underline; }
.manual-section { margin-bottom: 16px; }
.manual-section h2 { font-size: 18px; margin: 0 0 12px; color: var(--c-primary); }
.manual-section h3 { font-size: 14px; margin: 16px 0 8px; color: var(--c-text); }
.manual-section ul { padding-left: 20px; line-height: 1.8; color: var(--c-text-muted); }
.manual-section b { color: var(--c-text); }
.manual-footer { text-align: center; padding: 20px; color: var(--c-text-dim); font-size: 12px; }
.btn-manual-close {
  display: inline-block;
  padding: 10px 40px;
  margin-bottom: 12px;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.btn-manual-close:hover { opacity: 0.85; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  #btn-hamburger { display: block; }

  #sidebar {
    position: fixed;
    left: -240px;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    z-index: 50;
    transition: left 0.25s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 60px;
  }

  #sidebar.open {
    left: 0;
  }

  #content {
    padding: 16px;
  }

  .home-title { font-size: 24px; }
  .home-logo { max-height: 80px; }
  .home-quick-actions { flex-direction: column; align-items: center; }

  .btn-manual { display: none; }

  .user-chip { display: none; }
}

/* ====================================================================
   Entry Card — Sales / Purchase Form
   ==================================================================== */
.entry-card {
  padding: 20px;
}

.entry-header-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}

.entry-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.entry-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.entry-field input[type="date"],
.entry-field select {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  padding: 8px 11px;
  font-size: 13px;
  min-width: 140px;
  transition: border-color var(--anim);
}

.entry-field input:focus,
.entry-field select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.16);
}

.client-field {
  flex: 1;
  min-width: 220px;
}

.autocomplete-wrap {
  position: relative;
}

.autocomplete-wrap input,
.entry-field .autocomplete-wrap input {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  padding: 8px 11px;
  font-size: 13px;
  transition: border-color var(--anim);
}

.autocomplete-wrap input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.16);
}

.balance-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.12);
  margin-top: 4px;
  align-self: flex-start;
}

/* Autocomplete Dropdown */
.ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
}

.ac-wrap {
  position: relative;
}

.ac-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--anim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ac-item:hover,
.ac-item.active {
  background: rgba(59, 130, 246, 0.1);
}

.ac-main {
  font-size: 13px;
  color: var(--c-text);
}

.ac-sub {
  font-size: 11px;
  color: var(--c-text-dim);
}

/* Grid Table */
.grid-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-card);
}

.grid-table thead th {
  background: var(--c-surface);
  padding: 9px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.grid-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.grid-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.grid-cell {
  padding: 4px 6px;
  vertical-align: middle;
  position: relative;
}

.grid-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--c-text);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--anim), background var(--anim);
}

.grid-input:focus {
  outline: none;
  border-color: var(--c-primary);
  background: rgba(59, 130, 246, 0.07);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.subtotal-cell {
  font-weight: 700;
  color: var(--c-text-mute);
  white-space: nowrap;
  padding: 6px 10px;
  font-size: 13px;
}

.btn-row-del {
  background: transparent;
  border: none;
  color: var(--c-text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--anim);
}

.btn-row-del:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--c-danger);
}

.entry-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

/* ====================================================================
   Statement Modal — Korean Blue 공급받는자용
   ==================================================================== */
.statement-modal {
  width: 720px;
  max-width: 96vw;
  background: #fff;
  color: #111;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
  animation: scaleIn 0.22s ease;
}

.stmt-header {
  background: linear-gradient(135deg, #1a3a8f 0%, #2563eb 100%);
  color: #fff;
  padding: 18px 22px;
}

.stmt-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.stmt-doc-label {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.stmt-date {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

.stamp-box {
  width: 50px;
  height: 50px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.5;
  text-align: center;
  line-height: 1.3;
}

.stmt-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stmt-party {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.stmt-party-title {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 7px;
  opacity: 0.85;
}

.stmt-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.stmt-info-table td {
  padding: 3px 6px;
  vertical-align: top;
}

.stmt-info-table td:first-child {
  width: 72px;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
}

.stmt-body {
  padding: 16px 20px;
  background: #fff;
}

.stmt-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: #111;
}

.stmt-items-table thead th {
  background: #1e3a8a;
  color: #fff;
  padding: 8px 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #2563eb;
}

.stmt-items-table tbody td {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  text-align: center;
  color: #111;
}

.stmt-items-table tbody tr:nth-child(even) {
  background: #f8faff;
}

.stmt-items-table tbody td:nth-child(2) {
  text-align: left;
}

.stmt-footer {
  padding: 14px 20px;
  background: #f0f4ff;
  border-top: 2px solid #1e3a8a;
}

.stmt-balance-row {
  display: flex;
  gap: 0;
  border: 1px solid #c7d4f0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stmt-bal-item {
  flex: 1;
  padding: 12px 16px;
  text-align: center;
  border-right: 1px solid #c7d4f0;
}

.stmt-bal-item:last-child {
  border-right: none;
}

.stmt-bal-item.highlight {
  background: #1e3a8a;
  color: #fff;
}

.stmt-bal-label {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.stmt-bal-item.highlight .stmt-bal-label {
  color: rgba(255, 255, 255, 0.72);
}

.stmt-bal-value {
  font-size: 15px;
  font-weight: 800;
  color: #111;
}

.stmt-bal-value.prev {
  color: #6b7280;
}

.stmt-bal-value.current {
  color: #1e3a8a;
}

.stmt-bal-value.total {
  color: #fff;
  font-size: 17px;
}

.stmt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: var(--c-card);
  border-top: 1px solid var(--c-border);
}

/* ====================================================================
   거래명세서 정식 양식 (Trade Statement)
   ==================================================================== */
.ts-page {
  width: 210mm;
  background: #fff;
  padding: 6mm 8mm;
  color: #000;
  font-family: 'Malgun Gothic', '맑은 고딕', sans-serif;
}
.ts-statement { border-width: 2px; border-style: solid; }
.ts-cut-line {
  text-align: center;
  padding: 10mm 0;
  font-size: 10px;
  color: #999;
  letter-spacing: 2px;
}
.ts-title-bar {
  text-align: center;
  padding: 5px 0;
  border-bottom-width: 2px;
  border-bottom-style: solid;
}
.ts-title-bar h1 {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 8px;
  display: inline;
  margin: 0;
}
.ts-title-bar .ts-sub {
  font-size: 11px;
  font-weight: normal;
  letter-spacing: 0;
}
.ts-date-row {
  border-bottom-width: 2px;
  border-bottom-style: solid;
  padding: 3px 8px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ts-date-row .ts-dl { font-weight: bold; }
.ts-date-row .ts-serial-box,
.ts-date-row .ts-date-box {
  display: inline-block;
  min-width: 100px;
  border-bottom: 1px solid #999;
  margin-left: 4px;
}
.ts-info-section {
  display: flex;
  border-bottom-width: 2px;
  border-bottom-style: solid;
}
.ts-info-left { width: 50%; border-right-width: 2px; border-right-style: solid; }
.ts-info-right { width: 50%; }
.ts-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}
.ts-info-table td {
  border: 1px solid #aaa;
  padding: 2px 3px;
  height: 21px;
  vertical-align: middle;
  color: #000;
}
.ts-info-table .ts-label {
  font-weight: bold;
  text-align: center;
  width: 56px;
  white-space: nowrap;
  font-size: 9px;
}
.ts-info-table .ts-value { font-size: 10.5px; }
.ts-info-table .ts-section-header {
  font-weight: bold;
  text-align: center;
  width: 18px;
  min-width: 18px;
  max-width: 18px;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 1px;
  font-size: 10.5px;
  padding: 2px 0;
  overflow: hidden;
}
.ts-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  table-layout: fixed;
}
.ts-items-table th {
  border: 1px solid #aaa;
  padding: 3px 1px;
  text-align: center;
  font-weight: bold;
  font-size: 9.5px;
  height: 24px;
  overflow: hidden;
  color: #000;
}
.ts-items-table td {
  border: 1px solid #aaa;
  padding: 2px 3px;
  text-align: center;
  height: 22px;
  font-size: 10px;
  overflow: hidden;
  color: #000;
}
.ts-items-table .ts-sum-row td {
  font-weight: bold;
  height: 24px;
  font-size: 11px;
}
.ts-page .num { font-family: 'Consolas', 'Courier New', monospace; }
.ts-remark-section {
  border-top: 1px solid #aaa;
  padding: 4px 8px;
  font-size: 14px;
  min-height: 36px;
}
.ts-bottom-section { border-top-width: 2px; border-top-style: solid; }
.ts-bottom-summary {
  display: flex;
  font-size: 10.5px;
}
.ts-bottom-summary .ts-cell {
  flex: 1;
  text-align: center;
  padding: 4px 2px;
  border-right: 1px solid #aaa;
}
.ts-bottom-summary .ts-cell:last-child { border-right: none; }
.ts-bottom-summary .ts-cell .ts-bl {
  font-weight: bold;
  font-size: 9.5px;
  display: block;
  color: #000;
}
.ts-bottom-summary .ts-cell .ts-bv {
  font-size: 11px;
  display: block;
  margin-top: 1px;
  min-height: 14px;
  color: #000;
}

/* === 빨간색 (공급받는자 보관용) === */
.ts-red { border-color: #c00; }
.ts-red .ts-title-bar { border-bottom-color: #c00; }
.ts-red .ts-title-bar h1 { color: #c00; }
.ts-red .ts-title-bar .ts-sub { color: #c00; }
.ts-red .ts-date-row { border-bottom-color: #c00; }
.ts-red .ts-info-section { border-bottom-color: #c00; }
.ts-red .ts-info-left { border-right-color: #c00; }
.ts-red .ts-bottom-section { border-top-color: #c00; }

/* === 파란색 (공급자 보관용) === */
.ts-blue { border-color: #0055b8; }
.ts-blue .ts-title-bar { border-bottom-color: #0055b8; }
.ts-blue .ts-title-bar h1 { color: #0055b8; }
.ts-blue .ts-title-bar .ts-sub { color: #0055b8; }
.ts-blue .ts-date-row { border-bottom-color: #0055b8; }
.ts-blue .ts-info-section { border-bottom-color: #0055b8; }
.ts-blue .ts-info-left { border-right-color: #0055b8; }
.ts-blue .ts-bottom-section { border-top-color: #0055b8; }

/* 미수/미지급 현황: 다크 테마에서 날짜 입력 캘린더 아이콘 흰색 */
.arap-date-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}
.arap-date-input::-webkit-datetime-edit {
  color: var(--c-text, #e2e8f0);
}

/* 입출금 인쇄 전용 컨테이너: 화면에서는 숨김 */
.bsv-print-only {
  display: none !important;
}

.bsv-input-error {
  border-color: #f97316 !important;
  box-shadow: 0 0 0 1px #f97316;
}

/* AR/AP 정렬 초기화 버튼: 입/출금처리와 동일 (투명 배경 + 하늘색 아웃라인) */
.arap-sort-reset-btn {
  padding: 4px 12px;
  background: transparent;
  color: #63b3ed;
  border: 1px solid #63b3ed;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  outline: none;
  transition: all 0.15s ease;
  box-shadow: 0 0 8px rgba(99, 179, 237, 0.25);
}
.arap-sort-reset-btn:hover {
  background: rgba(99, 179, 237, 0.15);
  box-shadow: 0 0 10px rgba(99, 179, 237, 0.35);
}

/* ====================================================================
   Print / PDF Styles
   ==================================================================== */
@media print {
  @page {
    margin: 10mm;
  }

  /* 모달 인쇄 시에만 body 직계 자식 숨김 (입출금 인쇄 모드에서는 적용 안 함) */
  body:not(.bsv-print-mode) > *:not(.modal-backdrop) {
    display: none !important;
  }

  .modal-backdrop {
    position: static !important;
    background: none !important;
    display: block !important;
    padding: 0 !important;
  }

  .no-print {
    display: none !important;
  }

  .statement-modal {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    animation: none !important;
    background: #fff !important;
    padding: 0 !important;
  }

  /* 거래명세서 인쇄 */
  .ts-page {
    width: 100% !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  .ts-statement {
    page-break-inside: avoid;
  }
  .ts-red { border-color: #c00 !important; }
  .ts-red .ts-title-bar { border-bottom-color: #c00 !important; }
  .ts-red .ts-title-bar h1 { color: #c00 !important; }
  .ts-red .ts-title-bar .ts-sub { color: #c00 !important; }
  .ts-red .ts-date-row { border-bottom-color: #c00 !important; }
  .ts-red .ts-info-section { border-bottom-color: #c00 !important; }
  .ts-red .ts-info-left { border-right-color: #c00 !important; }
  .ts-red .ts-bottom-section { border-top-color: #c00 !important; }
  .ts-blue { border-color: #0055b8 !important; }
  .ts-blue .ts-title-bar { border-bottom-color: #0055b8 !important; }
  .ts-blue .ts-title-bar h1 { color: #0055b8 !important; }
  .ts-blue .ts-title-bar .ts-sub { color: #0055b8 !important; }
  .ts-blue .ts-date-row { border-bottom-color: #0055b8 !important; }
  .ts-blue .ts-info-section { border-bottom-color: #0055b8 !important; }
  .ts-blue .ts-info-left { border-right-color: #0055b8 !important; }
  .ts-blue .ts-bottom-section { border-top-color: #0055b8 !important; }
  .ts-cut-line {
    color: #999 !important;
  }

  /* ----- 입/출금처리: 인쇄 전용 전체 데이터 (숨김 컨테이너) ----- */
  .bsv-print-only {
    display: none !important;
  }

  /* 인쇄 시: 좌측 사이드바, 상단 헤더, 필터, 앱 본문 전부 숨김 */
  body.bsv-print-mode #toast-container,
  body.bsv-print-mode #header,
  body.bsv-print-mode #sidebar,
  body.bsv-print-mode #app,
  body.bsv-print-mode .no-print,
  body.bsv-print-mode #bsv-filter-bar,
  body.bsv-print-mode #bsv-pagination,
  body.bsv-print-mode #bsv-loading,
  body.bsv-print-mode #bsv-empty {
    display: none !important;
  }

  body.bsv-print-mode #bsv-print-container {
    display: block !important;
    visibility: visible !important;
  }

  /* 그림자 제거 및 흑백/단색 처리 */
  body.bsv-print-mode,
  body.bsv-print-mode * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body.bsv-print-mode #bsv-print-container,
  body.bsv-print-mode #bsv-print-container * {
    background-color: #fff !important;
    color: #000 !important;
  }

  body.bsv-print-mode {
    background: #fff !important;
  }

  body.bsv-print-mode #bsv-print-container .bsv-print-inner,
  body.bsv-print-mode .arap-print-inner {
    padding: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* 인쇄 시에만 표시되는 헤더: 조회기간, 출력일시 */
  body.bsv-print-mode .print-header-block {
    display: block !important;
    margin-bottom: 12px;
    padding: 8px 0;
    font-size: 12px;
    color: #000;
  }
  body.bsv-print-mode .print-header-block .print-period,
  body.bsv-print-mode .print-header-block .print-datetime {
    margin-right: 20px;
  }

  /* 표 A4 최적화: width 100%, table-layout auto, 짤림 방지, 선명한 테두리 */
  body.bsv-print-mode #bsv-print-container,
  body.bsv-print-mode #arap-print-container {
    overflow: hidden;
    max-width: 100%;
  }

  body.bsv-print-mode .bsv-print-table,
  body.bsv-print-mode .arap-print-table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    font-size: 11px !important;
  }

  body.bsv-print-mode .bsv-print-table th,
  body.bsv-print-mode .bsv-print-table td,
  body.bsv-print-mode .arap-print-table th,
  body.bsv-print-mode .arap-print-table td {
    padding: 6px 8px !important;
    border: 1px solid #000 !important;
    word-break: break-all;
    overflow-wrap: break-word;
    background-color: #fff !important;
    color: #000 !important;
  }

  body.bsv-print-mode .arap-print-table thead tr th,
  body.bsv-print-mode .bsv-print-table thead tr th {
    border: 1px solid #000 !important;
  }

  /* 인쇄 테이블 헤더: 모두 가운데 정렬 */
  body.bsv-print-mode .bsv-print-table thead th,
  body.bsv-print-mode .arap-print-table thead th {
    text-align: center !important;
  }

  /* AR/AP 인쇄: 거래처코드, 거래처명, 구분 가운데 / 금액·최근거래일 우측 */
  body.bsv-print-mode .arap-print-table td:nth-child(1),
  body.bsv-print-mode .arap-print-table td:nth-child(2),
  body.bsv-print-mode .arap-print-table td:nth-child(3) {
    text-align: center !important;
  }
  body.bsv-print-mode .arap-print-table td:nth-child(4),
  body.bsv-print-mode .arap-print-table td:nth-child(5),
  body.bsv-print-mode .arap-print-table td:nth-child(6),
  body.bsv-print-mode .arap-print-table td:nth-child(7),
  body.bsv-print-mode .arap-print-table td:nth-child(8) {
    text-align: right !important;
  }

  /* 거래처명 셀: 긴 이름 줄바꿈 */
  body.bsv-print-mode .arap-print-table td:nth-child(2),
  body.bsv-print-mode .bsv-print-table td:nth-child(2) {
    word-break: break-all;
    font-size: 10px;
    max-width: 120px;
  }

  body.bsv-print-mode .bsv-print-table thead th,
  body.bsv-print-mode .arap-print-table thead th {
    font-weight: 700 !important;
    border: 1px solid #000 !important;
    background-color: #fff !important;
    color: #000 !important;
  }

  /* 행 단위 페이지 브레이크 (tr 중간 잘림 방지) */
  body.bsv-print-mode .bsv-print-table tbody tr,
  body.bsv-print-mode .arap-print-table tbody tr {
    page-break-inside: avoid;
  }

  /* 미수/미지급 현황 인쇄: 컨테이너 표시 + 흑백 강제 */
  body.bsv-print-mode #arap-print-container {
    display: block !important;
  }
  body.bsv-print-mode #arap-print-container,
  body.bsv-print-mode #arap-print-container *,
  body.bsv-print-mode .arap-print-inner,
  body.bsv-print-mode .arap-print-inner *,
  body.bsv-print-mode .arap-print-summary {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
  }
}

/* ====================================================================
   History Table Checkbox Fixes
   ==================================================================== */
#sr-hist-table th:first-child,
#sr-hist-table td:first-child {
  text-align: center;
  vertical-align: middle;
  width: 50px;
}

#sr-hist-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  vertical-align: middle;
}

/* ====================================================================
   Modal tables: sticky header + sticky footer + scrollable body
   ==================================================================== */
.modal-table-wrapper {
  max-height: 420px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #3a4a5c;
  border-radius: 6px;
}

.modal-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.modal-table thead {
  display: block;
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #1e3a5f;
}

.modal-table tbody {
  display: block;
  overflow-y: auto;
  max-height: 320px;
}

.modal-table tfoot {
  display: block;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background-color: #1a2a3a;
  font-weight: bold;
  border-top: 2px solid #4a6fa5;
}

.modal-table thead tr,
.modal-table tbody tr,
.modal-table tfoot tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.modal-table th,
.modal-table td {
  padding: 8px 12px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-table th:first-child,
.modal-table td:first-child {
  text-align: left;
}

/* Sortable column headers */
.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover {
  background-color: rgba(255, 255, 255, 0.08);
}
.sortable-th.sort-asc::after {
  content: ' ↑';
  color: #63b3ed;
}
.sortable-th.sort-desc::after {
  content: ' ↓';
  color: #63b3ed;
}
.sortable-th.sort-none::after {
  content: ' ⇅';
  color: #666;
}

.sort-reset-btn {
  display: none;
  margin-left: auto;
  margin-bottom: 6px;
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  color: #63b3ed;
  border: 1px solid #63b3ed;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sort-reset-btn:hover {
  background: rgba(99, 179, 237, 0.15);
}
.sort-reset-btn.visible {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}