:root {
  --bg: #f2f6fc;
  --card-bg: #ffffff;
  --primary: #1565c0;
  --primary-dark: #0d3c74;
  --income: #2e7d32;
  --expense: #c62828;
  --profit: #1565c0;
  --border: #dde5f0;
  --text: #1c2b3a;
  --muted: #64748b;
  --radius: 10px;
  --warn: #ef6c00;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar nav { display: flex; flex-direction: column; margin-top: 8px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  color: #dbe9fb;
  padding: 10px 20px;
  font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); }
.sidebar nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-section-label {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  padding: 14px 20px 4px;
}
.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.logout-link { color: #ffcdd2; }
.role-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}
.role-badge.role-admin { background: var(--primary); color: #fff; }
.role-badge.role-viewer { background: #78828d; color: #fff; }

/* Content */
.content { flex: 1; padding: 28px 34px; max-width: 1300px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin-bottom: 24px; font-size: 14px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.summary-card .label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary-card .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.summary-card.income .value { color: var(--income); }
.summary-card.expense .value { color: var(--expense); }
.summary-card.profit .value { color: var(--profit); }
.summary-card.warn .value { color: var(--warn); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fbfcfd; }
.text-right { text-align: right; }
.amount-income { color: var(--income); font-weight: 600; }
.amount-expense { color: var(--expense); font-weight: 600; }
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-profit { background: #e6f4ea; color: var(--income); }
.badge-loss { background: #fdecea; color: var(--expense); }
.badge-none { background: #eceff1; color: var(--muted); }
.badge-warn { background: #fff3e0; color: var(--warn); }
.badge-info { background: #e3f2fd; color: var(--profit); }

/* Status badges (projects) */
.badge-status-Planned { background: #eceff1; color: var(--muted); }
.badge-status-InProgress, .badge-status-progress { background: #e3f2fd; color: var(--profit); }
.badge-status-OnHold { background: #fff3e0; color: var(--warn); }
.badge-status-Completed { background: #e6f4ea; color: var(--income); }

/* Forms */
form.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--primary-dark); }
.btn.btn-danger { background: var(--expense); }
.btn.btn-secondary { background: #78828d; }
.btn.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #e6f4ea; color: #1b5e20; border: 1px solid #b8dfc2; }
.alert-error { background: #fdecea; color: #b71c1c; border: 1px solid #f3c1bc; }
.alert-info { background: #e3f2fd; color: #0d47a1; border: 1px solid #bbdefb; }

/* Chart bars (pure CSS, no JS dependency) */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; margin-top: 10px; }
.bar-chart .bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bars { display: flex; gap: 2px; align-items: flex-end; height: 130px; }
.bar-chart .bar { width: 8px; border-radius: 2px 2px 0 0; }
.bar-chart .bar.income { background: var(--income); }
.bar-chart .bar.expense { background: var(--expense); }
.bar-chart .bar-label { font-size: 10px; color: var(--muted); margin-top: 6px; }

/* Simple horizontal bars (category breakdowns, P&L, inventory) */
.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.hbar-row .hbar-label { width: 160px; flex-shrink: 0; color: var(--text); }
.hbar-row .hbar-track { flex: 1; background: #eef1f4; border-radius: 4px; overflow: hidden; height: 14px; }
.hbar-row .hbar-fill { height: 100%; border-radius: 4px; }
.hbar-row .hbar-fill.income { background: var(--income); }
.hbar-row .hbar-fill.expense { background: var(--expense); }
.hbar-row .hbar-value { width: 110px; text-align: right; flex-shrink: 0; font-weight: 600; }

.pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: 6px; border: 1px solid var(--border); font-size: 13px; }
.pagination a { background: #fff; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Login page */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d3c74, #1565c0);
}
.login-box {
  background: #fff;
  padding: 36px 34px;
  border-radius: 12px;
  width: 340px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.login-box h1 { text-align: center; margin-bottom: 6px; }
.login-box .subtitle { text-align: center; margin-bottom: 22px; }
.login-box .btn { width: 100%; margin-top: 10px; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .nav-section-label { padding: 10px 12px 4px; }
  .content { padding: 18px; }
}
