* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", "Malgun Gothic", sans-serif;
  background: #f5f6fa;
  color: #222;
  line-height: 1.5;
}
a { color: #4a6cf7; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: linear-gradient(135deg, #4a6cf7 0%, #6b4ef7 100%);
  color: white;
  padding: 14px 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { color: white; font-size: 20px; font-weight: 700; }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a { color: white; }
.user-info { opacity: 0.9; font-size: 14px; }
.link-btn {
  background: none; border: 1px solid rgba(255,255,255,0.4);
  color: white; padding: 6px 12px; border-radius: 4px; cursor: pointer;
  font-size: 14px;
}
.link-btn:hover { background: rgba(255,255,255,0.15); }

.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }
.container.narrow { max-width: 600px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; gap: 16px;
}
.page-header h1 { margin: 0 0 4px 0; }
.page-header .desc { color: #666; margin: 0; }
.header-actions { display: flex; gap: 8px; }

h1 { margin-top: 0; }
.empty {
  text-align: center; padding: 60px 20px;
  background: white; border-radius: 12px;
}
.empty p { color: #666; }

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.ledger-card {
  background: white; padding: 20px; border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: transform .15s, box-shadow .15s;
  display: block; color: #222;
}
.ledger-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.1);
  text-decoration: none;
}
.ledger-card h3 { margin: 0 0 6px 0; color: #4a6cf7; }
.ledger-card .desc { color: #666; margin: 0 0 12px 0; font-size: 14px; }
.ledger-card .meta {
  display: flex; justify-content: space-between;
  color: #888; font-size: 13px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border: 1px solid #ccc; background: white;
  border-radius: 6px; cursor: pointer; font-size: 14px;
  color: #333; text-decoration: none;
}
.btn:hover { background: #f0f0f0; text-decoration: none; }
.btn-primary { background: #4a6cf7; color: white; border-color: #4a6cf7; }
.btn-primary:hover { background: #3a5ce5; color: white; }
.btn-danger { background: #e74c3c; color: white; border-color: #e74c3c; }
.btn-danger:hover { background: #c0392b; color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 6px; font-size: 10px; line-height: 1; min-width: 24px; }
.btn-disabled {
  opacity: 0.3; cursor: default; pointer-events: none;
  border: 1px solid #ddd; background: #fafafa; color: #999;
}
.move-btns {
  display: inline-flex; flex-direction: column; gap: 2px;
  margin-right: 4px; vertical-align: middle;
}
.move-form { display: inline; margin: 0; padding: 0; }
.btn-block { width: 100%; }

form label {
  display: block;
  margin-bottom: 14px;
  font-weight: 500;
  color: #333;
}
form input[type=text], form input[type=password], form input[type=number],
form input[type=date], form textarea, form select {
  display: block; width: 100%; padding: 8px 10px;
  border: 1px solid #ccc; border-radius: 6px;
  margin-top: 4px; font-size: 14px; font-family: inherit;
}
form input[type=file] { margin-top: 4px; }
form label.checkbox { display: flex; align-items: center; gap: 8px; }
form label.checkbox input { width: auto; margin: 0; }

.row { display: flex; gap: 12px; }
.row .col { flex: 1; }

.form-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid #eee;
}

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4a6cf7 0%, #6b4ef7 100%);
}
.auth-card {
  background: white; padding: 40px 32px; border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  width: 100%; max-width: 380px;
}
.auth-card h1 { text-align: center; color: #4a6cf7; margin-top: 0; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-error { background: #fdecea; color: #c0392b; border: 1px solid #f5b7b1; }
.alert-success { background: #e9f7ef; color: #27ae60; border: 1px solid #abebc6; }
.alert-info { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }

.month-nav {
  display: flex; align-items: center; gap: 8px;
  background: white; padding: 12px; border-radius: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.view-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  background: white; padding: 4px; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.view-tabs .tab {
  flex: 1; text-align: center; padding: 10px;
  border-radius: 6px; color: #555; font-weight: 500;
  transition: background .15s;
}
.view-tabs .tab:hover { background: #f5f6fa; text-decoration: none; }
.view-tabs .tab.active {
  background: #4a6cf7; color: white;
}
.view-tabs .tab.active:hover { background: #3a5ce5; }
.all-label { color: #333; font-size: 14px; }
.all-label strong { color: #4a6cf7; }
.pagination {
  display: flex; gap: 4px; justify-content: center;
  margin-top: 20px; padding: 16px; background: white;
  border-radius: 8px; align-items: center; flex-wrap: wrap;
}
.page-info { margin-left: 12px; color: #666; font-size: 13px; }
.month-nav select {
  width: auto; padding: 6px 8px;
}
.inline-filter {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; flex-wrap: wrap;
}
.filter-tag {
  padding: 4px 10px; border-radius: 14px; font-size: 13px;
  background: #fff; border: 1px solid #c7d2fe;
}
.filter-tag.filter-category { color: #4a6cf7; background: #eef2ff; }
.filter-tag.filter-account { color: #2e7d32; background: #e8f5e9; border-color: #c8e6c9; }
.filter-tag strong { font-weight: 700; }

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.summary-box {
  background: white; padding: 16px; border-radius: 8px;
  text-align: center;
}
.summary-box .label { color: #666; font-size: 13px; }
.summary-box .value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.summary-box.income .value { color: #27ae60; }
.summary-box.expense .value { color: #e74c3c; }
.summary-box.balance .value { color: #4a6cf7; }

.entry-list {
  background: white; border-radius: 8px; overflow: hidden;
}
.entry-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 16px; padding: 14px 16px;
  border-bottom: 1px solid #eee;
  align-items: flex-start;
}
.entry-row:last-child { border-bottom: none; }
.entry-date { color: #666; font-size: 13px; padding-top: 4px; }
.entry-line {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.tag {
  background: #eef2ff; color: #4a6cf7;
  padding: 2px 8px; border-radius: 10px; font-size: 12px;
}
.tag-link { cursor: pointer; text-decoration: none; }
.tag-link:hover { background: #dbe3ff; text-decoration: none; }
.tag-account {
  background: #e8f5e9; color: #2e7d32;
  border: 1px solid #c8e6c9;
}
.account-note {
  color: #555; font-size: 13px; margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f5f5f5; padding: 3px 8px; border-radius: 4px;
  display: inline-block;
}
.entry-time { color: #999; font-size: 11px; margin-top: 2px; }
.entry-meta-line { color: #777; font-size: 12px; margin-top: 4px; }
.entry-meta-line span { margin-right: 4px; }

.bulk-summary {
  background: #f5f6fa; padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; display: flex; gap: 20px; flex-wrap: wrap;
  font-size: 14px;
}
.bulk-preview-table { overflow-x: auto; margin-bottom: 16px; }
.bulk-preview-table .table { min-width: 900px; }
.bulk-preview-table th, .bulk-preview-table td { white-space: nowrap; font-size: 13px; }
.bulk-errors {
  background: #fdecea; border: 1px solid #f5b7b1; border-radius: 8px;
  padding: 12px 16px; margin-bottom: 16px;
}
.bulk-errors h3 { margin-top: 0; color: #c0392b; font-size: 15px; }
.bulk-errors code {
  background: white; padding: 1px 4px; border-radius: 3px;
  font-size: 12px; color: #c0392b;
}
.bulk-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.text-danger { color: #e74c3c; }
.text-success { color: #27ae60; }
.active-filter {
  background: #eef2ff; border: 1px solid #c7d2fe;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.amount { font-size: 17px; font-weight: 700; }
.entry-row.income .amount { color: #27ae60; }
.entry-row.expense .amount { color: #e74c3c; }
.memo { color: #555; font-size: 14px; margin-top: 4px; }
.entry-images {
  margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap;
}
.entry-images img {
  width: 70px; height: 70px; object-fit: cover;
  border-radius: 6px; border: 1px solid #eee;
}
.entry-actions { display: flex; gap: 6px; flex-shrink: 0; }

.table {
  width: 100%; background: white; border-collapse: collapse;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.table th, .table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid #eee; font-size: 14px;
}
.table th { background: #f5f6fa; color: #555; font-weight: 600; }
.inline-form { display: flex; gap: 4px; }
.inline-form input { width: 120px; }
.muted { color: #999; font-size: 12px; }

.image-list {
  border: 1px solid #eee; border-radius: 6px; padding: 10px;
  margin-bottom: 14px;
}
.image-list legend { padding: 0 6px; color: #666; font-size: 13px; }
.img-check {
  display: inline-block; margin: 0 8px 8px 0; position: relative;
  font-weight: normal;
}
.img-check input { position: absolute; top: 4px; left: 4px; }
.img-check img {
  width: 80px; height: 80px; object-fit: cover;
  border-radius: 4px; border: 1px solid #ddd;
}

hr { border: 0; border-top: 1px solid #eee; margin: 20px 0; }

.search-form {
  background: white; padding: 20px; border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06); margin-bottom: 20px;
}
.search-results { margin-top: 24px; }
.results-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 12px;
}
.results-header h2 { margin: 0; font-size: 18px; }
.result-summary { display: flex; gap: 16px; font-weight: 600; font-size: 14px; }
.result-summary .income { color: #27ae60; }
.result-summary .expense { color: #e74c3c; }
.result-summary .balance { color: #4a6cf7; }
.ledger-link {
  background: #fff8e1; color: #b8860b;
  padding: 2px 8px; border-radius: 10px; font-size: 12px;
  border: 1px solid #f0e2b0;
}
.ledger-link:hover { background: #ffecb3; text-decoration: none; }

.resize-list { margin-top: 10px; }
.resize-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px; background: #f9fafc; border: 1px solid #e5e8ef;
  border-radius: 8px; margin-bottom: 8px;
}
.resize-thumb {
  width: 70px; height: 70px; object-fit: cover;
  border-radius: 6px; border: 1px solid #ddd; flex-shrink: 0;
}
.resize-body { flex: 1; min-width: 0; }
.resize-name {
  font-size: 13px; font-weight: 600; color: #333;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.resize-info { font-size: 12px; color: #666; margin: 2px 0 6px; }
.resize-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px;
}
.resize-controls label { margin: 0; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.resize-controls select {
  width: auto; padding: 4px 6px; font-size: 13px; margin: 0;
}
.resize-preview { color: #4a6cf7; font-size: 12px; }

@media (max-width: 640px) {
  .entry-row { grid-template-columns: 80px 1fr; }
  .entry-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .summary { grid-template-columns: 1fr; }
}
