/* TVR Monitoring - staff GUI. Deliberately plain: this is an internal
   tool for a small team, not a product - readable and fast beats polished. */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #1a1d23;
  line-height: 1.45;
}

a { color: #1c6ddb; text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: #6b7280; font-weight: normal; }
.muted.small { font-size: 0.85em; }

/* --- Top bar --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #14213d;
  color: #fff;
  padding: 0.75rem 1.5rem;
}
.topbar .brand { color: #fff; font-weight: 600; font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-right .who { color: #c7d2e6; }
.topbar-right a { color: #fff; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

h1 { margin-top: 0.25rem; }
h2 { margin-top: 2rem; border-bottom: 1px solid #e2e5ea; padding-bottom: 0.35rem; }

/* --- Flash messages --- */
.flashes { margin-bottom: 1rem; }
.flash { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 0.5rem; }
.flash-success { background: #e4f6e9; color: #1a6b34; border: 1px solid #b6e3c3; }
.flash-error { background: #fdeaea; color: #a02020; border: 1px solid #f3bcbc; }

/* --- Login --- */
.login-box {
  max-width: 340px;
  margin: 4rem auto;
  background: #fff;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.login-box h1 { text-align: center; font-size: 1.3rem; }
.login-box form { display: flex; flex-direction: column; gap: 0.4rem; }
.login-box label { font-size: 0.85rem; color: #4b5563; margin-top: 0.5rem; }

/* --- Stat tiles --- */
.stat-row { display: flex; gap: 1rem; margin: 1rem 0 1.5rem; }
.stat {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: #6b7280; font-size: 0.85rem; }

/* --- Status chips --- */
.status-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-status-online { background: #e4f6e9; color: #1a6b34; }
.chip-status-offline { background: #fdeaea; color: #a02020; }
.chip-status-fault { background: #fdeaea; color: #a02020; }
.chip-status-premium_lapsed { background: #fdeaea; color: #a02020; }
.chip-status-unknown { background: #eef0f3; color: #55606e; }

.chip-severity-instant { background: #fdeaea; color: #a02020; }
.chip-severity-daily { background: #fff4e0; color: #91600a; }

/* Site health (alerts-only, mute-aware - see webapp.py's _site_health) and
   the "muted" marker shown on individual alerts/rows while a mute is
   active. Kept visually distinct from chip-status-*/chip-severity-* above
   so it's never mistaken for the real, never-muted connectivity/fault
   status badge. */
.chip-health-green { background: #e4f6e9; color: #1a6b34; }
.chip-health-amber { background: #fff4e0; color: #91600a; }
.chip-health-red { background: #fdeaea; color: #a02020; }
.chip-muted { background: #eef0f3; color: #55606e; margin-left: 0.35rem; }

.muted-banner {
  background: #eef2fb;
  color: #2b3a55;
  border: 1px solid #d3ddf3;
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  margin: 0.5rem 0 1rem;
}

/* --- Fleet power flow (added 30 Aug 2026) --- */
.power-flow-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.2rem 1.5rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
}
.power-flow-meta { margin: 0 0 0.75rem; font-size: 0.85rem; }
.power-flow-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0 0.75rem;
}
.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.flow-row-arrows-vertical { padding: 0.1rem 0; }
.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 130px;
  padding: 1rem 0.5rem;
  border-radius: 10px;
  background: #fafbfc;
  border: 2px solid #e2e5ea;
}
.flow-node-solar { border-color: #f0c419; }
.flow-node-battery { border-color: #1c6ddb; }
.flow-node-home { border-color: #3f4650; }
.flow-node-grid { border-color: #a02020; }
.flow-icon {
  min-width: 36px;
  height: 36px;
  padding: 0 0.3rem;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}
.flow-node-solar .flow-icon { background: #d99a00; }
.flow-node-battery .flow-icon { background: #1c6ddb; }
.flow-node-home .flow-icon { background: #3f4650; }
.flow-node-grid .flow-icon { background: #a02020; }
.flow-value { font-size: 1.3rem; font-weight: 700; }
.flow-label { font-size: 0.8rem; color: #4b5563; text-align: center; margin-top: 0.15rem; }
.flow-sub { font-size: 0.78rem; margin-top: 0.2rem; }
.flow-arrow {
  font-size: 1.8rem;
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
}
.flow-arrow-vertical { font-size: 1.5rem; }
.flow-arrow-charging, .flow-arrow-importing { color: #1c6ddb; }
.flow-arrow-discharging, .flow-arrow-exporting, .flow-arrow-active { color: #91600a; }
.flow-arrow-idle { color: #9aa1ab; }
.power-flow-footnote { font-size: 0.8rem; margin: 0.75rem 0 0; }

/* --- Tables --- */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #eef0f3;
  font-size: 0.9rem;
}
.data-table th { background: #fafbfc; color: #4b5563; font-weight: 600; }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table .row-resolved { color: #9aa1ab; }

/* --- Forms --- */
.stacked-form { display: flex; flex-direction: column; gap: 0.3rem; max-width: 420px; }
.stacked-form label { font-size: 0.85rem; color: #4b5563; margin-top: 0.6rem; }
.stacked-form input {
  padding: 0.45rem 0.6rem;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  font-size: 0.95rem;
}
.form-actions { margin-top: 1rem; }

input[type="text"], input[type="password"], input[type="number"] {
  padding: 0.45rem 0.6rem;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  font-size: 0.95rem;
}

button, .btn-secondary {
  background: #1c6ddb;
  color: #fff;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
button:hover { background: #1656ad; }
.btn-secondary { background: #eef0f3; color: #3f4650; }
.btn-secondary:hover { background: #e2e5ea; }

.inline-form { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0 1rem; }

select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  font-size: 0.9rem;
}

/* --- Notes / activity feed --- */
.note-form { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0.75rem 0 1rem; max-width: 640px; }
.note-form textarea {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}
.activity-feed { list-style: none; margin: 0; padding: 0; max-width: 720px; }
.activity-feed li {
  background: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.activity-meta { display: block; color: #6b7280; font-size: 0.78rem; margin-bottom: 0.15rem; }
.activity-detail { display: block; font-size: 0.9rem; white-space: pre-wrap; }
