:root {
  color-scheme: only dark;
  --bg0: #0f0e0d;
  --bg1: #1a1816;
  --accent-like: #4ade80;
  --accent-nope: #f87171;
  --accent-solar: #fbbf24;
  --text: #f5f0e8;
  --muted: #9c958a;
  --link: #a8c4b8;
  --border: rgba(255, 255, 255, 0.08);
  --card: #2a2622;
  --card-radius: 20px;
  --shell-max: 440px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg1) 0%, var(--bg0) 55%);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: "DM Sans", system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  text-align: center;
  padding-top: max(0.5rem, env(safe-area-inset-top));
  padding-bottom: 0.65rem;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  background: var(--bg0);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.site-nav a {
  color: var(--link);
  text-decoration: none;
}

.site-nav a:hover {
  text-decoration: underline;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  pointer-events: none;
  text-decoration: none;
}

.site-nav__logout {
  display: contents;
  margin: 0;
}

.site-nav__logout-btn {
  border: none;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
}

.site-nav__logout-btn:hover {
  text-decoration: underline;
}

.user-line {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
  word-break: break-word;
}

.main {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0 0;
}

.main--narrow {
  max-width: none;
}

.page-title {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

.page-title--with-icon {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-title__icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: var(--accent-like);
  font-size: 1.1rem;
}

.house-kicker {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.5rem;
}

.house-kicker a {
  color: var(--link);
}

.metric--solar {
  margin-bottom: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: var(--card-radius);
  background: var(--card);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

.metric--solar .metric-value {
  color: var(--accent-solar);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric {
  padding: 1rem 1.1rem;
  border-radius: var(--card-radius);
  background: var(--card);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.metric-value {
  font-size: 1.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 0;
  line-height: 1.2;
}

.metric-value .unit {
  font-size: 0.55em;
  font-weight: 600;
  color: var(--muted);
  margin-left: 0.1em;
}

.metrics-hint {
  margin: -0.5rem 0 1.25rem;
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
}

.charge-mode {
  margin-bottom: 1.25rem;
}

.charge-mode__label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: 0 0 0.55rem;
}

.charge-mode__switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.charge-mode__option {
  position: relative;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 0.7rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
  text-align: center;
}

.charge-mode__option:hover:not(:disabled) {
  color: var(--text);
}

.charge-mode__option[aria-pressed="true"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.charge-mode__option[data-mode="now"][aria-pressed="true"] {
  background: linear-gradient(145deg, #2a3d2f, #1f2a22);
  color: var(--accent-like);
}

.charge-mode__option[data-mode="solar"][aria-pressed="true"] {
  background: linear-gradient(145deg, #3d3520, #2a2418);
  color: var(--accent-solar);
}

.charge-mode__option:disabled {
  opacity: 0.55;
  cursor: wait;
}

.charge-mode__status {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

.charge-mode__status.is-error {
  color: var(--accent-nope);
}

.charge-mode__status.is-ok {
  color: var(--accent-like);
}

.energy-charts {
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: var(--card-radius);
  background: var(--card);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

.energy-charts__meta {
  margin: 0 0 1rem;
  font-size: 0.8rem;
}

.energy-chart-block {
  margin-bottom: 1.25rem;
}

.energy-chart-block:last-child {
  margin-bottom: 0;
}

.energy-chart-block__title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.energy-chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}

.section-title {
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.device-create {
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: var(--card-radius);
  background: var(--card);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

.device-create__form {
  display: grid;
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field__label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.field__input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  padding: 0.65rem 0.75rem;
}

.field__input:focus {
  outline: 2px solid rgba(168, 196, 184, 0.45);
  outline-offset: 1px;
}

.btn {
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.7rem 1rem;
}

.btn--primary {
  color: var(--text);
  background: linear-gradient(145deg, #2a3d2f, #1f2a22);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.33);
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.device-create__status,
.relay-switch__status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

.device-create__status.is-error,
.relay-switch__status.is-error {
  color: var(--accent-nope);
}

.device-create__status.is-ok,
.relay-switch__status.is-ok {
  color: var(--accent-like);
}

.device-list-section {
  margin-top: 0.5rem;
}

.device-list-section__count {
  font-weight: 400;
  font-size: 0.85em;
}

.relay-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0.25rem;
  margin-top: 0.65rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.relay-switch__option {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.relay-switch__option:hover:not(:disabled) {
  color: var(--text);
}

.relay-switch__option[aria-pressed="true"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.relay-switch__option[data-power="on"][aria-pressed="true"] {
  background: linear-gradient(145deg, #2a3d2f, #1f2a22);
  color: var(--accent-like);
}

.relay-switch__option[data-power="off"][aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.relay-switch__option:disabled {
  opacity: 0.55;
  cursor: wait;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.9rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tile {
  border-radius: var(--card-radius);
  background: var(--card);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.house-grid {
  margin-top: 0.75rem;
}

.house-tile__link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 96px;
  padding: 1rem;
  color: var(--text);
  text-decoration: none;
}

.house-tile__link:hover,
.house-tile__link:focus {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
  outline: none;
}

.house-list__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--accent-like);
  font-size: 1.1rem;
}

.house-list__text {
  min-width: 0;
  flex: 1;
}

.house-list__name {
  display: block;
  font-weight: 600;
}

.house-tile__meta {
  display: block;
  margin-top: 0.1rem;
}

.device-panel {
  margin-top: 0.5rem;
  border-radius: var(--card-radius);
  background: var(--card);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.device-panel__summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.device-panel__summary::-webkit-details-marker {
  display: none;
}

.device-panel > summary {
  list-style: none;
}

.device-panel__chevron {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.device-panel[open] .device-panel__chevron {
  transform: rotate(90deg);
}

.device-panel__title-icon {
  color: var(--accent-like);
}

.device-panel__body {
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}

.device-grid {
  margin: 0;
  padding: 0.75rem 0 0;
  grid-template-columns: 1fr;
}

.device-card {
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.device-grid .device-card {
  margin: 0 0 0.75rem;
}

.device-type {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.device-id {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  word-break: break-all;
}

.charger-state {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.charger-state--s2 {
  background: rgba(74, 222, 128, 0.18);
  color: #4ade80;
}

.charger-state--s3,
.charger-state--s4 {
  background: rgba(251, 191, 36, 0.16);
  color: #fbbf24;
}

.charger-state--s5 {
  background: rgba(96, 165, 250, 0.16);
  color: #93c5fd;
}

.charger-state--s6 {
  background: rgba(168, 196, 184, 0.16);
  color: #a8c4b8;
}

#js-house-links-panel {
  margin-bottom: 1.25rem;
}

.relay-picker {
  display: grid;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  max-height: 10rem;
  overflow-y: auto;
}

.relay-picker__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.relay-picker__item--unavailable {
  opacity: 0.45;
  cursor: not-allowed;
}

.relay-picker__item--unavailable input {
  cursor: not-allowed;
}

.field__input option:disabled {
  color: var(--muted);
}

.relay-picker__empty {
  margin: 0;
  font-size: 0.85rem;
}

.empty-note {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 1rem 0;
}

.loading-note {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

i.fa-solid,
i.fas {
  color: inherit;
}

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  .charge-mode__option {
    font-size: 0.75rem;
    padding: 0.65rem 0.45rem;
  }
}

/* Mimer-specific */
.shell--wide {
  --shell-max: 560px;
}

.tempus-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.tempus-badge--urd {
  background: rgba(168, 196, 184, 0.16);
  color: var(--link);
}

.tempus-badge--verdandi {
  background: rgba(74, 222, 128, 0.18);
  color: var(--accent-like);
}

.tempus-badge--skuld {
  background: rgba(251, 191, 36, 0.16);
  color: var(--accent-solar);
}

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--card-radius);
  padding: 3.5rem 1.5rem;
  min-height: 10rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  margin-bottom: 1rem;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--link);
  background: rgba(168, 196, 184, 0.06);
}

.dropzone__icon {
  font-size: 2rem;
  color: var(--link);
  margin-bottom: 0.5rem;
}

.dropzone__hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.label-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.14);
  color: var(--accent-like);
  border: none;
  cursor: pointer;
}

.label-chip--selected {
  background: rgba(74, 222, 128, 0.28);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.35);
}

.label-chip--remove {
  background: transparent;
  color: var(--muted);
  padding: 0 0.2rem;
  font-size: 0.9rem;
}

.label-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.label-suggestion {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: none;
  cursor: pointer;
}

.label-suggestion:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.upload-success {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--card-radius);
  background: var(--card);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

.upload-success__qr {
  display: block;
  margin: 0.75rem auto 0;
  border-radius: 12px;
  max-width: 180px;
}

.share-url-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin: 0.75rem 0;
}

.share-url-row .field__input {
  flex: 1;
  font-size: 0.82rem;
}

.access-log {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.access-log th,
.access-log td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--border);
}

.access-log th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.access-log .tempus-badge {
  margin: 0;
  padding: 0.15rem 0.45rem;
}

.file-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 1rem;
}

.file-label {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert--error {
  background: rgba(248, 113, 113, 0.12);
  color: var(--accent-nope);
}

.alert--ok {
  background: rgba(74, 222, 128, 0.12);
  color: var(--accent-like);
}

.recent-files {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-file {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.recent-file:last-child {
  border-bottom: none;
}

.recent-file__name {
  font-weight: 600;
  word-break: break-all;
}

.recent-file__meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.file-list__item {
  margin: 0;
}

.file-list__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.file-list__name {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  word-break: break-all;
}

.file-list__name:hover {
  color: var(--link);
  text-decoration: underline;
}

.file-list__meta {
  font-size: 0.78rem;
  margin: 0.35rem 0 0;
}

.file-list__url {
  font-size: 0.75rem;
  word-break: break-all;
  margin: 0.5rem 0 0;
}

.file-list__edit {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.file-list__edit .field {
  margin-bottom: 0.65rem;
}

.file-list__actions {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-list__edit .device-create__status {
  margin-top: 0.35rem;
}

.btn--small {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

.btn--danger {
  color: var(--text);
  background: linear-gradient(145deg, #4a2828, #331a1a);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.33);
}

.btn--danger:hover:not(:disabled) {
  filter: brightness(1.1);
}
