/* ============================================================
   개인 가계부 — 공통 스타일
   ============================================================ */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
               "Segoe UI", sans-serif;
  background: #f5f6f8;
  color: #1f2329;
  font-size: 14px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* HTML hidden 속성이 CSS display 규칙에 항상 우선하도록 보장 */
[hidden] { display: none !important; }

.muted { color: #8a8f98; }
.error { color: #d04545; margin-top: 8px; font-size: 13px; }

/* ============================================================
   로그인 화면
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-card {
  background: #fff;
  width: 100%;
  max-width: 360px;
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 20px;
}
.auth-card p { margin: 0 0 16px; }
.auth-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8dce2;
  border-radius: 8px;
  margin-bottom: 12px;
}
.auth-card button {
  width: 100%;
  padding: 10px;
  background: #2960e6;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
}
.auth-card button:hover { background: #1d50ce; }

/* ============================================================
   앱 본체 — 탑바 / 탭
   ============================================================ */
.app { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid #e6e8ec;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  padding: 16px 0;
  white-space: nowrap;
}
.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  padding: 16px 14px;
  color: #5a626d;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: #1f2329; }
.tab.active {
  color: #2960e6;
  border-bottom-color: #2960e6;
  font-weight: 600;
}
.topbar-actions { display: flex; gap: 8px; }
.ghost {
  background: transparent;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  padding: 6px 12px;
  color: #5a626d;
}
.ghost:hover { background: #f0f2f5; }

/* ============================================================
   패널
   ============================================================ */
.content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header h2 { margin: 0; font-size: 20px; }
.placeholder {
  background: #fff;
  padding: 48px;
  text-align: center;
  color: #8a8f98;
  border-radius: 8px;
  border: 1px dashed #d8dce2;
}

/* ============================================================
   공통 컴포넌트
   ============================================================ */
.panel-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.select {
  padding: 6px 10px;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}
.month-buttons {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
.month-buttons .mbtn {
  background: #fff;
  border: 1px solid #d8dce2;
  padding: 6px 12px;
  border-radius: 6px;
  min-width: 40px;
  color: #5a626d;
}
.month-buttons .mbtn:hover { background: #f0f2f5; }
.month-buttons .mbtn.active {
  background: #2960e6;
  border-color: #2960e6;
  color: #fff;
  font-weight: 600;
}
.month-buttons .mbtn.has-data::after {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  background: #2960e6;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.month-buttons .mbtn.active.has-data::after { background: #fff; }

.btn {
  background: #2960e6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
}
.btn:hover { background: #1d50ce; }
.btn.secondary { background: #fff; color: #5a626d; border: 1px solid #d8dce2; }
.btn.secondary:hover { background: #f0f2f5; }
.btn.danger { background: #d04545; }
.btn.danger:hover { background: #b53939; }
.btn.small { padding: 4px 10px; font-size: 13px; }

.row-actions { display: flex; gap: 6px; }

/* ============================================================
   월급명세서 — 카드 / 표 / 요약
   ============================================================ */
.payroll-stack { display: flex; flex-direction: column; gap: 16px; }

.salary-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.salary-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.salary-card .card-title {
  font-size: 16px;
  font-weight: 600;
}
.salary-card .card-title .badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f0f2f5;
  color: #5a626d;
  font-weight: 500;
}
.salary-card .card-title .badge.extra {
  background: #fff4e5;
  color: #c47100;
}

.salary-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 700px) {
  .salary-columns { grid-template-columns: 1fr; }
}

.item-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.item-table th {
  text-align: left;
  font-weight: 600;
  color: #5a626d;
  padding: 8px 0;
  border-bottom: 1px solid #e6e8ec;
}
.item-table td {
  padding: 6px 0;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.item-table td.amount, .item-table th.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.item-table tr.subtotal td {
  padding-top: 10px;
  border-top: 2px solid #d8dce2;
  border-bottom: none;
  font-weight: 600;
}
.item-table input[type="text"],
.item-table input[type="number"] {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.item-table input[type="text"]:hover,
.item-table input[type="number"]:hover { background: #f7f8fa; }
.item-table input[type="text"]:focus,
.item-table input[type="number"]:focus {
  background: #fff;
  border-color: #2960e6;
  outline: none;
}
.item-table input[type="number"] { text-align: right; }
.item-table .del-btn {
  background: transparent;
  border: none;
  color: #b53939;
  cursor: pointer;
  padding: 2px 6px;
}
.item-table .del-btn:hover { background: #fde8e8; border-radius: 4px; }

.net-line {
  margin-top: 16px;
  padding: 14px;
  background: #f7f8fa;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
}
.net-line .label { color: #5a626d; }
.net-line .value {
  font-size: 20px;
  font-weight: 700;
  color: #1f2329;
  font-variant-numeric: tabular-nums;
}

/* 요약 카드 */
.summary-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.summary-card .summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-variant-numeric: tabular-nums;
}
.summary-card .summary-row .label { color: #5a626d; }
.summary-card .summary-row.total {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 2px solid #d8dce2;
  font-size: 17px;
  font-weight: 700;
}
.summary-card .summary-row.total .value { color: #2960e6; }
.summary-card .extra-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff4e5;
  border-radius: 6px;
  color: #8b5a00;
  font-size: 13px;
}

.empty-card {
  background: #fff;
  border: 1px dashed #d8dce2;
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: #8a8f98;
}
.empty-card .btn { margin-top: 12px; }

.add-extra-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============================================================
   태그 관리
   ============================================================ */
.tag-stack { display: flex; flex-direction: column; gap: 16px; }

.tag-section {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.tag-section .section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}
.tag-section .section-desc {
  color: #8a8f98;
  margin: 0 0 16px;
  font-size: 13px;
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}
.tag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f7f8fa;
  border-radius: 6px;
}
.tag-row .name {
  flex: 1;
  font-size: 14px;
  cursor: text;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
}
.tag-row .name:hover { background: #fff; }
.tag-row input.name-edit {
  flex: 1;
  font-size: 14px;
  padding: 4px 8px;
  border: 1px solid #2960e6;
  border-radius: 4px;
  background: #fff;
}
.tag-row .in-use-badge {
  font-size: 11px;
  color: #8a8f98;
  background: #e6e8ec;
  padding: 2px 6px;
  border-radius: 4px;
}
.tag-row .icon-btn {
  background: transparent;
  border: 1px solid transparent;
  width: 28px; height: 28px;
  border-radius: 4px;
  color: #5a626d;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tag-row .icon-btn:hover { background: #fff; border-color: #d8dce2; }
.tag-row .icon-btn.del:hover { background: #fde8e8; color: #b53939; border-color: #fbb;}
.tag-row .icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tag-row .icon-btn:disabled:hover { background: transparent; border-color: transparent; }

.tag-empty {
  color: #aaa;
  padding: 16px;
  text-align: center;
  background: #f7f8fa;
  border-radius: 6px;
  font-size: 13px;
}

.tag-add-form {
  display: flex;
  gap: 8px;
}
.tag-add-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  font-size: 14px;
}
.tag-add-form input:focus { outline: none; border-color: #2960e6; }

/* ============================================================
   카드 사용내역
   ============================================================ */
.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cards-info-box {
  background: #fff;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.cards-info-box h4 { margin: 0 0 8px; font-size: 14px; color: #5a626d; }
.cards-info-box .stmt-row {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 13px; color: #5a626d;
}
.cards-info-box .stmt-row b { color: #1f2329; }

.cards-filters {
  background: #fff;
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-group .filter-label {
  font-size: 13px;
  color: #5a626d;
  min-width: 80px;
  font-weight: 500;
}
.chip {
  background: #f7f8fa;
  border: 1px solid #e6e8ec;
  color: #5a626d;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { background: #fff; }
.chip.active {
  background: #2960e6;
  border-color: #2960e6;
  color: #fff;
}

.cards-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #5a626d;
}
.cards-summary .total {
  font-size: 20px;
  font-weight: 700;
  color: #1f2329;
  font-variant-numeric: tabular-nums;
}

.tx-table-wrap {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  overflow-x: auto;
}
table.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.tx-table th, table.tx-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
table.tx-table th {
  background: #f7f8fa;
  color: #5a626d;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table.tx-table td.amount, table.tx-table th.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.tx-table .domestic-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e6f0ff;
  color: #2960e6;
}
table.tx-table .domestic-badge.foreign {
  background: #fff4e5;
  color: #c47100;
}
table.tx-table .inline-select, table.tx-table .inline-input {
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  min-width: 80px;
}
table.tx-table .inline-select:hover, table.tx-table .inline-input:hover { background: #f7f8fa; }
table.tx-table .inline-select:focus, table.tx-table .inline-input:focus {
  border-color: #2960e6;
  background: #fff;
  outline: none;
}
table.tx-table .row-del {
  background: transparent;
  border: none;
  color: #b53939;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
table.tx-table .row-del:hover { background: #fde8e8; }

.tx-empty {
  padding: 48px;
  text-align: center;
  color: #8a8f98;
}

/* ============================================================
   모달
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-header .icon-btn {
  background: transparent;
  border: none;
  color: #5a626d;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.tx-form .form-row { margin-bottom: 12px; }
.tx-form .form-row.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tx-form label {
  display: block;
  font-size: 12px;
  color: #5a626d;
  margin-bottom: 4px;
}
.tx-form input, .tx-form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  font-size: 14px;
}
.tx-form input:focus, .tx-form select:focus { outline: none; border-color: #2960e6; }

.companies-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px 90px 32px;
  gap: 8px;
  margin-bottom: 6px;
  align-items: center;
}
.companies-row input {
  padding: 6px 10px;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}
