* { box-sizing: border-box; }
body { font-family: Inter, -apple-system, system-ui, sans-serif; background: #fafaf9; color: #1a1a1a; margin: 0; font-size: 14px; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 24px; }
header { background: white; border-bottom: 1px solid #e5e5e5; padding: 18px 0 14px; }
.title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.back-link { color: #737373; text-decoration: none; font-size: 20px; }
.back-link:hover { color: #1a1a1a; }
.btn { padding: 7px 14px; border: 1px solid #e5e5e5; border-radius: 8px; background: white; font-size: 13px; font-family: inherit; cursor: pointer; color: #1a1a1a; font-weight: 500; }
.btn:hover { background: #fafaf9; }

.month-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border: 1px solid #e5e5e5; border-radius: 999px; background: white; font-size: 12px; font-family: inherit; cursor: pointer; color: #525252; font-weight: 500; transition: all 0.15s; }
.chip:hover { border-color: #1a1a1a; color: #1a1a1a; }
.chip.on { background: #1a1a1a; color: white; border-color: #1a1a1a; }

main { padding: 28px 0 80px; }

.pnl-sheet { background: white; border: 1px solid #e5e5e5; border-radius: 10px; padding: 40px 48px; }
.pnl-loading { text-align: center; padding: 60px; color: #a3a3a3; }

.pnl-title { text-align: center; margin-bottom: 32px; }
.pnl-title h2 { font-size: 20px; font-weight: 700; margin: 0 0 2px; }
.pnl-title p { margin: 0; color: #525252; font-size: 14px; }
.pnl-title .period { font-weight: 600; color: #1a1a1a; margin-top: 4px; font-size: 15px; }

.pnl-table { width: 100%; border-collapse: collapse; }
.pnl-table th, .pnl-table td { padding: 9px 8px; border-bottom: 1px solid #f5f5f4; }
.pnl-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #525252; font-weight: 600; border-bottom: 2px solid #e5e5e5; }
.pnl-table th:first-child { text-align: left; }
.pnl-table td:first-child { padding-left: 0; }
.pnl-table td.num, .pnl-table th.num { text-align: right; font-variant-numeric: tabular-nums; min-width: 100px; }
.total-col { background: #fafaf9; font-weight: 600; }

.section-header td { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #737373; font-weight: 600; padding-top: 20px; padding-bottom: 6px; border-bottom: 2px solid #e5e5e5; }

.cat-row { cursor: pointer; }
.cat-row:hover { background: #fafaf9; }
.cat-link { color: #1a1a1a; text-decoration: none; font-weight: 500; border-bottom: 1px dashed #d4d4d4; }
.cat-link:hover { color: #3b82f6; border-color: #3b82f6; }
.cat-count { font-size: 11px; color: #a3a3a3; margin-left: 6px; }

.total-row td { font-weight: 600; border-top: 1px solid #d4d4d4; border-bottom: 2px solid #d4d4d4; padding: 10px 0; }
.total-row.net-pos td { background: #f0fdf4; font-size: 15px; border-bottom: 3px double #16a34a; }
.total-row.net-neg td { background: #fef2f2; font-size: 15px; border-bottom: 3px double #dc2626; }
.total-row.net-pos td.num { color: #16a34a; }
.total-row.net-neg td.num { color: #dc2626; }
.amt-neg { color: #dc2626; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 12px; width: 90%; max-width: 600px; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid #e5e5e5; }
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #737373; padding: 0 4px; line-height: 1; }
.modal-close:hover { color: #1a1a1a; }
.modal-body { padding: 16px 24px 24px; overflow-y: auto; }

.modal-table { width: 100%; border-collapse: collapse; }
.modal-table th, .modal-table td { padding: 7px 0; text-align: left; border-bottom: 1px solid #f5f5f4; font-size: 13px; }
.modal-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #525252; font-weight: 600; border-bottom: 1px solid #e5e5e5; }
.modal-table td.num, .modal-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.modal-table tfoot td { font-weight: 600; border-top: 2px solid #e5e5e5; }
.modal-month { font-size: 13px; font-weight: 600; color: #525252; margin: 16px 0 6px; }
.modal-month:first-child { margin-top: 0; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1a1a1a; color: white; padding: 10px 18px; border-radius: 8px; font-size: 13px; opacity: 0; transition: all 0.2s; pointer-events: none; z-index: 300; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #dc2626; }

@media print {
  .no-print { display: none !important; }
  body { background: white; }
  main { padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .pnl-sheet { border: none; border-radius: 0; padding: 20px 0; }
  .cat-row { cursor: default; }
  .cat-link { border: none; }
  #toast, .modal-overlay { display: none !important; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 12px; }
  .pnl-sheet { padding: 24px 16px; }
  .title-row { flex-wrap: wrap; gap: 8px; }
  h1 { font-size: 18px; }
  .chip { padding: 4px 10px; font-size: 11px; }
  .pnl-title h2 { font-size: 17px; }
  .pnl-table td.num { min-width: 90px; }
  .modal { width: 95%; }
  .modal-header { padding: 12px 16px; }
  .modal-body { padding: 12px 16px 16px; }
}
