:root {
  --bg: #dcecd8;
  --panel-bg: #e7f2e3;
  --track: #1c1c1c;
  --fill: #2fae2f;
  --text-dark: #1c1c1c;
  --text-green: #1f9c1f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #333;
  font-family: "Segoe UI", Arial, sans-serif;
}

.screen {
  width: 100%;
  max-width: 720px;
  background: var(--bg);
  border-radius: 14px;
  padding: 18px 22px 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  color: var(--text-dark);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.topbar-right {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.user-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-green);
  opacity: 0.85;
}

.logout-form {
  display: inline;
  margin: 0;
}
.logout-btn {
  background: none;
  border: 1px solid var(--fill);
  color: var(--text-green);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.75;
}
.logout-btn:hover {
  opacity: 1;
  background: rgba(47, 174, 47, 0.12);
}

.panel {
  position: relative;
}

.gauge-grid {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0 auto;
}

.gauge-cell {
  position: absolute;
  width: 36%;
  z-index: 2;
}

.top-left     { top: 0;    left: 0; }
.top-right    { top: 0;    right: 0; }
.bottom-left  { bottom: 0; left: 0; }
.bottom-right { bottom: 0; right: 0; }

.gauge {
  position: relative;
  background: var(--panel-bg);
  border-radius: 10px;
}

.gauge svg { width: 100%; display: block; }

.gauge .track {
  fill: none;
  stroke: var(--track);
  stroke-width: 12;
  stroke-linecap: round;
}

.gauge .fill {
  fill: none;
  stroke: var(--fill);
  stroke-width: 12;
  stroke-linecap: round;
  transition: d 0.4s ease;
}

.icon {
  position: absolute;
  top: 52%;
  left: 50%;
  width: 26%;
  transform: translate(-50%, -50%);
  color: var(--text-dark);
}

.icon-svg { width: 100%; display: block; }

.soc {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-green);
  font-weight: 700;
  font-size: 1.05rem;
}

.reading {
  position: absolute;
  bottom: 2%;
  left: 50%;
  transform: translate(-50%, 0);
  text-align: center;
  white-space: nowrap;
}
.reading .value {
  color: var(--text-green);
  font-weight: 700;
  font-size: 1.15rem;
}
.reading .unit {
  color: var(--text-dark);
  font-size: 0.75rem;
  margin-left: 3px;
}

.center-node {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--fill);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-green);
  font-size: 0.8rem;
  z-index: 3;
}

.connector-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.connector-path {
  fill: none;
  stroke: #4a7a46;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 1 7;
  transition: d 0.3s ease;
}

.connector-arrow polygon {
  fill: #2f6f2f;
}
.connector-arrow {
  transition: transform 0.3s ease;
}

.status-line {
  margin-top: 10px;
  text-align: center;
  font-size: 0.8rem;
  color: #55705a;
  min-height: 1.1em;
}

.settings-panel {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--panel-bg);
  border-radius: 10px;
  font-size: 0.9rem;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.settings-row + .settings-row {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.settings-label {
  color: var(--text-dark);
  font-weight: 600;
}

.settings-value {
  color: var(--text-green);
  font-weight: 700;
}

.settings-value-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edit-link {
  color: var(--text-green);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  padding: 2px 8px;
  border: 1px solid var(--fill);
  border-radius: 999px;
  opacity: 0.75;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.edit-link:hover {
  opacity: 1;
  background: rgba(47, 174, 47, 0.12);
}

.flash-messages {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.flash-message {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}
.flash-success { background: rgba(47, 174, 47, 0.15); color: #1f7a1f; }
.flash-warning { background: rgba(230, 170, 30, 0.18); color: #8a5a00; }
.flash-error   { background: rgba(220, 60, 60, 0.15); color: #a02020; }

/* --- edit_config page ---------------------------------------------- */

.edit-screen {
  max-width: 420px;
}

.edit-title {
  margin: 0 0 18px;
  font-size: 1.2rem;
  color: var(--text-dark);
}

.edit-message {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.edit-message-error { background: rgba(220, 60, 60, 0.15); color: #a02020; }

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
}

.edit-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.edit-input-row input[type="number"],
.edit-input-row input[type="text"],
.edit-input-row input[type="password"] {
  flex: 1;
  padding: 8px 10px;
  font-size: 1rem;
  border: 1px solid var(--fill);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text-dark);
}

.remember-me-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
}

.edit-unit {
  font-weight: 600;
  color: var(--text-dark);
}

.edit-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.btn-save {
  background: var(--fill);
  color: #fff;
  border: none;
  padding: 9px 22px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}
.btn-save:hover { opacity: 0.9; }
.btn-cancel {
  color: var(--text-dark);
  text-decoration: none;
  font-weight: 600;
  opacity: 0.75;
}
.btn-cancel:hover { opacity: 1; text-decoration: underline; }

@media (max-width: 480px) {
  .topbar { font-size: 0.9rem; }
  .reading .value { font-size: 0.95rem; }
  .settings-panel { font-size: 0.8rem; }
}
