/* 흰색 테마 — 경리 자동화 웹 (완전 반응형) */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: 'Malgun Gothic', '맑은 고딕', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #ffffff;
  color: #1e2a3a;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}
a { color: #1976d2; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* 레이아웃 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #ffffff; border-right: 1px solid #e0e0e0;
  padding: 20px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  flex-shrink: 0; transition: transform .25s ease;
  z-index: 100;
}
.sidebar h1 { font-size: 16px; margin: 0 0 8px 20px; color: #1e2a3a; }
.sidebar .company { font-size: 12px; color: #1976d2; padding: 0 20px 20px; border-bottom: 1px solid #f0f0f0; margin-bottom: 10px; }
.sidebar nav a {
  display: block; padding: 10px 20px; color: #546e7a;
  border-left: 4px solid transparent; font-size: 13px;
}
.sidebar nav a:hover { background: #f5f7fa; color: #1e2a3a; text-decoration: none; }
.sidebar nav a.active { background: #e3f2fd; color: #1976d2; border-left-color: #2196f3; font-weight: 600; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #ffffff; border-bottom: 1px solid #e0e0e0;
  padding: 14px 24px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 50;
}
.topbar h2 { margin: 0; font-size: 18px; color: #1e2a3a; }
.topbar .user { font-size: 13px; color: #546e7a; display: flex; align-items: center; gap: 10px; }
.topbar .user a { margin-left: 6px; }

/* 회사 탭 바 (상단 빠른 전환) */
.company-tabs {
  display: flex; gap: 6px; background: #f8f9fa; border-bottom: 1px solid #e0e0e0;
  padding: 10px 24px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  position: sticky; top: 55px; z-index: 40;
}
.company-tabs a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: #ffffff; border: 1px solid #e0e0e0;
  border-radius: 20px; font-size: 13px; color: #546e7a; font-weight: 500;
  white-space: nowrap; flex-shrink: 0; transition: all .15s;
}
.company-tabs a:hover { background: #eceff1; color: #1e2a3a; text-decoration: none; }
.company-tabs a.active {
  background: var(--tab-color, #2196f3); color: #ffffff;
  border-color: var(--tab-color, #2196f3); font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

/* 햄버거 버튼 (모바일에서만 표시) */
.menu-toggle {
  display: none; background: transparent; border: 1px solid #cfd8dc;
  border-radius: 6px; padding: 6px 10px; font-size: 18px; cursor: pointer;
  margin-right: 10px;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 90;
}
.sidebar-backdrop.show { display: block; }

.content { padding: 24px; max-width: 100%; }

/* 카드 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: #ffffff; border: 1px solid #e0e0e0; border-radius: 10px;
  padding: 20px; min-width: 0;
}
.card .label { font-size: 13px; color: #757575; margin-bottom: 8px; }
.card .value { font-size: 22px; font-weight: bold; color: #1e2a3a; word-break: break-all; }
.card.red   .value { color: #e53935; }
.card.blue  .value { color: #1976d2; }
.card.green .value { color: #388e3c; }

/* 테이블 */
.panel {
  background: #ffffff; border: 1px solid #e0e0e0; border-radius: 8px;
  margin-bottom: 24px; overflow: hidden;
}
.panel-header {
  padding: 14px 20px; border-bottom: 1px solid #f0f0f0;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
}
.panel-header h3 { margin: 0; font-size: 15px; color: #1e2a3a; }
.panel-body { padding: 0; }

/* 테이블 가로 스크롤 (모바일 필수) */
.panel > table, .panel-body > table {
  display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
th { background: #fafafa; color: #546e7a; font-weight: 600; font-size: 13px; }
td { font-size: 13px; }
tr:hover td { background: #fafafa; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 폼 */
.form-row { margin-bottom: 14px; min-width: 0; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; color: #546e7a; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd8dc;
  border-radius: 6px; font-size: 14px; background: #ffffff; color: #1e2a3a;
  font-family: inherit; max-width: 100%;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: #2196f3;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* 버튼 */
.btn {
  display: inline-block; padding: 10px 18px; border: 1px solid #cfd8dc;
  border-radius: 6px; background: #ffffff; color: #1e2a3a; cursor: pointer;
  font-size: 13px; font-family: inherit; text-decoration: none;
  touch-action: manipulation;
}
.btn:hover { background: #f5f7fa; }
.btn-primary { background: #2196f3; color: #ffffff; border-color: #2196f3; font-weight: 600; }
.btn-primary:hover { background: #1976d2; }
.btn-success { background: #4caf50; color: #ffffff; border-color: #4caf50; }
.btn-success:hover { background: #388e3c; }
.btn-danger  { background: #f44336; color: #ffffff; border-color: #f44336; }
.btn-danger:hover  { background: #d32f2f; }
.btn-warning { background: #ff9800; color: #ffffff; border-color: #ff9800; }
.btn-warning:hover { background: #f57c00; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* 배지 */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 12px; font-weight: 600;
}
.badge-paid     { background: #e8f5e9; color: #2e7d32; }
.badge-unpaid   { background: #ffebee; color: #c62828; }
.badge-pending  { background: #fff3e0; color: #ef6c00; }
.badge-approved { background: #e3f2fd; color: #1565c0; }

/* 알림 */
.flash { padding: 12px 18px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.flash-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.flash-error   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.flash-info    { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }

/* 로그인 */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #f8f9fa; padding: 20px;
}
.login-box {
  background: #ffffff; padding: 40px 36px; border-radius: 10px;
  border: 1px solid #e0e0e0; width: 100%; max-width: 380px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.login-box h1 { text-align: center; margin: 0 0 8px; font-size: 20px; color: #1e2a3a; }
.login-box .sub { text-align: center; color: #757575; font-size: 13px; margin-bottom: 24px; }

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #e0e0e0; margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 10px 18px; color: #546e7a; border-bottom: 2px solid transparent;
  font-size: 13px; white-space: nowrap;
}
.tabs a:hover { color: #1e2a3a; text-decoration: none; }
.tabs a.active { color: #1976d2; border-bottom-color: #2196f3; font-weight: 600; }

/* 필터 바 */
.filter-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 14px 20px; }
.filter-bar .form-row { margin: 0; min-width: 140px; flex: 1 1 140px; }
.filter-bar .form-row.narrow { min-width: 100px; flex: 0 1 120px; }
.filter-bar .btn { flex-shrink: 0; }

/* 유틸 */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: #9e9e9e; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; }
.hidden { display: none; }
.inline-form { display: inline-block; margin-right: 4px; }

/* ==================== 반응형 ==================== */
/* 태블릿 */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .content { padding: 18px; }
  .card .value { font-size: 19px; }
}

/* 모바일 (햄버거 메뉴) */
@media (max-width: 768px) {
  .menu-toggle { display: inline-block; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    transform: translateX(-100%);
    height: 100vh; width: 260px;
    box-shadow: 2px 0 16px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .main { width: 100%; }
  .company-tabs { padding: 8px 12px; top: 52px; }
  .company-tabs a { padding: 7px 12px; font-size: 12px; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar h2 { font-size: 16px; flex: 1; }
  .topbar .user { font-size: 12px; width: 100%; justify-content: flex-end; }
  .content { padding: 14px 12px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .card .value { font-size: 17px; }
  .card .label { font-size: 12px; }
  .panel { border-radius: 6px; margin-bottom: 16px; }
  .panel-header { padding: 12px 14px; }
  .panel-header h3 { font-size: 14px; }
  th, td { padding: 8px 10px; font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .filter-bar { padding: 12px 14px; }
  .filter-bar .form-row,
  .filter-bar .form-row.narrow { flex: 1 1 45%; min-width: 0; }
  .filter-bar .btn { flex: 1 1 100%; }
  .btn { padding: 12px 16px; font-size: 14px; } /* 터치 친화 */
  .btn-sm { padding: 8px 12px; font-size: 12px; }
  .inline-form { display: block; margin-bottom: 6px; }
  .login-box { padding: 28px 22px; }
}

/* 작은 모바일 */
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .topbar h2 { font-size: 15px; }
  .sidebar { width: 240px; }
  .content { padding: 10px 8px; }
  html, body { font-size: 13px; }
}

@media print {
  .sidebar, .topbar, .filter-bar, .btn, .menu-toggle { display: none !important; }
  .main, .content { padding: 0; }
}
