/* ── Han Pay (한 페이) 정산관리 시스템 ── */
:root {
  /* 딥블루 팔레트 */
  --deep-950: #061428;
  --deep-900: #0a1f3d;
  --deep-800: #0f2d5c;
  --deep-700: #154278;
  --deep-600: #1a5294;
  --deep-500: #2563b0;

  --accent:       #1e6fd9;
  --accent-bright: #3d8eef;
  --accent-dark:  #1557b8;
  --accent-light: #e6f0fc;

  --gold:        #c9a032;
  --gold-light:  #faf6ea;

  --bg:          #eef3fa;
  --surface:     #ffffff;
  --border:      #cdd9ec;
  --border-soft: #e4ecf7;
  --text:        #0a1628;
  --text-muted:  #5a6f8c;
  --shadow:      0 1px 3px rgba(6, 20, 40, 0.07), 0 4px 16px rgba(6, 20, 40, 0.05);
  --shadow-lg:   0 8px 32px rgba(6, 20, 40, 0.12);
  --radius:      10px;
  --radius-lg:   14px;
  --sidebar-w:   240px;
  --header-h:    72px;
  --font: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
  color-scheme: light only;
  background-color: var(--bg);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--deep-950) 0%, var(--deep-900) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(21, 87, 184, 0.4);
  color: #fff;
}

.brand-icon svg { width: 22px; height: 22px; }

.brand-text h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.brand-text span { font-size: 11px; opacity: 0.55; display: block; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px;
  opacity: 0.4; padding: 8px 12px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all 0.18s ease;
  margin-bottom: 2px;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-link.active {
  background: rgba(30, 111, 217, 0.25);
  color: #fff;
  font-weight: 600;
}

.nav-link svg { width: 18px; height: 18px; opacity: 0.85; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  opacity: 0.4;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-logout {
  align-self: flex-start;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  opacity: 1;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ── 메인 영역 ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}

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

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.3;
}

.topbar-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.content {
  padding: 28px 32px;
  flex: 1;
}

.content-inner {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.18s ease;
  font-family: var(--font);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(21, 87, 184, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(21, 87, 184, 0.42); }

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--deep-600);
}
.btn-outline:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: var(--deep-500); }

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.28);
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.38); }

.btn-edit {
  background: transparent;
  color: var(--accent-dark, #1557b8);
  border: 1.5px solid rgba(30, 111, 217, 0.35);
}
.btn-edit:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark, #1557b8);
}

.btn-delete {
  background: transparent;
  color: #dc2626;
  border: 1.5px solid rgba(220, 38, 38, 0.4);
}
.btn-delete:hover {
  background: #fef2f2;
  border-color: #dc2626;
  color: #b91c1c;
}

.btn-sm { padding: 4px 10px; font-size: 11px; }

.btn-group { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }

/* ── 카드 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  width: 100%;
}

.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--border-soft);
}

.card-header h2 {
  font-size: 15px; font-weight: 700; color: var(--deep-700);
}

.card-header-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.card-body { padding: 24px; }

/* ── 통계 카드 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
}

.stat-card.gold::before {
  background: linear-gradient(90deg, var(--gold), #dcc56a);
}

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--deep-800); }
.stat-value.gold { color: var(--gold); }
.stat-value.danger { color: #dc2626; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.stat-card.warning::before {
  background: linear-gradient(90deg, #dc2626, #f87171);
}

.stat-card.warning .stat-label {
  color: #b91c1c;
}

.fee-kpi-grid {
  margin-top: 0;
}

.bulk-collect-panel,
.collect-payment-panel {
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bulk-collect-panel.is-disabled,
.collect-payment-panel.is-disabled {
  opacity: 0.72;
}

.collect-payment-head {
  margin-bottom: 10px;
}

.collect-payment-head strong {
  font-size: 14px;
  color: var(--deep-700);
}

.collect-payment-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.collect-payment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.collect-payment-item {
  padding: 10px 12px;
  background: var(--border-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}

.collect-payment-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.collect-payment-amount {
  font-weight: 700;
  color: var(--deep-700);
}

.collect-payment-company {
  color: var(--text-muted);
}

.collect-payment-item-sub {
  margin-top: 4px;
  color: var(--text-muted);
  line-height: 1.5;
}

.collect-payment-item-note {
  margin-top: 4px;
  color: var(--deep-600);
}

.payment-preview {
  margin: 0;
  padding: 10px 12px;
  background: var(--border-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  text-align: left;
  font-family: var(--font);
}

.collect-payment-scope {
  margin: 0 0 12px;
}

/* ── 수금 이력 팝업 ── */
body.popup-page {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
  width: 100%;
}

