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

:root {
  --green:      #16a34a;
  --green-bg:   #dcfce7;
  --blue:       #2563eb;
  --blue-bg:    #dbeafe;
  --amber:      #d97706;
  --amber-bg:   #fef3c7;
  --red:        #dc2626;
  --red-bg:     #fee2e2;
  --grey-50:    #f8fafc;
  --grey-100:   #f1f5f9;
  --grey-200:   #e2e8f0;
  --grey-400:   #94a3b8;
  --grey-500:   #64748b;
  --grey-600:   #475569;
  --grey-700:   #334155;
  --grey-800:   #1e293b;
  --grey-900:   #0f172a;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 1px 3px rgba(0,0,0,.1);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);
  --sidebar-w:  220px;
  --sidebar-bg: #0f172a;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--grey-800); background: var(--grey-50); min-height: 100vh; }

/* ── Layout ── */
#app-shell { display: flex; min-height: 100vh; }
#sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); position: fixed; top: 0; left: 0; bottom: 0; display: flex; flex-direction: column; z-index: 100; }
#main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

/* ── Sidebar ── */
.sidebar-header { padding: 1.25rem 1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: .95rem; font-weight: 700; color: white; }
.logo-sub  { font-size: .7rem; color: rgba(255,255,255,.4); }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-section { margin-bottom: .5rem; }
.nav-section-label { font-size: .65rem; font-weight: 700; color: rgba(255,255,255,.3); text-transform: uppercase; letter-spacing: .08em; padding: .4rem 1rem .2rem; }
.nav-link { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; color: rgba(255,255,255,.6); text-decoration: none; font-size: .85rem; font-weight: 500; transition: all .15s; border-radius: 0; }
.nav-link:hover { background: rgba(255,255,255,.06); color: white; }
.nav-link.active { background: rgba(255,255,255,.1); color: white; font-weight: 600; }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-footer { padding: .75rem 0; border-top: 1px solid rgba(255,255,255,.08); }

/* ── Page ── */
.page-header { background: white; border-bottom: 1px solid var(--grey-200); padding: 1.2rem 2rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.page-header h1 { font-size: 1.2rem; font-weight: 700; }
.page-header p { font-size: .85rem; color: var(--grey-500); margin-top: .1rem; }
.page-body { padding: 1.5rem 2rem; }

/* ── Cards ── */
.card { background: white; border-radius: var(--radius-lg); border: 1.5px solid var(--grey-200); padding: 1.25rem; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: white; border: 1.5px solid var(--grey-200); border-radius: var(--radius-lg); padding: 1rem 1.25rem; }
.stat-label { font-size: .72rem; font-weight: 700; color: var(--grey-400); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--grey-900); line-height: 1; }
.stat-sub   { font-size: .75rem; color: var(--grey-500); margin-top: .2rem; }
.stat-card.green { border-color: var(--green); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.blue  { border-color: var(--blue); }
.stat-card.blue  .stat-value { color: var(--blue); }
.stat-card.amber { border-color: var(--amber); }
.stat-card.amber .stat-value { color: var(--amber); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius); font-size: .85rem; font-weight: 600; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap; }
.btn-primary   { background: var(--green); color: white; border-color: var(--green); }
.btn-primary:hover { background: #15803d; }
.btn-secondary { background: white; color: var(--grey-700); border-color: var(--grey-200); }
.btn-secondary:hover { background: var(--grey-50); border-color: var(--grey-400); }
.btn-danger    { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-ghost     { background: transparent; color: var(--grey-500); border-color: transparent; }
.btn-ghost:hover { background: var(--grey-100); color: var(--grey-700); }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .78rem; font-weight: 700; color: var(--grey-600); }
input, select, textarea {
  padding: .5rem .75rem;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  background: white;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.form-grid .span2 { grid-column: span 2; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: .72rem; font-weight: 700; color: var(--grey-500); text-transform: uppercase; letter-spacing: .05em; padding: .6rem .75rem; text-align: left; border-bottom: 1.5px solid var(--grey-200); white-space: nowrap; }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--grey-100); font-size: .85rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--grey-50); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop.hidden { display: none; }
.modal { background: white; border-radius: var(--radius-lg); padding: 1.5rem; width: 90%; max-width: 480px; box-shadow: var(--shadow-md); }
.modal h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--grey-900); color: white; padding: .65rem 1rem; border-radius: var(--radius); font-size: .85rem; font-weight: 500; animation: slideIn .2s ease; }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--grey-50); }
.login-card { background: white; border-radius: var(--radius-lg); border: 1.5px solid var(--grey-200); padding: 2rem; width: 100%; max-width: 360px; }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo .icon { font-size: 2.5rem; }
.login-logo h1 { font-size: 1.3rem; font-weight: 800; margin-top: .4rem; }
.login-logo p  { font-size: .8rem; color: var(--grey-400); }
.login-error { color: var(--red); font-size: .82rem; margin-top: .75rem; text-align: center; }

/* ── Monthly chart ── */
.month-bar-wrap { display: flex; flex-direction: column; gap: .5rem; }
.month-row { display: flex; align-items: center; gap: .75rem; }
.month-label { font-size: .78rem; font-weight: 600; color: var(--grey-600); min-width: 90px; }
.bar-track { flex: 1; background: var(--grey-100); border-radius: 999px; height: 12px; position: relative; overflow: hidden; }
.bar-elec  { background: var(--green); height: 100%; border-radius: 999px; transition: width .4s; }
.bar-petrol { background: var(--amber); height: 100%; border-radius: 999px; transition: width .4s; position: absolute; top: 0; }
.month-total { font-size: .78rem; font-weight: 700; color: var(--grey-700); min-width: 50px; text-align: right; }

/* ── Mobile hamburger ── */
#mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #sidebar {
    display: flex;
    width: 75vw;
    max-width: 260px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
  }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  .page-body { padding: 1rem; }
  #mobile-menu-btn { display: flex; }
  .page-header { gap: .75rem; }
}
