/* Design tokens */
:root {
  --color-background: #f8f5ff;
  --color-background-soft: #eee7fb;
  --color-surface: #ffffff;
  --color-surface-muted: #fbf9ff;
  --color-text: #251339;
  --color-text-muted: #705985;
  --color-primary: #6d28d9;
  --color-primary-strong: #4c1d95;
  --color-primary-light: #8b5cf6;
  --color-focus: #ede9fe;
  --color-border: #d8c9f5;
  --color-border-soft: rgba(216, 201, 245, 0.86);
  --shadow-card: 0 24px 70px rgba(52, 24, 92, 0.18);
  --radius-card: 8px;
  --radius-control: 8px;
  --space-page: 2rem;
}

/* Base */
* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--color-text);
  background:
    radial-gradient(circle at top left, rgba(167, 139, 250, 0.34), transparent 34rem),
    linear-gradient(
      145deg,
      #fbf9ff 0%,
      var(--color-background) 48%,
      var(--color-background-soft) 100%
    );
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

/* Layout */
.page-shell {
  width: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: var(--space-page) 1rem;
}

.login-view {
  width: min(100%, 26.25rem);
}

.dashboard-view {
  width: min(100%, 68rem);
  min-width: 0;
}

/* Brand */
.brand {
  display: grid;
  justify-items: center;
  gap: 0.7rem;
  margin-bottom: 1.35rem;
  text-align: center;
}

.brand-logo {
  width: min(420px, 90vw);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-size: 2.05rem;
  line-height: 1.1;
  font-weight: 800;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

p {
  margin: 0.35rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* Login card */
.login-card {
  display: grid;
  gap: 0.65rem;
  padding: 2rem;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-card);
}

label {
  color: var(--color-primary-strong);
  font-size: 0.9rem;
  font-weight: 650;
}

input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.75rem;
  margin-bottom: 0.45rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-text);
  background: var(--color-surface);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  outline: 3px solid var(--color-focus);
}

select {
  appearance: none;
  padding-right: 2.35rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
    linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.15rem) 50%,
    calc(100% - 0.82rem) 50%;
  background-repeat: no-repeat;
  background-size: 0.35rem 0.35rem;
}

input[type="checkbox"] {
  width: 1.25rem;
  min-width: 1.25rem;
  height: 1.25rem;
  min-height: 1.25rem;
  margin: 0;
  padding: 0;
  accent-color: var(--color-primary);
}

button {
  min-height: 2.85rem;
  margin-top: 0.4rem;
  border: 0;
  border-radius: var(--radius-control);
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

a {
  color: inherit;
}

.secondary-button {
  min-height: 2.6rem;
  margin: 0;
  padding: 0 1rem;
  border: 1px solid var(--color-border);
  color: var(--color-primary-strong);
  background: var(--color-surface);
}

.compact-button {
  min-height: 2.15rem;
  padding: 0 0.65rem;
  font-size: 0.86rem;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.6rem;
  margin-top: 1.2rem;
  padding: 0 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-primary-strong);
  background: var(--color-surface);
  font-weight: 750;
  text-decoration: none;
}

.header-overview-link {
  margin-top: 0;
}

button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

.login-status {
  min-height: 1.25rem;
  margin: 0.1rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.login-status[data-tone="success"] {
  color: #166534;
}

.login-status[data-tone="error"] {
  color: #b42318;
}

/* Dashboard */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.dashboard-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.9rem;
}

.dashboard-logo {
  width: 3.5rem;
  height: 3.5rem;
  flex: 0 0 auto;
}

.dashboard-brand h1 {
  font-size: 1.65rem;
}

.dashboard-brand p {
  margin-top: 0.2rem;
}

.dashboard-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  min-width: 0;
}

.account-menu {
  position: relative;
}

.account-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.45rem;
  min-width: 2.45rem;
  min-height: 2.35rem;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
}

.account-menu-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.45rem);
  right: 0;
  display: grid;
  gap: 0.35rem;
  width: min(16rem, calc(100vw - 2rem));
  padding: 0.55rem;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: 0 18px 42px rgba(52, 24, 92, 0.16);
}