.popup-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--deep-800);
}

.popup-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.popup-content {
  flex: 1;
  width: 100%;
  padding: 20px 24px 28px;
  box-sizing: border-box;
}

.popup-content .filter-bar {
  margin-bottom: 16px;
}

.collection-history-kpi {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 16px;
}

.collection-history-table th,
.collection-history-table td {
  text-align: center;
  vertical-align: middle;
}

.collection-history-table .alloc-list {
  justify-content: center;
}

.collection-history-table .nowrap {
  white-space: nowrap;
}

.alloc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.alloc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--deep-700);
  white-space: nowrap;
}

.alloc-chip strong {
  color: var(--accent-dark);
}

.bulk-collect-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}

.bulk-collect-title strong {
  font-size: 14px;
  color: var(--deep-700);
}

.bulk-collect-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.bulk-collect-fields {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
}

.bulk-collect-fields .form-group label {
  font-size: 11px;
}

.bulk-collect-fields .form-control {
  height: 38px;
  min-width: 140px;
}

.bulk-note-field .form-control {
  min-width: 200px;
}

.bulk-collect-fields .btn {
  height: 38px;
  white-space: nowrap;
}

.company-chip-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 66px;
}

.company-chip-bar #btnOpenCollectPayment:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.company-chip-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.company-chip-actions .btn {
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
}

.company-chip-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.company-chip-bar .filter-quick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 38px;
}

.company-chip-bar .filter-quick .quick-filter {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.badge-unreceived,
.badge-outstanding {
  background: #fef3c7;
  color: #b45309;
}

.badge-partial {
  background: #ffedd5;
  color: #c2410c;
}

.badge-waived {
  background: #f3e8ff;
  color: #7c3aed;
}

.badge-collection-manual {
  background: #e0f2fe;
  color: #0369a1;
}

.danger-text {
  color: #dc2626;
  font-weight: 700;
}

table.data-table .fee-group-row td {
  background: var(--border-soft);
  border-top: 2px solid var(--border);
  padding: 10px 16px;
  text-align: left;
}

.fee-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fee-group-head strong {
  font-size: 14px;
  color: var(--deep-700);
}

.fee-group-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.fee-group-outstanding {
  color: #b45309;
  font-weight: 600;
}

.fee-group-done {
  color: #15803d;
  font-weight: 600;
}

table.data-table .row-outstanding td,
table.data-table .row-partial td {
  background: #fffbeb;
}

table.data-table .row-outstanding td:first-child,
table.data-table .row-partial td:first-child {
  box-shadow: inset 3px 0 0 #f59e0b;
}

table.data-table .row-collected-full td {
  background: #f0fdf4;
}

.collected-readonly {
  font-weight: 600;
}

.collected-input {
  min-width: 110px;
  max-width: 140px;
  text-align: right;
  padding: 6px 10px;
  font-size: 12px;
}

/* ── 데이터 테이블 (셀 가운데 정렬) ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0 auto;
}

table.data-table th,
table.data-table td {
  padding: 12px 14px;
  text-align: center;
  border: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table thead th {
  background: var(--deep-700);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  padding: 11px 12px;
}

table.data-table th.th-sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 26px;
  position: relative;
  transition: background 0.12s;
}

table.data-table th.th-sortable:hover {
  background: var(--deep-600, #1a3a6b);
}

table.data-table th.th-sortable::after {
  content: '⇅';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.45;
  font-size: 10px;
  line-height: 1;
}

table.data-table th.th-sortable.is-sorted-asc::after {
  content: '▲';
  opacity: 1;
}

table.data-table th.th-sortable.is-sorted-desc::after {
  content: '▼';
  opacity: 1;
}

table.data-table tbody tr:nth-child(even) td {
  background: #f7fafd;
}

table.data-table tbody tr:hover td {
  background: var(--accent-light);
}

table.data-table .row-label {
  background: var(--border-soft);
  font-weight: 600;
  color: var(--deep-700);
}

table.data-table .fee-row td { background: var(--gold-light); }
table.data-table .fee-row .row-label { background: #f3ead0; color: #7a6318; }

table.data-table .col-total {
  background: var(--accent-light);
  font-weight: 700;
}

table.data-table .fee-highlight {
  color: var(--gold);
  font-weight: 700;
}

table.data-table tfoot td {
  background: var(--border-soft);
  font-weight: 600;
}

table.data-table .summary-total-row td {
  background: var(--accent-light);
  border-top: 2px solid var(--accent);
  font-weight: 700;
}

.table-pagination-wrap {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}

.table-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.pagination-ellipsis {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 13px;
  user-select: none;
}

.settlement-report.monthly-mode {
  grid-template-columns: 1fr;
}

.settlement-report.monthly-mode .chart-panel {
  max-width: 100%;
}

.amount { font-variant-numeric: tabular-nums; }
.amount::before { content: '₩'; font-size: 0.85em; margin-right: 1px; opacity: 0.65; }

.amount-korean {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amount-plain {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 정산서 레이아웃은 settlement-report.css 에서 정의 */

.report-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  padding: 24px 32px;
  background: linear-gradient(135deg, var(--deep-900), var(--deep-700));
  border-radius: var(--radius-lg);
  color: #fff;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
}

