/* ===== Root Variables ===== */
:root {
  --left-w: 240px; /* kept for future use */
  --left-w-collapsed: 56px;
  --right-w: 260px;
  --right-w-collapsed: 0px;
  --card-bg: #333;
  --text: #f0f0f0;
  --accent: #ffb347;
  --blue-accent: #76a8ff;
}

/* ===== Base Reset ===== */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #232526 0%, #414345 100%);
  color: var(--text);
}

/* ===== Sticky Page Header (full width) ===== */
#template-header {
  position: sticky; /* stays at top while scrolling */
  top: 0;
  z-index: 50;
  background: var(--card-bg);
  color: var(--text);
  padding: 12px 16px;
  margin: 0 20px 20px; /* aligns with grid padding */
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid #444;

  display: flex;
  align-items: center; /* vertically centres */
  justify-content: center; /* horizontally centres */
}

#template-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--accent);
  text-align: center; /* ⬅️ centres the text horizontally */
}
/* Left icon pinned inside the header */
#template-header .hdr-icon{
  position: absolute;
  left: 16px;              /* matches your header padding */
  top: 50%;
  transform: translateY(-50%);
  text-decoration: none;
  font-size: 1.1rem;       /* tweak size to taste */
  line-height: 1;
  opacity: 0.9;
}

#template-header .hdr-icon:hover{
  opacity: 1;
  filter: brightness(1.1);
}

/* ===== Grid: 2 across × 3 deep ===== */
#widget-zone {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* two across */
  grid-template-rows: repeat(3, minmax(340px, 1fr)); /* three equal rows */
  gap: 20px;
  padding: 0 20px 20px; /* top space comes from header margin-bottom */
  height: calc(100vh - 40px); /* fill viewport minus bottom padding */
}

/* ===== Widget Card (base) ===== */
section.widget {
  background: var(--card-bg);
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  min-height: 0; /* enables child overflow scroll */
}
section.widget:hover {
  box-shadow: 0 4px 16px #ffb34799;
  transform: translateY(-2px) scale(1.01);
}

/* ===== Widget Internal Header + Body ===== */
.widget-title {
  padding: 10px 14px;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid #444;
  background: rgba(255, 255, 255, 0.04);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}
.widget-body {
  flex: 1;
  padding: 12px;
  overflow: auto; /* keep the 2×3 grid fixed height */
  text-align: left; /* change to center if you want */
}

/* ===== (Optional) Headings used inside widgets ===== */
h4 {
  color: var(--accent);
  margin: 0 0 0.6rem;
}

/* ===== Tables inside widgets ===== */
.widget table {
  width: 100%;
  border-collapse: collapse;
  background: #232526;
  color: #fff;
}
.widget th,
.widget td {
  border: 1px solid #444;
  padding: 8px;
  text-align: center;
}
.widget th {
  background: var(--accent);
  color: #232526;
  font-weight: 700;
}
.widget tr:nth-child(even) {
  background: #2c2c2c;
}
.widget tr:hover {
  background: #444;
}

/* ===== Responsive (stack on small screens) ===== */
@media (max-width: 900px) {
  #template-header {
    margin: 0 12px 12px;
  }
  #widget-zone {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    height: auto;
    padding: 0 12px 12px;
    gap: 12px;
  }
}

/* === Widget form styling === */
.form-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.form-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px 14px;
}

.form-grid label {
  align-self: center;
  color: var(--text);
  opacity: 0.9;
  font-weight: 600;
}

.form-grid input[type="date"],
.form-grid input[type="number"],
.form-grid input[type="text"] {
  width: 100%;
  background: #232526;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-grid input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.btn-primary {
  background: linear-gradient(180deg, #ffb347, #d0872b);
  color: #232526;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn-primary:hover {
  box-shadow: 0 4px 16px #ffb34799;
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}

.status {
  min-height: 1.2em;
  font-size: 0.95rem;
  opacity: 0.95;
}
/* Two cards side-by-side inside one widget */
.dual-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 100%;
}

/* Card look to match your site */
.form-card {
  background: #2c2c2c;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.form-title {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 700;
}

/* Compact form grid */
.form-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 14px;
  align-items: center;
}

.form-grid label {
  font-weight: 600;
  color: var(--text);
  opacity: 0.9;
}

.form-grid input[type="date"],
.form-grid input[type="number"],
.form-grid input[type="text"] {
  width: 100%;
  background: #232526;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-grid input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15);
}

.form-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Reuse your existing .btn-primary if present; otherwise: */
.btn-primary {
  background: linear-gradient(180deg, #ffb347, #d0872b);
  color: #232526;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn-primary:hover {
  box-shadow: 0 4px 16px #ffb34799;
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}

.status {
  min-height: 1.2em;
  font-size: 0.95rem;
  opacity: 0.95;
}

/* Stack vertically on narrow screens */
@media (max-width: 1100px) {
  .dual-forms {
    grid-template-columns: 1fr;
  }
}

/*###################################### GAS + TEMP #######################################*/
.dual-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 100%;
}
.form-card {
  background: #2c2c2c;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}
.form-title {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 700;
}
.form-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 14px;
  align-items: center;
}
.form-grid label {
  font-weight: 600;
  color: var(--text);
  opacity: 0.9;
}
.form-grid input[type="date"],
.form-grid input[type="number"],
.form-grid input[type="text"] {
  width: 100%;
  background: #232526;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-grid input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15);
}
.form-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-primary {
  background: linear-gradient(180deg, #ffb347, #d0872b);
  color: #232526;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn-primary:hover {
  box-shadow: 0 4px 16px #ffb34799;
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.status {
  min-height: 1.2em;
  font-size: 0.95rem;
  opacity: 0.95;
}
@media (max-width: 1100px) {
  .dual-forms {
    grid-template-columns: 1fr;
  }
}
.calc-preview {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed #555;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 6px;
}
.calc-preview .muted {
  opacity: 0.75;
  font-size: 0.85rem;
}

/*###################################### End GAS & ELECTRIC #######################################*/
/* Latest summary card for gas and eletric*/
.latest-card {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #444;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}
.latest-card .latest-text {
  opacity: 0.95;
}

#toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
}
.toast {
  background: #2e7d32;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  margin-bottom: 10px;
  opacity: 0;
  transform: translateY(-8px);
  animation: toast-in 0.18s ease-out forwards,
    toast-out 0.25s ease-in forwards 3s;
}
.toast.error {
  background: #b3261e;
}
@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px; /* space between form and latest card */
  min-width: 0; /* prevents overflow in grid columns */
}
/*  ###################################### Bank Savings #######################################*/
/* Savings table tweaks */
.savings-table input[type="number"] {
  width: 100%;
  background: #232526;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: right;
}
.savings-table .row-save {
  display: flex;
  justify-content: center;
}
.savings-mini-btn {
  background: #2e7d32;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
}
.savings-mini-btn:hover { filter: brightness(1.06); }
.savings-mini-btn:disabled { opacity: .5; cursor: not-allowed; }