.account-menu-user {
  margin: 0;
  padding: 0.45rem 0.55rem 0.55rem;
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.account-menu-panel button {
  width: 100%;
  min-height: 2.35rem;
  margin: 0;
  padding: 0 0.6rem;
  border: 0;
  color: var(--color-primary-strong);
  background: transparent;
  text-align: left;
}

.account-menu-panel button:hover,
.account-menu-panel button:focus-visible {
  background: var(--color-focus);
}

.password-change-panel {
  display: grid;
  justify-items: center;
}

.password-change-card {
  width: min(100%, 28rem);
}

.password-change-card h2 {
  margin: 0;
  color: var(--color-primary-strong);
  font-size: 1.25rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.module-card {
  display: block;
  min-height: 10.5rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(52, 24, 92, 0.12);
  text-decoration: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.module-card:hover,
.module-card:focus-visible {
  border-color: rgba(109, 40, 217, 0.48);
  box-shadow: 0 22px 56px rgba(52, 24, 92, 0.16);
  transform: translateY(-1px);
}

.module-card:focus-visible,
.secondary-link:focus-visible,
.secondary-button:focus-visible,
.module-tab:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

.module-card:nth-child(2) {
  border-color: rgba(91, 141, 239, 0.35);
}

.module-card:nth-child(3) {
  border-color: rgba(22, 101, 52, 0.25);
}

.module-kicker {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.module-title {
  display: block;
  margin: 1.45rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
}

.module-description {
  display: block;
  margin-top: 0.45rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.placeholder-view {
  min-width: 0;
  padding: 1.5rem;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(52, 24, 92, 0.12);
}

.placeholder-view h2 {
  margin: 0.65rem 0 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.placeholder-view p {
  max-width: 42rem;
}

.module-view-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

.module-view-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-width: 0;
}

.module-view-actions .secondary-link,
.module-view-actions button {
  margin-top: 0;
}

.module-view-actions button {
  min-width: 9rem;
  padding: 0 1.15rem;
}

.unsaved-notice {
  display: inline-flex;
  align-items: center;
  min-height: 2.6rem;
  color: #92400e;
  font-size: 0.9rem;
  font-weight: 750;
}

.walldisplay-save-button {
  border: 1px solid var(--color-border);
  color: var(--color-primary-strong);
  background: var(--color-surface);
}

.walldisplay-save-button[data-unsaved="true"] {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.module-message {
  margin-top: 1rem;
}

.settings-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.settings-section {
  display: grid;
  gap: 0.7rem;
  padding-top: 0.15rem;
}

.settings-section + .settings-section {
  padding-top: 0.95rem;
  border-top: 1px solid var(--color-border-soft);
}

.settings-section h4 {
  margin: 0;
  color: var(--color-primary-strong);
  font-size: 0.94rem;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.settings-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.25rem;
}

.settings-actions button {
  min-width: 9rem;
}

.settings-message {
  min-height: 1.25rem;
  margin: 0;
}

.settings-message[data-tone="success"] {
  color: #166534;
}

.settings-message[data-tone="warning"] {
  color: #92400e;
}

.settings-message[data-tone="error"] {
  color: #b42318;
}

.walldisplay-display-shell {
  display: grid;
  gap: 0.85rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.walldisplay-display-selector {
  display: grid;
  grid-template-columns: auto minmax(14rem, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  max-width: 42rem;
}

.walldisplay-display-selector label {
  margin-bottom: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.walldisplay-display-selector select {
  margin-bottom: 0;
}

.walldisplay-display-selector .empty-message {
  grid-column: 1 / -1;
}

.walldisplay-device-key-panel {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
}

.walldisplay-device-key-state {
  margin: 0;
  color: var(--color-text);
  font-weight: 750;
}

.walldisplay-device-key-result {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.walldisplay-device-key-result p {
  flex-basis: 100%;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.walldisplay-device-key-result code {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: #111827;
  color: #f9fafb;
  font-size: 0.86rem;
}

.walldisplay-empty-state {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.walldisplay-empty-state p {
  margin: 0;
  color: var(--color-text-muted);
  font-weight: 750;
}

.walldisplay-display-create {
  display: grid;
  gap: 0.85rem;
}

.field-help {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.sync-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.sync-status-card {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.sync-status-card span,
.sync-status-details dt {
  color: var(--color-text-muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.sync-status-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--color-primary-strong);
  font-size: 1.2rem;
  line-height: 1.25;
}

.sync-status-details {
  margin: 0;
}

.sync-status-details div {
  display: grid;
  grid-template-columns: minmax(10rem, 14rem) 1fr;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--color-border-soft);
  border-bottom: 1px solid var(--color-border-soft);
}

.sync-status-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.35rem;
  max-width: 100%;
  overflow: visible;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--color-border-soft);
}

.module-tab {
  flex: 0 1 auto;
  min-height: 2.55rem;
  margin: 0;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-control) var(--radius-control) 0 0;
  color: var(--color-primary-strong);
  background: transparent;
  box-shadow: none;
}

.module-tab[aria-selected="true"] {
  border-color: var(--color-border-soft);
  color: #fff;
  background: var(--color-primary);
}

.module-tab-panel {
  padding-top: 1rem;
}

.messages-section {
  display: grid;
  gap: 1rem;
}

.messages-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.messages-header > div {
  flex: 1 1 auto;
  min-width: 0;
}

.messages-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.messages-header p {
  max-width: none;
  margin: 0.3rem 0 0;
}

.messages-list {
  display: grid;
  gap: 1rem;
}

.message-metadata {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.message-metadata div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.message-metadata dt {
  font-weight: 750;
}

.message-metadata dt::after {
  content: ":";
}

.message-metadata dd {
  margin: 0;
}

.active-message-preview {
  margin-top: 0.7rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: var(--color-surface-muted);
  color: var(--color-text);
  white-space: pre-wrap;
}

.content-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 13rem));
  align-items: end;
  gap: 0.7rem;
}

.content-settings input[type="number"] {
  width: 100%;
  margin: 0;
}

.family-secondary-section {
  max-width: 44rem;
  padding: 0.8rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.module-display-settings {
  display: grid;
  gap: 0.75rem;
  max-width: 44rem;
}

.module-display-toggle-row,
.module-display-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(10rem, 13rem));
  gap: 0.65rem 1rem;
  align-items: end;
}

.module-display-field-row-compact {
  grid-template-columns: repeat(2, minmax(8rem, 12rem));
  gap: 0.5rem 0.75rem;
}

.module-display-settings .message-enabled {
  margin-bottom: 0;
}

.module-display-field-row input[type="number"] {
  width: 100%;
  margin: 0;
}

.button-limit-reached {
  opacity: 0.72;
}

.field-with-suffix {
  display: grid;
  grid-template-columns: minmax(6rem, 10rem) auto;
  gap: 0.55rem;
  align-items: center;
}

.field-with-suffix input {
  width: 100%;
  margin: 0;
}

.field-with-suffix span {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.walldisplay-image-display-settings {
  gap: 0.65rem;
}

.walldisplay-image-display-help {
  display: grid;
  gap: 0.15rem;
}

.walldisplay-image-display-help .field-help {
  max-width: 42rem;
}

.walldisplay-icon-actions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.walldisplay-icon-actions-grid .message-enabled {
  margin-bottom: 0;
}

.walldisplay-icon-action {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.25rem 0;
}

.walldisplay-icon-action .message-enabled {
  flex: 1 1 auto;
  min-width: 0;
}

.walldisplay-icon-action .status-detail-help {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 1.15rem;
  margin-right: 0.2rem;
  font-size: 0.72rem;
}

.walldisplay-icon-order-controls {
  display: inline-flex;
  gap: 0.25rem;
  justify-self: end;
}

.walldisplay-icon-order-controls .icon-button {
  width: 1.85rem;
  min-width: 1.85rem;
  min-height: 1.85rem;
  font-size: 0.85rem;
}

.walldisplay-browser-actions-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.walldisplay-browser-action-row {
  display: grid;
  grid-template-columns: minmax(5rem, 0.6fr) minmax(10rem, 1.1fr) minmax(14rem, 2fr) minmax(7rem, 0.8fr) minmax(6rem, 0.7fr) auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.8rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: var(--color-surface-muted);
}

.walldisplay-browser-action-row .message-enabled {
  align-self: center;
  margin-bottom: 0.35rem;
}

.walldisplay-browser-action-controls {
  display: inline-flex;
  gap: 0.3rem;
  justify-content: flex-end;
  align-items: center;
}

.walldisplay-browser-actions-empty {
  margin: 0.75rem 0 0;
  color: var(--color-text-muted);
}

.walldisplay-sync-settings {
  grid-template-columns: minmax(12rem, 16rem);
  align-items: start;
}

.walldisplay-sync-settings .message-field {
  gap: 0.35rem;
}

.walldisplay-browser-preview {
  display: grid;
  min-width: 0;
}

.walldisplay-preview-frame {
  display: grid;
  grid-template-columns: minmax(20rem, 62%) minmax(14rem, 38%);
  width: 100%;
  min-height: 24rem;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: var(--wd-preview-background, #f6f3ea);
  color: var(--wd-preview-panel-body-text, #1d1d1b);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.46);
}

.walldisplay-preview-frame[data-images-enabled="false"] {
  grid-template-columns: 1fr;
}

.walldisplay-preview-left {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(0.85rem, 1.8vw, 1.15rem);
  min-width: 0;
  padding: clamp(1rem, 2.2vw, 1.45rem);
  background: var(--wd-preview-background, #f6f3ea);
}

.walldisplay-preview-meta {
  display: flex;
  align-items: baseline;
  gap: clamp(0.75rem, 2vw, 1.35rem);
  min-width: 0;
}

.walldisplay-preview-date-row {
  display: flex;
  align-items: baseline;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 0.55rem 0.8rem;
  min-width: 0;
}

.walldisplay-preview-date {
  min-width: 0;
  color: var(--wd-preview-date-text, #34302a);
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  font-weight: 720;
  line-height: 1.15;
}

.walldisplay-preview-weather {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.28rem;
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--wd-preview-panel-border, rgba(29, 29, 27, 0.18));
  border-radius: 999px;
  background: var(--wd-preview-badge-background, rgba(255, 255, 255, 0.34));
  color: var(--wd-preview-badge-text, #24211d);
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1;
  white-space: nowrap;
}

.walldisplay-preview-weather-icon {
  font-size: 0.95em;
}

.walldisplay-preview-weather strong {
  font-weight: 820;
}

.walldisplay-preview-clock {
  flex: 0 0 auto;
  color: var(--wd-preview-clock-text, #1d1d1b);
  font-size: clamp(3rem, 7vw, 5.4rem);
  font-weight: 850;
  line-height: 1;
}

.walldisplay-preview-sections {
  display: grid;
  align-content: start;
  gap: clamp(0.6rem, 1.25vw, 0.85rem);
  min-width: 0;
}

.walldisplay-preview-hint {
  display: -webkit-box;
  max-height: var(--wd-preview-hint-max-height, 10.24em);
  overflow: hidden;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--wd-preview-panel-border, rgba(29, 29, 27, 0.14));
  border-radius: 6px;
  background: var(--wd-preview-panel-background, transparent);
  color: var(--wd-preview-panel-body-text, #1d1d1b);
  font-size: clamp(1rem, 1.9vw, 1.25rem);
  font-weight: 700;
  line-height: 1.28;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--wd-preview-hint-line-clamp, 8);
  overflow-wrap: anywhere;
}

.walldisplay-preview-section {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--wd-preview-panel-border, transparent);
  border-radius: 6px;
  background: var(--wd-preview-panel-background, transparent);
}

.walldisplay-preview-section-no-background {
  border-color: transparent;
  background: transparent;
}

.walldisplay-preview-section h4 {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  color: var(--wd-preview-panel-title-text, #1d1d1b);
  font-size: clamp(0.95rem, 1.7vw, 1.16rem);
  font-weight: 820;
  line-height: 1.1;
  white-space: nowrap;
}

.walldisplay-preview-section h4 i {
  display: none;
  flex: 1 1 auto;
  min-width: 2rem;
  border-top: 1px solid var(--wd-preview-panel-border, rgba(29, 29, 27, 0.28));
}

.walldisplay-preview-section-no-background h4 i {
  display: block;
}

.walldisplay-preview-list {
  display: grid;
  gap: 0.32rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.walldisplay-preview-list li {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
}

.walldisplay-preview-list span,
.walldisplay-preview-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.walldisplay-preview-list span {
  color: var(--wd-preview-panel-body-text, #24211d);
  font-size: clamp(0.86rem, 1.45vw, 1.02rem);
  font-weight: 680;
}

.walldisplay-preview-list small {
  color: var(--wd-preview-panel-muted-text, #6d655a);
  font-size: 0.76rem;
}

.walldisplay-preview-empty {
  margin: 0;
  color: var(--wd-preview-muted-text, #6d655a);
}

.walldisplay-preview-image-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 100%;
  padding: clamp(0.85rem, 2vw, 1.15rem);
  border-left: 1px solid var(--wd-preview-image-border, rgba(29, 29, 27, 0.14));
  background: var(--wd-preview-image-background, #eeeae0);
  color: var(--wd-preview-panel-muted-text, #7b7266);
  text-align: center;
}

.walldisplay-preview-frame[data-images-background="false"] .walldisplay-preview-image-area {
  border-left-color: transparent;
  background: transparent;
}

.walldisplay-preview-image-area img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 30rem;
  background: var(--wd-preview-image-placeholder, #eeeae0);
  object-fit: contain;
}

.walldisplay-preview-frame[data-images-background="false"] .walldisplay-preview-image-area img {
  background: transparent;
}

.walldisplay-real-screenshot {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.walldisplay-screenshot-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
}

.walldisplay-screenshot-refresh-status,
.walldisplay-screenshot-request-status {
  margin: 0;
}

.walldisplay-screenshot-refresh-status[data-tone="success"] {
  color: #166534;
}

.walldisplay-screenshot-refresh-status[data-tone="error"] {
  color: #b42318;
}

.walldisplay-screenshot-card {
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) minmax(12rem, 18rem);
  gap: 1rem;
  align-items: start;
}

.walldisplay-screenshot-image {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12rem;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  text-align: center;
}

.walldisplay-screenshot-image img {
  display: block;
  width: 100%;
  max-height: 28rem;
  object-fit: contain;
}

.walldisplay-screenshot-history {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  list-style: none;
}

.walldisplay-image-area-note {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.images-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.9rem;
}

.image-upload-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.image-upload-panel h4 {
  margin: 0 0 0.35rem;
  color: var(--color-primary-strong);
  font-size: 1rem;
}

.image-upload-panel p {
  margin-top: 0.25rem;
}

.family-primary-action {
  border-color: rgba(92, 45, 145, 0.36);
  background: rgba(255, 255, 255, 0.78);
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto;
  gap: 0.75rem;
  width: min(100%, 32rem);
}

.upload-row input,
.upload-row button {
  margin: 0;
}

.birthday-editor {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
}

.birthday-editor h3,
.birthday-editor h4 {
  margin: 0;
  font-size: 1rem;
}

.birthday-form {
  display: grid;
  gap: 0.85rem;
}

.appointment-exceptions-section {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: var(--color-surface-muted);
}

.appointment-exceptions-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.appointment-exceptions-header h5 {
  margin: 0;
  font-size: 0.95rem;
}

.appointment-exceptions-header p {
  margin: 0.2rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.appointment-exceptions-list,
.appointment-exception-editor {
  display: grid;
  gap: 0.6rem;
}

.appointment-exception-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--color-border-soft);
}

.appointment-exception-row:first-child {
  border-top: 0;
}

.appointment-title-cell {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.appointment-importance-marker {
  flex: 0 0 auto;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
}

.appointment-importance-notice {
  background: #d97706;
}

.appointment-importance-important {
  background: #dc2626;
}

.table-wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

.birthdays-table,
.appointments-table,
.scheduled-messages-table,
.briefbert-profiles-table,
.briefbert-prompts-table,
.service-history-table,
.service-status-table,
.users-table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
}

.users-table {
  min-width: 42rem;
}

.users-table .table-actions {
  flex-wrap: nowrap;
}

.users-table th:first-child,
.users-table td:first-child,
.users-table th:nth-child(3),
.users-table td:nth-child(3),
.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  text-align: center;
  white-space: nowrap;
}

.users-table th:last-child,
.users-table td:last-child {
  width: 10rem;
}

.waste-table {
  min-width: 54rem;
}

.birthdays-table th,
.birthdays-table td,
.appointments-table th,
.appointments-table td,
.scheduled-messages-table th,
.scheduled-messages-table td,
.briefbert-profiles-table th,
.briefbert-profiles-table td,
.briefbert-prompts-table th,
.briefbert-prompts-table td,
.service-history-table th,
.service-history-table td,
.service-status-table th,
.service-status-table td,
.users-table th,
.users-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border-soft);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.birthdays-table tr:last-child td,
.appointments-table tr:last-child td,
.scheduled-messages-table tr:last-child td,
.briefbert-profiles-table tr:last-child td,
.briefbert-prompts-table tr:last-child td,
.service-history-table tr:last-child td,
.service-status-table tr:last-child td,
.users-table tr:last-child td {
  border-bottom: 0;
}

.birthdays-table th,
.appointments-table th,
.scheduled-messages-table th,
.briefbert-profiles-table th,
.briefbert-prompts-table th,
.service-history-table th,
.service-status-table th,
.users-table th {
  color: var(--color-primary-strong);
  font-size: 0.86rem;
}

.birthdays-table th button,
.appointments-table th button,
.scheduled-messages-table th button {
  min-height: 0;
  margin: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: 750;
  text-align: left;
  white-space: nowrap;
}

.birthdays-table th,
.birthdays-table td {
  overflow-wrap: normal;
  word-break: normal;
}

.appointments-table th,
.appointments-table td {
  overflow-wrap: normal;
  word-break: normal;
}

.birthdays-table th:first-child,
.birthdays-table td:first-child {
  width: 4.5rem;
  min-width: 4.5rem;
  text-align: center;
  white-space: nowrap;
}

.birthdays-table th:nth-child(2),
.birthdays-table td:nth-child(2) {
  min-width: 10rem;
  white-space: nowrap;
}

.birthdays-table th:nth-child(3),
.birthdays-table td:nth-child(3) {
  min-width: 8.5rem;
  white-space: nowrap;
}

.birthdays-table th:nth-child(4),
.birthdays-table td:nth-child(4) {
  min-width: 12rem;
  overflow-wrap: break-word;
}

.birthdays-table th:last-child,
.birthdays-table td:last-child {
  width: 7rem;
  min-width: 7rem;
  white-space: nowrap;
}

.birthdays-table .table-actions {
  flex-wrap: nowrap;
}

.appointments-table th:first-child,
.appointments-table td:first-child {
  width: 4.5rem;
  min-width: 4.5rem;
  text-align: center;
  white-space: nowrap;
}

.appointments-table th:nth-child(2),
.appointments-table td:nth-child(2) {
  min-width: 12rem;
}

.appointments-table th:nth-child(3),
.appointments-table td:nth-child(3) {
  min-width: 11rem;
  white-space: nowrap;
}

.appointments-table th:nth-child(4),
.appointments-table td:nth-child(4) {
  min-width: 9.5rem;
  white-space: nowrap;
}

.appointments-table th:nth-child(5),
.appointments-table td:nth-child(5) {
  min-width: 12rem;
  overflow-wrap: break-word;
}

.appointments-table th:last-child,
.appointments-table td:last-child {
  width: 7rem;
  min-width: 7rem;
  white-space: nowrap;
}

.appointments-table .table-actions {
  flex-wrap: nowrap;
}

.scheduled-messages-table th:first-child,
.scheduled-messages-table td:first-child {
  width: 4.5rem;
  min-width: 4.5rem;
  text-align: center;
  white-space: nowrap;
}

.scheduled-messages-table th:nth-child(2),
.scheduled-messages-table td:nth-child(2) {
  min-width: 11rem;
  white-space: nowrap;
}

.scheduled-messages-table th:nth-child(3),
.scheduled-messages-table td:nth-child(3) {
  min-width: 11rem;
  white-space: nowrap;
}

.scheduled-messages-table th:nth-child(4),
.scheduled-messages-table td:nth-child(4) {
  min-width: 16rem;
  overflow-wrap: anywhere;
}

.scheduled-messages-table th:last-child,
.scheduled-messages-table td:last-child {
  width: 7rem;
  min-width: 7rem;
  white-space: nowrap;
}

.scheduled-messages-table .table-actions {
  flex-wrap: nowrap;
}

.scheduled-message-preview-cell {
  max-width: 22rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waste-table th:first-child,
.waste-table td:first-child {
  width: 8.5rem;
  min-width: 8.5rem;
  text-align: left;
}

.waste-table th:nth-child(2),
.waste-table td:nth-child(2) {
  min-width: 18rem;
}

.waste-table th:nth-child(3),
.waste-table td:nth-child(3) {
  min-width: 12rem;
  overflow-wrap: break-word;
  white-space: normal;
}

.waste-table th:last-child,
.waste-table td:last-child {
  width: 7rem;
  min-width: 7rem;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}

.compact-checkbox {
  margin: 0;
  white-space: nowrap;
}

.permission-editor {
  display: grid;
  gap: 0.75rem;
  min-width: 16rem;
}

.permission-preset-panel {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.permission-preset-panel label {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(12rem, 18rem);
  gap: 0.5rem;
  align-items: center;
}

.permission-preset-panel .permission-note {
  margin: 0;
}

.permission-preset-panel--compact {
  padding: 0;
  border: 0;
  background: transparent;
}

.permission-preset-panel--compact label {
  grid-template-columns: minmax(7rem, 1fr) minmax(9rem, 12rem);
}

.permission-display-section {
  display: grid;
  gap: 0.75rem;
}

.permission-display-section h4 {
  margin: 0;
  color: var(--color-primary-strong);
  font-size: 1rem;
}

.permission-editor fieldset {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0.7rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
}

.permission-editor legend {
  padding: 0 0.25rem;
  color: var(--color-primary-strong);
  font-weight: 750;
}

.permission-editor label {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) minmax(9rem, 12rem);
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

.permission-editor select {
  margin: 0;
}

.permission-note {
  margin: 0 0 0.55rem;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.compact-editor-title {
  margin: 0 0 0.65rem;
  color: var(--color-primary-strong);
  font-size: 0.95rem;
}

.status-yes {
  color: #166534;
  font-weight: 750;
}

.status-no {
  color: var(--color-text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0 0.6rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge-ok {
  border-color: rgba(22, 101, 52, 0.2);
  color: #166534;
  background: #dcfce7;
}

.status-badge-warning {
  border-color: rgba(180, 83, 9, 0.24);
  color: #92400e;
  background: #fef3c7;
}

.status-badge-error {
  border-color: rgba(180, 35, 24, 0.24);
  color: #b42318;
  background: #fee2e2;
}

.status-badge-pending {
  border-color: rgba(107, 114, 128, 0.24);
  color: var(--color-text-muted);
  background: #f3f4f6;
}

.icon-button {
  width: 2.25rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  color: var(--color-primary-strong);
  background: var(--color-surface);
  font-size: 1rem;
  line-height: 1;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.message-editor {
  display: grid;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
}

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

.message-field input,
.message-field textarea {
  margin-bottom: 0;
}

.message-field-full {
  width: 100%;
}

.message-editor textarea {
  min-height: 9rem;
  resize: vertical;
}

.message-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.message-enabled {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  margin-bottom: 0.45rem;
  padding: 0.35rem 0.1rem;
  cursor: pointer;
  font-weight: 750;
}

.message-enabled input {
  width: 1.25rem;
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.waste-bin-option {
  min-width: 13rem;
}

.waste-bin-marker {
  width: 0.9rem;
  height: 0.9rem;
  border: 1px solid rgba(37, 19, 57, 0.2);
  border-radius: 3px;
  flex: 0 0 auto;
}

.waste-bin-marker-yellow {
  background: #f2b046;
}

.waste-bin-marker-paper {
  background: #4d712d;
}

.waste-bin-marker-residual {
  background: #4b4b4b;
}

.waste-bin-marker-bio {
  background: #7e4d16;
}

.waste-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.waste-type-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.waste-type-icon-form {
  width: 1.4rem;
  height: 1.4rem;
}

.waste-type-icon-chip {
  width: 1.05rem;
  height: 1.05rem;
}

.waste-type-icon .waste-bin-marker {
  width: 70%;
  height: 70%;
}

.waste-type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.waste-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.6rem;
  padding: 0.18rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--waste-type-color) 38%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--waste-type-color) 10%, #ffffff);
  color: var(--color-text);
  font-size: 0.86rem;
  font-weight: 750;
  white-space: nowrap;
}

.waste-type-chip-residual {
  --waste-type-color: #4b4b4b;
}

.waste-type-chip-bio {
  --waste-type-color: #7e4d16;
}

.waste-type-chip-paper {
  --waste-type-color: #4d712d;
}

.waste-type-chip-yellow {
  --waste-type-color: #f2b046;
}

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

.image-card {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.image-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 12rem;
  max-height: 16rem;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background-color: #f6f6f2;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.image-preview > span {
  padding: 1rem;
}

.image-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}

.image-card-title {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.image-metadata {
  display: grid;
  grid-template-columns: minmax(5.8rem, 8rem) 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
}

.image-metadata dt {
  color: var(--color-text-muted);
  font-weight: 750;
}

.image-metadata dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--color-text-muted);
}

.image-details {
  color: var(--color-text-muted);
  font-size: 0.86rem;
}

.image-details summary {
  width: fit-content;
  cursor: pointer;
  color: var(--color-primary-strong);
  font-weight: 750;
}

.empty-message {
  margin: 0;
  color: var(--color-text-muted);
}

.system-status-layout {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.briefbert-layout {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.briefbert-profiles-table {
  min-width: 48rem;
}

.briefbert-profiles-table th:last-child,
.briefbert-profiles-table td:last-child {
  width: 5.6rem;
  min-width: 5.6rem;
}

.briefbert-profiles-table th:nth-child(3),
.briefbert-profiles-table td:nth-child(3) {
  width: 5.4rem;
  min-width: 5.4rem;
  text-align: center;
}

.briefbert-profiles-table .table-actions {
  min-width: 0;
}

.briefbert-profile-actions {
  align-items: center;
  flex-wrap: nowrap;
}

.briefbert-profile-enabled {
  display: inline-grid;
  gap: 0.15rem;
  justify-items: center;
  min-width: 2.35rem;
  max-width: 5.2rem;
}

.briefbert-profile-enabled-cell {
  text-align: center;
}

.briefbert-profile-enabled .compact-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.briefbert-profile-enabled-toggle {
  width: 1rem;
  min-width: 1rem;
  height: 1rem;
  min-height: 1rem;
  margin: 0;
  padding: 0;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.briefbert-profile-enabled-toggle:disabled {
  cursor: default;
}

.briefbert-profile-enabled span {
  color: var(--color-muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.briefbert-profile-enabled span[data-tone="success"] {
  color: #166534;
}

.briefbert-profile-enabled span[data-tone="warning"] {
  color: #92400e;
}

.briefbert-profile-enabled span[data-tone="error"] {
  color: #b42318;
}

.briefbert-profiles-table .icon-button {
  width: 2rem;
  min-width: 2rem;
  min-height: 2rem;
  font-size: 0.95rem;
}

.briefbert-runs-table {
  min-width: 52rem;
}

.briefbert-prompts-table {
  min-width: 28rem;
}

.briefbert-prompts-table th:last-child,
.briefbert-prompts-table td:last-child {
  width: 6rem;
  white-space: nowrap;
}

.briefbert-prompts-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.briefbert-prompts-table tbody tr.is-selected td {
  background: rgba(59, 130, 246, 0.08);
}

.briefbert-runs-table tbody tr.is-selected td {
  background: rgba(59, 130, 246, 0.08);
}

.briefbert-profiles-table td[data-tone="success"],
.briefbert-runs-table td[data-tone="success"] {
  color: #166534;
  font-weight: 700;
}

.briefbert-profiles-table td[data-tone="warning"],
.briefbert-runs-table td[data-tone="warning"] {
  color: #92400e;
  font-weight: 700;
}

.briefbert-profiles-table td[data-tone="error"],
.briefbert-runs-table td[data-tone="error"] {
  color: #b42318;
  font-weight: 700;
}

.briefbert-prompt-preview {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.briefbert-prompt-preview-header {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  justify-content: space-between;
}

.briefbert-prompt-preview h4 {
  margin: 0;
  color: var(--color-primary-strong);
  font-size: 0.95rem;
}

.briefbert-prompt-state {
  margin: 0.25rem 0 0;
  color: var(--color-muted);
  font-size: 0.86rem;
}

.briefbert-prompt-state[data-tone="success"] {
  color: #166534;
}

.briefbert-prompt-state[data-tone="warning"] {
  color: #92400e;
}

.briefbert-prompt-state[data-tone="error"] {
  color: #b42318;
}

.briefbert-prompt-status {
  color: var(--color-muted);
  font-size: 0.86rem;
}

.briefbert-prompt-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  margin: 0;
}

.briefbert-prompt-editor {
  min-height: 420px;
  width: 100%;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  resize: vertical;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.86);
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--color-text);
}

.briefbert-prompt-editor[readonly] {
  background: rgba(255, 255, 255, 0.58);
}

.briefbert-run-preview {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.briefbert-run-preview-header {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  justify-content: space-between;
}

.briefbert-run-preview h4 {
  margin: 0;
  color: var(--color-primary-strong);
  font-size: 0.95rem;
}

.briefbert-run-preview-content {
  min-height: 14rem;
  max-height: 32rem;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.86);
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--color-text);
}

.system-status-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.system-status-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.system-status-card h3 {
  margin: 0;
  color: var(--color-primary-strong);
  font-size: 1rem;
}

.system-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.65rem;
  margin: 0;
}

.system-status-grid div {
  display: grid;
  align-content: start;
  min-height: 4.2rem;
  padding: 0.7rem;
  border: 1px solid rgba(216, 201, 245, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.system-status-grid dt {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.system-status-grid dd {
  min-width: 0;
  margin: 0.2rem 0 0;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.service-status-table-wrapper {
  background: rgba(255, 255, 255, 0.72);
}

.service-status-table {
  min-width: 46rem;
}

.service-status-table th:nth-child(3),
.service-status-table td:nth-child(3),
.service-status-table th:nth-child(4),
.service-status-table td:nth-child(4),
.service-status-table th:last-child,
.service-status-table td:last-child {
  white-space: nowrap;
}

.service-status-table tr.is-selected td {
  background: rgba(91, 33, 182, 0.05);
}

.service-status-table .table-actions {
  flex-wrap: nowrap;
}

.service-status-empty {
  padding: 0.9rem;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.service-status-details-panel {
  display: grid;
  gap: 0.85rem;
  padding: 0.9rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.service-status-details-panel h4,
.service-status-details-panel h5 {
  margin: 0;
  color: var(--color-primary-strong);
}

.service-status-details-panel h4 {
  font-size: 1rem;
}

.service-status-details-panel h5 {
  font-size: 0.9rem;
}

.service-detail-grid,
.service-details-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.65rem;
  margin: 0;
}

.service-detail-grid div,
.service-details-list div {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid rgba(216, 201, 245, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.service-detail-grid dt,
.service-details-list dt {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.status-detail-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
}

.status-detail-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 0.95rem;
  height: 0.95rem;
  min-height: 0.95rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(123, 97, 177, 0.34);
  border-radius: 999px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  cursor: help;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
  touch-action: manipulation;
}

.status-detail-help:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.status-tooltip-popover {
  position: fixed;
  z-index: 1000;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(42, 30, 66, 0.16);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(42, 30, 66, 0.22);
  color: var(--color-text);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.35;
}

.status-tooltip-popover[hidden] {
  display: none;
}

.service-detail-grid dd,
.service-details-list dd {
  min-width: 0;
  margin: 0.25rem 0 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.service-sync-summary {
  display: grid;
  gap: 0.7rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-soft);
}

.service-status-history {
  display: grid;
  gap: 0.7rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-soft);
}

.service-history-table {
  min-width: 34rem;
}

.service-history-table th:nth-child(1),
.service-history-table td:nth-child(1),
.service-history-table th:nth-child(2),
.service-history-table td:nth-child(2),
.service-history-table th:nth-child(3),
.service-history-table td:nth-child(3) {
  white-space: nowrap;
}

.status-list {
  display: grid;
  gap: 0.75rem;
  margin: 1.25rem 0 0;
}

.status-list div {
  display: grid;
  grid-template-columns: minmax(8rem, 13rem) 1fr;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--color-border-soft);
}

.status-list dt {
  color: var(--color-text-muted);
  font-weight: 750;
}

.status-list dd {
  margin: 0;
}

.status-error {
  min-height: 1.25rem;
  color: #b42318;
}

/* Footer */
.site-footer {
  padding: 1rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 56.25rem) {
  :root {
    --space-page: 1.35rem;
  }

  .dashboard-view {
    width: 100%;
  }

  .placeholder-view {
    padding: 1.15rem;
  }

  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-view-header {
    flex-wrap: wrap;
  }

  .module-view-actions {
    justify-content: flex-start;
  }

  .module-view-actions button {
    min-width: 0;
  }

  .module-tab {
    min-height: 2.75rem;
    padding: 0 0.85rem;
    scroll-snap-align: start;
  }

  .settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  }

  .system-status-grid,
  .service-detail-grid,
  .service-details-list {
    grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  }

  .briefbert-prompt-editor {
    min-height: 360px;
  }
}

@media (max-width: 30rem) {
  .login-card {
    padding: 1.5rem;
  }

  h1 {
    font-size: 1.75rem;
  }
}

@media (max-width: 44rem) {
  :root {
    --space-page: 1rem;
  }

  .page-shell {
    align-items: start;
    padding: var(--space-page) 0.7rem;
  }

  .dashboard-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-brand {
    gap: 0.7rem;
  }

  .dashboard-logo {
    width: 3rem;
    height: 3rem;
  }

  .dashboard-actions,
  .module-view-actions,
  .settings-actions,
  .form-actions {
    width: 100%;
  }

  .module-view-header,
  .module-view-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }

  .account-menu-trigger {
    width: 2.45rem;
  }

  .walldisplay-display-selector {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .walldisplay-icon-actions-grid {
    grid-template-columns: 1fr;
  }

  .walldisplay-browser-action-row {
    grid-template-columns: 1fr;
  }

  .walldisplay-browser-action-controls {
    justify-content: stretch;
  }

  .walldisplay-device-key-panel {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .module-card {
    min-height: 8.5rem;
  }

  .placeholder-view {
    padding: 0.95rem;
  }

  .messages-header,
  .system-status-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .content-settings {
    grid-template-columns: 1fr;
  }

  .module-display-toggle-row,
  .module-display-field-row,
  .module-display-field-row-compact {
    grid-template-columns: 1fr;
  }

  .status-list div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .sync-status-grid,
  .sync-status-details div {
    grid-template-columns: 1fr;
  }

  .system-status-grid,
  .service-detail-grid,
  .service-details-list {
    grid-template-columns: 1fr;
  }

  .briefbert-prompts-layout {
    grid-template-columns: 1fr;
  }

  .briefbert-prompt-preview-header,
  .briefbert-run-preview-header,
  .briefbert-prompt-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .briefbert-prompt-editor {
    min-height: 320px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .permission-preset-panel label,
  .permission-editor label {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .walldisplay-preview-frame {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .walldisplay-preview-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.4rem;
  }

  .walldisplay-preview-date-row {
    align-items: center;
  }

  .walldisplay-preview-clock {
    font-size: clamp(3rem, 16vw, 4.6rem);
  }

  .walldisplay-preview-image-area {
    min-height: 14rem;
    border-top: 1px solid rgba(29, 29, 27, 0.14);
    border-left: 0;
  }

  .walldisplay-screenshot-card {
    grid-template-columns: 1fr;
  }

  .messages-header,
  .message-editor-header,
  .image-upload-panel,
  .image-card-header,
  .upload-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .image-metadata {
    grid-template-columns: 1fr;
  }

  .birthdays-table th,
  .birthdays-table td,
  .appointments-table th,
  .appointments-table td,
  .scheduled-messages-table th,
  .scheduled-messages-table td,
  .briefbert-profiles-table th,
  .briefbert-profiles-table td,
  .briefbert-prompts-table th,
  .briefbert-prompts-table td,
  .service-history-table th,
  .service-history-table td,
  .service-status-table th,
  .service-status-table td,
  .users-table th,
  .users-table td {
    padding: 0.6rem;
  }

}

@media (max-width: 30rem) {
  .dashboard-brand h1 {
    font-size: 1.4rem;
  }

  .dashboard-brand p,
  .module-description {
    font-size: 0.88rem;
  }

  .module-tabs {
    margin-right: 0;
    margin-left: 0;
    padding-right: 0;
    padding-left: 0;
  }

  .module-tab {
    padding: 0 0.7rem;
    font-size: 0.88rem;
  }

  .briefbert-prompt-editor {
    min-height: 280px;
  }

  .briefbert-run-preview-content {
    min-height: 10rem;
  }
}

@media (pointer: coarse) {
  .icon-button {
    width: 2.55rem;
    min-width: 2.55rem;
    min-height: 2.55rem;
  }

  .briefbert-profiles-table .icon-button {
    width: 2.35rem;
    min-width: 2.35rem;
    min-height: 2.35rem;
  }
}