.report-company {
  text-align: center;
  justify-self: center;
}

.report-summary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 220px;
  justify-self: end;
}

.report-summary table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-summary td { padding: 5px 0; }
.report-summary td:first-child { opacity: 0.75; padding-right: 16px; text-align: left; }
.report-summary td:last-child { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.report-logo {
  width: 64px; height: 64px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.2);
  justify-self: start;
  color: #fff;
}

.report-logo svg { width: 32px; height: 32px; }

.report-company h2 { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.report-company .week-label { font-size: 14px; opacity: 0.85; margin-top: 4px; }
.report-company .period { font-size: 12px; opacity: 0.6; margin-top: 2px; }

/* settlement-report.css 참고 */

/* ── 차트 ── */
.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.chart-panel h3 {
  font-size: 13px; font-weight: 700; color: var(--deep-700);
  text-align: center;
  margin-bottom: 16px;
}

.chart-placeholder {
  height: 220px;
  display: flex; align-items: flex-end; justify-content: space-around;
  gap: 6px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.6s ease;
}

.chart-bar:hover { opacity: 0.85; }

.chart-labels {
  display: flex; justify-content: space-around;
  margin-top: 8px; font-size: 11px; color: var(--text-muted);
}

.chart-y-label {
  position: absolute; left: 0; top: 50%;
  transform: rotate(-90deg) translateX(50%);
  font-size: 10px; color: var(--text-muted);
  white-space: nowrap;
}

/* ── 폼 ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.18s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 111, 217, 0.15);
}

select.form-control { cursor: pointer; }

.input-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.input-time-24 {
  font-variant-numeric: tabular-nums;
  max-width: 140px;
}

.form-group label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-actions {
  display: flex; justify-content: flex-start; gap: 10px; flex-wrap: wrap;
  margin-top: 20px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-static {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--deep-700);
  background: var(--border-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ── 배지 ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}

.badge-deposit { background: #dbeafe; color: #1557b8; }
.badge-withdraw { background: #f1f5f9; color: #475569; }
.badge-fee     { background: var(--gold-light); color: #7a6318; }
.badge-active  { background: #dcfce7; color: #15803d; }
.badge-unavailable { background: #fef3c7; color: #b45309; }

/* ── 업체 카드 ── */
.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}

.company-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.company-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.company-card.active-company {
  border-color: var(--accent);
  background: var(--accent-light);
}

.company-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.company-card .meta { font-size: 12px; color: var(--text-muted); line-height: 1.9; }
.company-card .card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px;
}

