/* Budget System — dark theme */
:root {
  --bg: #0f1419;
  --bg-alt: #161c24;
  --panel: #1c232c;
  --panel-2: #242c37;
  --border: #2a3340;
  --border-strong: #3a4555;
  --text: #e3e8f0;
  --text-dim: #94a0b3;
  --text-muted: #6b7585;
  --accent: #4a90d9;
  --accent-2: #27ae60;
  --danger: #e74c3c;
  --warn: #f39c12;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: 18px 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav a {
  display: block;
  padding: 10px 20px;
  color: var(--text-dim);
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.sidebar-nav a:hover {
  background: var(--panel);
  color: var(--text);
}
.sidebar-nav a.active {
  background: var(--panel);
  color: var(--text);
  border-left-color: var(--accent);
}
.sidebar-nav .group-label {
  padding: 14px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.sidebar-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}
.sidebar-foot a { color: var(--text); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.content { padding: 24px; flex: 1; }

/* Cards / panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel-head h2, .panel-head h3 { margin: 0; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}
.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 24px;
  font-weight: 700;
}
.stat-card .sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.stat-card.green .value { color: var(--accent-2); }
.stat-card.red .value { color: var(--danger); }
.stat-card.blue .value { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3a7dc8; }
.btn-success { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-success:hover { background: #229b54; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=color],
select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
input[type=color] { padding: 2px; height: 38px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}

/* Tables */
table.t {
  width: 100%;
  border-collapse: collapse;
}
table.t th, table.t td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.t th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  font-weight: 600;
}
table.t tbody tr:hover {
  background: rgba(255,255,255,0.02);
}
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
table.t .num.neg { color: var(--danger); }
table.t .num.pos { color: var(--accent-2); }

/* Badge / chip */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--panel-2);
}
.chip-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* Modal */
.modal-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h3 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
}
.modal-body { padding: 20px; }

/* Flash messages */
.flashes {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}
.flashes li {
  padding: 10px 14px;
  border-radius: 5px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.flashes li.success { background: rgba(39,174,96,0.15); border-color: var(--accent-2); }
.flashes li.error { background: rgba(231,76,60,0.15); border-color: var(--danger); }
.flashes li.info { background: rgba(74,144,217,0.15); border-color: var(--accent); }

/* Login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg), var(--bg-alt));
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}
.login-card .tag { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }

/* Progress bars */
.progress {
  background: var(--bg);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--accent-2);
  transition: width 0.3s;
}
.progress-fill.warn { background: var(--warn); }
.progress-fill.danger { background: var(--danger); }

/* Utilities */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; gap: 12px; align-items: center; }
.grow { flex: 1; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* Filters bar */
.filters {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters > * { flex: 0 0 auto; }
.filters .form-group { margin: 0; }
.filters input, .filters select { min-width: 140px; }

/* Mobile responsive */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .sidebar-nav { display: flex; overflow-x: auto; padding: 8px 12px; }
  .sidebar-nav a {
    padding: 8px 12px;
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .sidebar-nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .sidebar-nav .group-label { display: none; }
  .sidebar-foot { display: none; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 20px; }
}
