:root {
  /* Brand — Contorizare Inteligentă (shared with the explorer) */
  --primary: #5DA66C;
  --primary-dark: #549561;
  --secondary: #00372F;
  --accent: #DA5D1E;
  --green-med: #98CF9D;
  --surface: #F3F5F2;

  /* Dark variants (brand-tinted) — default, like the explorer */
  --bg: #021a15;
  --bg2: #042A23;
  --bg3: #0a3d33;
  --text: #eff2ed;
  --text2: #9ca3af;
  --text-accent: #98CF9D;
  --chart-grid: #0e3a30;

  /* Semantic tokens derived from the theme */
  --card: var(--bg2);
  --muted: var(--text2);
  --border: #ffffff1f;
}

/* Light theme (matches the explorer's light palette) */
[data-theme="light"] {
  --bg: #F3F5F2;
  --bg2: #ffffff;
  --bg3: #e2e8e0;
  --text: #042A23;
  --text2: #6b7280;
  --text-accent: #549561;
  --chart-grid: #e2e8e0;
  --card: #ffffff;
  --muted: #6b7280;
  --border: #e2e8e0;
  --surface: #F3F5F2;
}

* { box-sizing: border-box; }
/* `hidden` must win over component display rules (e.g. .auth-wrap{display:flex}). */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: 'Onest', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── Login panel ── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #00372F 0%, #0a5a44 55%, #5DA66C 140%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
.logo {
  font-weight: 800;
  letter-spacing: .14em;
  font-size: 22px;
  color: var(--secondary);
  text-align: center;
}
.logo-sub {
  text-align: center;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .02em;
  margin-top: 2px;
  margin-bottom: 22px;
}
.panel h1 { font-size: 19px; margin: 0 0 6px; color: var(--secondary); }
.muted { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
label { display: block; margin: 16px 0 6px; font-size: 12.5px; font-weight: 600; }
input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}
input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
#otp { letter-spacing: .4em; text-align: center; font-weight: 700; }
button[type="submit"] {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
button[type="submit"]:hover { background: var(--primary-dark); }
.link {
  display: inline-block;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.link:hover { color: var(--text); text-decoration: underline; }
.msg { min-height: 20px; margin: 14px 0 0; font-size: 13.5px; color: var(--accent); text-align: center; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; font-weight: 400; color: var(--muted); cursor: pointer; }
.check input { width: auto; }

/* ── Dashboard header (explorer-style: theme + language switch) ── */
.app-header {
  background: var(--secondary);
  border-bottom: 2px solid var(--primary);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
[data-theme="light"] .app-header { background: var(--surface); border-bottom-color: var(--primary); }
.app-header h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
  margin: 0;
}
.app-header .meta { color: var(--text2); font-size: 11px; opacity: 0.7; }
.app-header #me-nlc { opacity: 1; color: var(--text-accent); font-weight: 600; }
.header-logout { color: var(--text2); margin-top: 0; }
[data-theme="light"] .header-logout { color: var(--muted); }

/* Theme + language switcher pills */
.theme-switcher {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border-radius: 9999px;
  padding: 3px;
}
#theme-switcher { margin-left: auto; }
.theme-switcher button {
  padding: 5px 12px;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  color: var(--text2);
  transition: all 0.15s;
}
.theme-switcher button.active { background: var(--primary); color: #fff; }
.theme-switcher button:hover:not(.active) { color: var(--text); }

/* Header on small screens: wrap the switchers to a second row instead of
   overflowing. Entry-level Android (320px) → iPhone Pro Max all fit. */
@media (max-width: 700px) {
  .app-header { flex-wrap: wrap; gap: 8px 10px; padding: 10px 14px; }
  #theme-switcher { margin-left: auto; }
}
@media (max-width: 480px) {
  .app-header .brand-sub { display: none; }
  .app-header h1 { font-size: 14px; }
  .theme-switcher button { padding: 5px 9px; font-size: 10px; }
}
.dash-grid {
  max-width: 1140px; margin: 22px auto; padding: 0 16px;
  display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start;
}
@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-main { min-width: 0; }
.dash-side {
  position: sticky; top: 20px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px;
}
.dash-side h3 { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--primary); margin: 0 0 4px; }
.small { font-size: 12px; }
#meters-history { list-style: none; padding: 0; margin: 14px 0; }
#meters-history li { padding: 10px 0; border-bottom: 1px solid var(--border); }
#meters-history li:last-child { border-bottom: none; }
.hist-id { font-family: ui-monospace, monospace; font-weight: 700; color: var(--text-accent); margin-right: 8px; }
.hist-range { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dash-side .note { margin: 6px 0 0; }
.badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.act { background: #e8f5e9; color: #15803d; }
.badge.dec { background: #fdecea; color: #b91c1c; }

#dashboard .card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; margin-bottom: 18px;
}
#dashboard .card h2 {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--primary); margin: 0 0 14px;
}
/* ── A–G consumption-class card (social comparison), from the explorer ── */
.comparison-card {
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}
.comparison-card h3 {
  font-family: 'Montserrat', sans-serif;
  font-size: 12px; font-weight: 600;
  color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.3px;
  margin: 0 0 12px;
}
.grade-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  font-family: 'Montserrat', sans-serif; font-size: 22px; font-weight: 700; color: #fff;
}
.grade-bar { display: flex; gap: 2px; margin-top: 10px; height: 8px; border-radius: 4px; overflow: hidden; }
.grade-bar div { flex: 1; transition: opacity 0.2s; }
.comparison-stat { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--text2); }
.comparison-stat strong { color: var(--text); font-weight: 600; }
.comparison-card .chip {
  display: inline-block; margin-top: 12px;
  font-size: 11px; line-height: 1.4; color: var(--text2);
  background: var(--bg3); border-radius: 8px; padding: 6px 10px;
}

/* Collapsible chart card (same mechanism as the explorer — calendar card). */
.collapsible-header { cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; }
.collapse-icon { transition: transform 0.2s; font-size: 14px; color: var(--muted); }
.collapsed .collapsible-body { display: none; }
.collapsed .collapse-icon { transform: rotate(-90deg); }
.collapsed.card h2 { margin-bottom: 0; }

.chart-scroll { overflow-x: auto; }
#calendar-chart { min-height: 320px; }
.chart { width: 100%; height: 320px; }
.chart.tall { height: 430px; }
.day-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.day-controls button {
  border: 1px solid var(--border); background: var(--bg3); color: var(--text); border-radius: 8px;
  width: 34px; height: 32px; cursor: pointer; font-size: 15px;
}
.day-controls input[type="date"] { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg3); color: var(--text); }
.clock-date { text-align: center; font-weight: 600; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.clock-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.clock-label { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.clock { width: 100%; height: 320px; }

/* ── Footer — reproduced from contorinteligent.energie.gov.md ──
   Dark-green band, white text, Montserrat headers, 12-col grid; same
   metrics as the source (80px padding, 4-col lists, 64px logos). Fixed
   colours regardless of theme, matching the institutional site. */
.cabinet-footer {
  background: #00372F;
  color: #fff;
  padding: 80px 0;
  font-weight: 300;
  font-size: 20px;
  line-height: 28px;
}
.cabinet-footer .cf-container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.cf-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1.5rem;
  row-gap: 2rem;
}
.cf-row:not(:last-child) {
  margin-bottom: 2rem;
  border-bottom: 1px solid #ffffff40;
  padding-bottom: 31px;
}
.cf-row-nav { display: flex; flex-direction: column; gap: 2rem; }
.cf-logo img { height: 4rem; width: auto; }
.cf-lists {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
  row-gap: 1.5rem;
}
.cf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.cf-head {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 18px;
  line-height: 24px;
  color: #fff;
  margin: 0 0 .25rem;
}
.cf-link { color: #fff; text-decoration: none; font-size: 16px; line-height: 22px; overflow-wrap: break-word; }
a.cf-link:hover { color: #549561; }
.cf-row-disc .cf-disclaimer {
  grid-column: span 6 / span 6;
  margin: 0;
  font-size: 20px;
  line-height: 28px;
  font-weight: 300;
}
.cf-logos {
  grid-column: span 6 / span 6;
  list-style: none; margin: 0; padding: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 9.67px;
}
.cf-logos img { height: 64px; width: auto; max-width: 100%; }
.cf-copy { grid-column: span 6 / span 6; margin: 0; color: #ffffffb3; font-size: 14px; line-height: 20px; }

@media (max-width: 820px) {
  .cabinet-footer { padding: 48px 0; }
  .cf-lists { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cf-row-disc .cf-disclaimer,
  .cf-logos,
  .cf-copy { grid-column: 1 / -1; }
  .cf-logos { flex-wrap: wrap; justify-content: flex-start; gap: 1.5rem; }
}