/* ── 필터 바 ── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
}

.filter-bar .form-group {
  margin: 0;
  min-width: 0;
}

.filter-bar .form-group > label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-bar .form-control {
  height: 38px;
  min-height: 38px;
  box-sizing: border-box;
}

.filter-field-company .form-control {
  min-width: 140px;
  width: 140px;
}

.filter-field-date .form-control {
  min-width: 148px;
  width: 148px;
}

.filter-field-quick .filter-quick {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 38px;
}

.filter-quick .quick-filter {
  min-width: 52px;
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.filter-bar .filter-actions {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.filter-bar .filter-actions .btn {
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
}

.filter-quick {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-quick .quick-filter.is-active {
  pointer-events: none;
}

.filter-quick .quick-filter.is-active[data-range="month"] {
  pointer-events: auto;
}

.filter-quick-with-month {
  position: relative;
}

.filter-field-quick-withdraw {
  flex: 1 1 auto;
  min-width: 0;
}

.filter-field-quick-withdraw .filter-quick {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 38px;
}

.filter-field-quick-withdraw .quick-withdraw-btn {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.btn-quick-withdraw {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

.btn-quick-withdraw:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.45);
  color: #fff;
}

.quick-withdraw-empty {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 38px;
}

.modal-compact {
  max-width: 380px;
}

.month-filter-wrap {
  position: relative;
}

.month-picker-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 132px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.month-picker-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.month-picker-item:hover {
  background: var(--border-soft);
}

.month-picker-item.is-active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.account-row,
.company-row {
  cursor: pointer;
  transition: background 0.12s;
}

.account-row:hover td,
.company-row:hover td {
  background: var(--accent-light);
}

.account-row.is-selected td,
.company-row.is-selected td {
  background: var(--accent-light);
}

.account-row.is-selected td:first-child,
.company-row.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.company-row.is-inactive td {
  background: #f1f5f9;
  color: #94a3b8;
}

.company-row.is-inactive td strong {
  color: #64748b;
}

.company-row.is-inactive .manager-id {
  color: #94a3b8;
}

.company-row.is-inactive:hover td {
  background: #e8edf3;
}

.company-row.is-inactive.is-selected td {
  background: #e2e8f0;
}

.manager-id-cell {
  text-align: left;
}

.manager-id {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--deep-600);
}

.company-memo-cell {
  max-width: 220px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
}

.company-memo {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.note-cell {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.note-cell[title]:not([title=""]) {
  cursor: help;
}

.detail-list {
  margin: 0;
  display: grid;
  gap: 14px;
}

.detail-list .detail-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.detail-list .detail-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.detail-list dt {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.detail-list dd {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  word-break: break-word;
}

.detail-list .detail-note {
  white-space: pre-wrap;
  line-height: 1.5;
}

table.data-table .row-received td {
  background: #f0fdf4;
}

.company-check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--border-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 160px;
  overflow-y: auto;
}

.company-check-list .check-label {
  justify-content: flex-start;
  width: 100%;
}

.company-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.company-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-dark, #1e4d8c);
  white-space: nowrap;
}

.check-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.note-input {
  min-width: 200px;
  max-width: 320px;
  padding: 6px 10px;
  font-size: 12px;
  text-align: left;
}

.balance-input {
  min-width: 120px;
  max-width: 160px;
  padding: 6px 10px;
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── 토스트 ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--deep-800);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  text-align: center;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 모달 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 20, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.modal-wide { max-width: 560px; }

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--deep-800);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

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

.modal-body {
  padding: 24px;
  text-align: left;
}

.modal-body .form-group {
  text-align: left;
  margin-bottom: 16px;
}

.modal-body .form-group:last-child { margin-bottom: 0; }

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

/* ── 유틸 ── */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }

/* ── 모바일 네비 (768px 이하에서 표시) ── */
.btn-mobile-menu,
.sidebar-close,
.sidebar-backdrop {
  display: none;
}

.btn-mobile-menu {
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--deep-800);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-mobile-menu svg {
  width: 20px;
  height: 20px;
}

.sidebar-close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(6, 20, 40, 0.55);
  backdrop-filter: blur(2px);
}

