* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  color: #111111;
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

#app { height: 100vh; display: flex; }

/* ── Auth ── */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #f5f5f5;
  z-index: 100;
}
.auth-card {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-logo { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; margin-bottom: 28px; color: #111111; }
.auth-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; color: #111111; }
.auth-sub { color: #666666; margin-bottom: 28px; font-size: 14px; }

/* ── Sidebar ── */
.sidebar {
  width: 220px; min-width: 220px;
  background: #1e1e2e;
  display: flex; flex-direction: column;
  padding: 16px 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 4px 16px 20px; font-size: 15px; font-weight: 600; color: #ffffff; }
.nav-section { margin-bottom: 4px; }
.nav-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: #888888; text-transform: uppercase; padding: 8px 16px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; color: #cccccc; text-decoration: none; font-size: 13.5px; transition: background 0.1s, color 0.1s; }
.nav-item:hover { background: #2d2d42; color: #ffffff; }
.nav-item.active { background: #4f46e5; color: #ffffff; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid #333355; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #aaaaaa; }

/* ── Content ── */
.content { flex: 1; overflow-y: auto; padding: 28px 32px; background: #f5f5f5; }

/* ── View header ── */
.view-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.view-header h2 { font-size: 20px; font-weight: 600; color: #111111; }
.view-header p { color: #666666; font-size: 13px; margin-top: 2px; }

/* ── Metric cards ── */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.metric-card { background: #ffffff; border: 1px solid #e0e0e0; border-radius: 12px; padding: 20px; }
.metric-card .metric-label { font-size: 11px; color: #888888; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.metric-card .metric-value { font-size: 26px; font-weight: 700; color: #111111; }
.metric-card .metric-sub { font-size: 12px; color: #888888; margin-top: 4px; }
.metric-card.green .metric-value { color: #059669; }
.metric-card.red .metric-value { color: #dc2626; }
.metric-card.amber .metric-value { color: #d97706; }
.metric-card.blue .metric-value { color: #2563eb; }

/* ── Cards ── */
.card { background: #ffffff; border: 1px solid #e0e0e0; border-radius: 12px; margin-bottom: 20px; overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #e0e0e0; display: flex; align-items: center; justify-content: space-between; background: #ffffff; }
.card-header h3 { font-size: 14px; font-weight: 600; color: #111111; }
.card-body { padding: 20px; color: #111111; background: #ffffff; }
.card-body.no-pad { padding: 0; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; color: #888888; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid #e0e0e0; white-space: nowrap; background: #fafafa; }
td { padding: 11px 16px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; color: #111111; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
tfoot td { background: #f5f5f5; color: #111111; }

.amount-credit { color: #059669; font-weight: 600; }
.amount-debit { color: #111111; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ── Forms ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #444444; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: #ffffff; border: 1px solid #d0d0d0;
  border-radius: 8px; color: #111111; padding: 9px 12px;
  font-size: 13px; transition: border-color 0.15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
input::placeholder { color: #aaaaaa; }
select option { background: #ffffff; color: #111111; }
.fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Buttons ── */
button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: background 0.15s, opacity 0.15s;
  text-decoration: none; font-family: inherit;
}
.btn-primary { background: #4f46e5; color: #ffffff; }
.btn-primary:hover { background: #4338ca; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: #ffffff; color: #444444; border: 1px solid #d0d0d0; }
.btn-ghost:hover { background: #f5f5f5; }
.btn-ghost:disabled { opacity: 0.5; }
.btn-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.full-width { width: 100%; justify-content: center; }
.small { padding: 4px 10px; font-size: 12px; }

/* ── Upload ── */
.upload-zone {
  border: 2px dashed #d0d0d0; border-radius: 12px;
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; background: #fafafa;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: #4f46e5; background: #ede9fe; }
.upload-zone p { color: #555555; }
.upload-zone .upload-hint { font-size: 12px; color: #888888; margin-top: 6px; }
.upload-zone .upload-icon { color: #aaaaaa; margin-bottom: 12px; }

/* ── Filters ── */
.filters-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters-bar input, .filters-bar select { width: auto; min-width: 140px; }
.filters-bar input[type="search"] { min-width: 220px; }

/* ── Category select inline ── */
.cat-cell { min-width: 220px; width: 220px; white-space: nowrap; }
.cat-select { background: #f5f5f5; border: 1px solid #d0d0d0; color: #111111; border-radius: 4px; padding: 3px 6px; font-size: 12px; cursor: pointer; min-width: 240px; width: 100%; }

/* ── Progress ── */
.progress-bar { height: 6px; background: #e0e0e0; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; border-radius: 3px; background: #4f46e5; transition: width 0.3s; }

/* ── Charts ── */
.chart-container { position: relative; height: 260px; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #ffffff; border: 1px solid #e0e0e0;
  border-radius: 8px; padding: 12px 18px; font-size: 13px;
  z-index: 999; max-width: 320px; transition: opacity 0.3s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); color: #111111;
}
#toast.success { border-color: #059669; color: #065f46; }
#toast.error { border-color: #dc2626; color: #991b1b; }
#toast.hidden { opacity: 0; pointer-events: none; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid #e0e0e0; font-size: 12px; color: #888888; background: #fafafa; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 24px; color: #aaaaaa; }
.empty-state h3 { font-size: 16px; color: #666666; margin-bottom: 6px; }
.empty-state p { color: #aaaaaa; }

/* ── Error ── */
.error-msg { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal { background: #ffffff; border: 1px solid #e0e0e0; border-radius: 12px; padding: 28px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: #111111; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── P&L ── */
.pl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.pl-section h4 { font-size: 13px; font-weight: 600; color: #888888; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.pl-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; color: #111111; }
.pl-row:last-child { border-bottom: none; }
.pl-total { display: flex; justify-content: space-between; padding: 10px 0 0; font-weight: 700; font-size: 14px; border-top: 1px solid #d0d0d0; margin-top: 4px; color: #111111; }

/* ── Utils ── */
.hidden { display: none !important; }
.text-muted { color: #888888; }
.text-small { font-size: 12px; }
.flex { display: flex; align-items: center; }
.flex-gap { gap: 8px; }
.ml-auto { margin-left: auto; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

@media (max-width: 900px) {
  .sidebar { width: 52px; min-width: 52px; }
  .sidebar-logo span, .nav-label, .nav-item span, .sidebar-footer span { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .content { padding: 20px 16px; }
  .pl-grid, .two-col { grid-template-columns: 1fr; }
  .fields-row, .fields-row-3 { grid-template-columns: 1fr; }
}

/* ── Reports additions ───────────────────────────────────── */
.action-group { display: flex; gap: 8px; }
.pl-header-print { display: none; }

@media print {
  .sidebar, .no-print { display: none !important; }
  .content { margin: 0 !important; padding: 20px !important; }
  .pl-header-print { display: block; text-align: center; margin-bottom: 24px; }
  .pl-header-print h1 { font-size: 18px; margin: 0 0 4px 0; }
  .pl-header-print p { font-size: 12px; color: #666; margin: 0; }
  .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ddd !important; }
  .metric-card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* Fix: main-app must be flex so sidebar + content sit side by side */
#main-app { display: flex; min-height: 100vh; }
#main-app .content { flex: 1; min-width: 0; }

/* Fix: main-app must be flex so sidebar + content sit side by side */
#main-app { display: flex; min-height: 100vh; }
#main-app .content { flex: 1; min-width: 0; }

body #main-app { display: flex !important; min-height: 100vh; width: 100%; }
