/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #F5F6FA;
  --sidebar-bg: #1A1D2E;
  --sidebar-active: #2D6A4F;
  --sidebar-hover: #252840;
  --accent: #2D6A4F;
  --accent-light: #52B788;
  --text: #1E2235;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --white: #FFFFFF;
  --danger: #EF4444;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px; min-width: 240px; background: var(--sidebar-bg); color: #CBD5E1;
  display: flex; flex-direction: column; padding: 0; overflow-y: auto;
}
.sidebar-logo { padding: 20px 20px 12px; font-size: 15px; font-weight: 700; color: #fff; border-bottom: 1px solid #2a2f4a; }
.sidebar-logo span { color: var(--accent-light); }
.sidebar-section { padding: 12px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: #4B5563; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px;
  color: #94A3B8; text-decoration: none; font-size: 13.5px; transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar-months { padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-months a {
  padding: 7px 10px; border-radius: 6px; font-size: 13px; color: #94A3B8;
  text-decoration: none; transition: background .15s, color .15s;
}
.sidebar-months a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-months a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar-party-filter { padding: 4px 8px 8px; }
.sidebar-party-filter select {
  width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid #2a2f4a;
  background: #252840; color: #CBD5E1; font-size: 13px; outline: none;
}

/* Main content */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Topbar */
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 7px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: none; transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: #E8F5E9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }

/* Flash messages */
.flash { padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.flash-error   { background: #FEE2E2; color: #991B1B; }
.flash-success { background: #D1FAE5; color: #065F46; }
.flash-info    { background: #DBEAFE; color: #1E40AF; }

/* 2FA warning banner */
.warning-banner {
  background: #FFFBEB; border-bottom: 1px solid #FDE68A; color: #92400E;
  padding: 10px 24px; font-size: 13px; display: flex; align-items: center; gap: 8px;
}

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 20px 24px 0; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-value.negative { color: var(--danger); }
.stat-value.positive { color: var(--accent); }
.stat-icon { font-size: 20px; margin-bottom: 4px; }

/* Content area */
.content { flex: 1; padding: 20px 24px 24px; overflow-y: auto; }

/* Card */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 11px 12px; text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-muted); background: #F8F9FB; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; cursor: pointer; }
tbody tr:hover { background: #F0FDF4; }
tbody tr.editing { background: #F0FDF4; }
tbody td { padding: 10px 12px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* Inline edit inputs */
.edit-input {
  width: 100%; padding: 4px 7px; border: 1.5px solid var(--accent-light);
  border-radius: 5px; font-size: 13px; outline: none; background: #fff;
}
.edit-input:focus { border-color: var(--accent); }

/* Category badges */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11.5px;
  font-weight: 600; white-space: nowrap;
}
.badge-transport   { background: #DBEAFE; color: #1D4ED8; }
.badge-food        { background: #FEF3C7; color: #92400E; }
.badge-grocery     { background: #D1FAE5; color: #065F46; }
.badge-hosting     { background: #D1FAE5; color: #065F46; }
.badge-software    { background: #EDE9FE; color: #5B21B6; }
.badge-rent        { background: #FFE4E6; color: #9F1239; }
.badge-marketing   { background: #FCE7F3; color: #831843; }
.badge-internet    { background: #E0F2FE; color: #075985; }
.badge-telecom     { background: #CFFAFE; color: #155E75; }
.badge-misc        { background: #F3F4F6; color: #374151; }
.badge-income      { background: #D1FAE5; color: #065F46; }
.badge-expense     { background: #FEE2E2; color: #991B1B; }

/* Amount coloring */
.amount-expense { color: var(--danger); font-weight: 600; }
.amount-income  { color: var(--accent); font-weight: 600; }

/* Add row */
.add-row td { background: #F8FFF9; }
.add-row td input, .add-row td select {
  width: 100%; padding: 5px 7px; border: 1.5px solid var(--border);
  border-radius: 5px; font-size: 13px; outline: none;
}
.add-row td input:focus, .add-row td select:focus { border-color: var(--accent-light); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: 12px; padding: 28px 28px 24px;
  width: 380px; max-width: 95vw; box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal input {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 14px; outline: none; margin-bottom: 14px;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Summary page */
.chart-container { padding: 20px; max-height: 340px; }
.summary-matrix { overflow-x: auto; }
.summary-matrix table { font-size: 13px; width: 100%; border-collapse: collapse; table-layout: fixed; }
.summary-matrix th { text-align: center; padding: 10px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-matrix td { text-align: center; padding: 8px 12px; white-space: nowrap; }
.summary-matrix td:first-child, .summary-matrix th:first-child { font-weight: 500; width: 160px; text-align: right; }
.summary-matrix td:last-child, .summary-matrix th:last-child { font-weight: 700; }
.cell-value { text-align: center; }
.row-total { font-weight: 700; color: var(--accent); text-align: center; }

/* Manage lists */
.lists-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.list-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-card-header { padding: 12px 16px; background: #F8F9FB; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.list-items { padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; }
.list-item-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.list-item-row:last-child { border-bottom: none; }
.list-add-form { padding: 10px 16px 14px; display: flex; gap: 8px; }
.list-add-form input { flex: 1; padding: 6px 10px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
.list-add-form input:focus { border-color: var(--accent-light); }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 200px; min-width: 200px; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .stats-row { grid-template-columns: 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

/* Attachment badge */
.att-count-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent); color: #fff;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  padding: 1px 5px; line-height: 1.4; pointer-events: none;
}

/* Attachment panel — hidden by default, opened via .panel-open class */
.attach-panel { display: none !important; }
.attach-panel.panel-open { display: table-row !important; }
.attach-panel td { padding: 0; }
.attach-panel-inner {
  padding: 12px 16px; background: #F0FDF4;
  border-bottom: 2px solid #86EFAC;
}
.att-list { display: flex; flex-direction: column; gap: 2px; }
.att-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid #D1FAE5; font-size: 13px;
}
.att-list-item:last-child { border-bottom: none; }
.att-empty { color: var(--text-muted); font-size: 13px; padding: 4px 0; }
.att-link { color: var(--accent); text-decoration: none; }
.att-link:hover { text-decoration: underline; }
.att-dropzone {
  margin-top: 10px; padding: 12px; border: 2px dashed #BBF7D0; border-radius: 8px;
  text-align: center; transition: all .2s; background: #FAFFFE;
}
.att-dropzone.att-dragover { border-color: var(--accent); background: #E6F9F1; }
.att-drop-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.att-drop-label i { margin-left: 4px; }
.att-upload-row {
  display: flex; gap: 8px; align-items: center; justify-content: center;
}
.att-upload-row input[type=file] { font-size: 13px; flex: 1; max-width: 250px; }