/* ── 반응형 ── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 20px 24px; }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
    color-scheme: light only;
    background-color: #eef3fa;
  }

  body {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #eef3fa;
    color: var(--text);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .btn-mobile-menu,
  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-backdrop:not([hidden]) {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: min(280px, 88vw);
    box-shadow: none;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }

  .sidebar-brand {
    padding-right: 52px;
  }

  .main {
    margin-left: 0;
    width: 100%;
    min-width: 0;
    overflow-x: visible;
    background: #eef3fa;
  }

  .content,
  .content-inner {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    background: #eef3fa;
  }

  .stats-grid { grid-template-columns: 1fr; }

  .content {
    padding: 12px 14px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    padding: 12px 14px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    height: auto;
    min-height: var(--header-h);
    gap: 12px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }

  .btn-mobile-menu {
    background: #ffffff;
    border-color: var(--border);
    color: var(--deep-700);
  }

  .filter-bar,
  .company-chip-bar {
    background: #ffffff;
    border-color: var(--border);
  }

  .card {
    background: #ffffff;
    border-color: var(--border);
  }

  .card-header {
    background: #e4ecf7;
  }

  .stat-card {
    background: #ffffff;
  }

  .table-pagination-wrap {
    background: #ffffff;
  }

  .sidebar-backdrop:not([hidden]) {
    background: rgba(6, 20, 40, 0.4);
  }

  .form-control,
  select.form-control,
  input.form-control,
  textarea.form-control {
    background-color: #ffffff;
    color: var(--text);
    color-scheme: light;
  }

  table.data-table tbody td {
    background-color: #ffffff;
  }

  table.data-table tbody tr:nth-child(even) td {
    background-color: #fafbfd;
  }

  .card-body {
    background: #ffffff;
  }

  .filter-quick .quick-filter {
    background: #ffffff;
    color: var(--text);
  }

  .bulk-collect-panel,
  .collect-payment-panel,
  .chart-panel,
  .modal {
    background: #ffffff;
  }

  .statement-footer-note {
    background: var(--border-soft);
    color: var(--text-muted);
  }

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

  .topbar-title {
    font-size: 18px;
  }

  .topbar-sub {
    font-size: 12px;
  }

  .topbar-actions {
    width: auto;
    flex-shrink: 0;
    justify-content: flex-end;
  }

  .filter-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 14px;
    gap: 10px;
  }

  .filter-bar .form-group {
    margin: 0;
    min-width: 0;
  }

  .filter-field-company {
    flex: 1 1 100%;
  }

  .filter-field-date {
    flex: 1 1 calc(50% - 5px);
  }

  .filter-field-company .form-control,
  .filter-field-date .form-control {
    width: 100%;
    min-width: 0;
  }

  .filter-field-quick {
    flex: 1 1 100%;
  }

  .filter-field-quick-withdraw {
    flex: 1 1 100%;
  }

  .filter-field-quick .filter-quick {
    height: 38px;
    flex-wrap: wrap;
  }

  .filter-bar .filter-actions {
    margin-left: auto;
    width: auto;
    flex: 1 1 100%;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  .filter-bar .filter-actions .btn {
    flex: 0 0 auto;
    min-width: auto;
  }

  .company-chip-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    min-height: 0;
    padding: 14px;
  }

  .company-chip-actions {
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
  }

  .company-chip-actions .btn {
    flex: 0 0 auto;
  }

  .company-chip-bar .filter-quick {
    width: auto;
    flex: 1 1 auto;
  }

  .card {
    overflow: visible;
  }

  .card-header {
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 10px;
  }

  .card-header .topbar-left {
    width: auto;
    flex: 1;
    min-width: 0;
  }

  .card-header-meta {
    display: inline;
    margin-top: 0;
  }

  .card-body {
    padding: 16px;
  }

  .card-body[style*="padding:0"],
  .card-body[style*="padding: 0"] {
    padding: 0 !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .company-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  table.data-table {
    min-width: 640px;
    font-size: 13px;
  }

  table.data-table th,
  table.data-table td {
    padding: 10px 10px;
  }

  .btn-group {
    justify-content: center;
    flex-wrap: nowrap;
  }

  .table-pagination {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .pagination-controls {
    justify-content: flex-end;
  }

  .pagination-info {
    text-align: left;
  }

  .modal-overlay {
    padding: 16px;
    align-items: center;
  }

  .modal,
  .modal-wide {
    max-width: 420px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 32px - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    border-radius: var(--radius-lg);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .modal-footer {
    flex-wrap: nowrap;
  }

  .modal-footer .btn {
    flex: 0 0 auto;
    min-width: auto;
  }

  .detail-list .detail-item {
    grid-template-columns: 96px 1fr;
    gap: 12px;
  }

  .toast {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(80px);
    max-width: calc(100vw - 32px);
  }

  .toast.show {
    transform: translateX(-50%) translateY(0);
  }

  .month-picker-popover {
    position: absolute;
    left: auto;
    right: 0;
    top: calc(100% + 6px);
    bottom: auto;
    min-width: 132px;
    max-width: calc(100vw - 28px);
    max-height: 280px;
  }

  .statement-head { text-align: center; }
  .statement-brand { justify-content: center; }
  .statement-table th,
  .statement-table td { padding: 10px 8px; }
  .report-header {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
    padding: 18px 16px;
    gap: 16px;
  }
  .report-logo,
  .report-summary { justify-self: center; }
  .report-summary td:first-child { text-align: center; }
  .report-summary td:last-child { text-align: center; }
  .report-company h2 { font-size: 22px; }
  .collection-history-kpi {
    grid-template-columns: 1fr 1fr;
  }
  .statement-footer-note {
    padding: 10px 14px;
    font-size: 11px;
    line-height: 1.5;
  }

  body.popup-page .popup-header {
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  body.popup-page .popup-content {
    padding: 14px 16px 20px;
  }
}

@media (max-width: 480px) {
  .filter-quick .quick-filter {
    flex: 1;
    min-width: 0;
    padding: 0 10px;
  }

  .quick-filter[data-range="month"],
  #btnMonthFilter {
    flex: 0 0 auto;
  }

  table.data-table {
    min-width: 520px;
  }
}
