*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Light shell: main area vs sidebar (sidebar slightly darker) */
  --bg: #f4f6f9;
  --sidebar-bg: #e2e6ed;
  --surface: #ffffff;
  --surface2: #eef1f6;
  --border: #cfd6e0;
  --text: #1a1d26;
  --text2: #5c6475;
  /* Room list row tints (matches Android values/colors.xml) */
  --room-row-featured-bg: #b3dff0;
  --room-row-expired-bg: #e8e8e8;
  /* Wevo brand (matches Android values/colors.xml wevo_color) */
  --primary: #1693c3;
  --primary-hover: #1280a8;
  --accent: #1693c3;
  --bg2: #e8ecf2;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --warning: #d97706;
  --success: #16a34a;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.screen { display: none; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* In-page toasts (replaces window.alert) */
.admin-toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
  pointer-events: none;
}
.admin-toast-stack .admin-toast {
  pointer-events: auto;
}
.admin-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.4;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  animation: admin-toast-in 0.2s ease-out;
}
@keyframes admin-toast-in {
  from { opacity: 0; transform: translateX(0.5rem); }
  to { opacity: 1; transform: translateX(0); }
}
.admin-toast--out {
  opacity: 0;
  transform: translateX(0.35rem);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.admin-toast-msg {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.admin-toast-close {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text2);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.admin-toast-close:hover {
  background: var(--surface2);
  color: var(--text);
}
.admin-toast--success {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
}
.admin-toast--success .admin-toast-msg::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--success);
  margin-right: 0.45rem;
  vertical-align: 0.15rem;
}
.admin-toast--error {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.admin-toast--error .admin-toast-msg::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 0.45rem;
  vertical-align: 0.15rem;
}
.admin-toast--info {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

/* Login */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
}
.login-card h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--primary);
}
.login-card label {
  display: block;
  margin-bottom: 1rem;
  font-size: .85rem;
  color: var(--text2);
}
.login-card input {
  display: block;
  width: 100%;
  margin-top: .3rem;
  padding: .6rem .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.error { color: var(--danger); font-size: .85rem; margin-top: .75rem; min-height: 1.2em; }

/* App shell */
#app-screen {
  min-height: 100vh;
  background: var(--bg);
}

#sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 10;
}
.sidebar-header { padding: 0 1rem 1rem; border-bottom: 1px solid var(--border); }
.sidebar-logo {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 2.25rem;
  object-fit: contain;
  object-position: left center;
}
.badge { font-size: .75rem; color: var(--text2); }

#sidebar ul { list-style: none; flex: 1; padding: .5rem 0; }
#sidebar li a {
  display: block;
  padding: .6rem 1.25rem;
  color: var(--text2);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .15s;
}
#sidebar li a:hover { background: rgba(255, 255, 255, 0.55); color: var(--text); }
#sidebar li a.active {
  border-left-color: var(--primary);
  color: var(--text);
  background: rgba(255, 255, 255, 0.75);
}

#logout-btn { margin: .5rem 1rem; }

#content {
  margin-left: 220px;
  padding: 1.5rem 2rem;
  flex: 1;
  min-width: 0;
  background: var(--bg);
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.page-header h2 { font-size: 1.3rem; }

/* Buttons */
button, .btn-primary, .btn-secondary, .btn-danger, .btn-warning {
  padding: .5rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { opacity: .85; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }

.firewall-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
  align-items: center;
}
/* Firewall status: limits + counters under Status */
.fw-status-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 0.25rem;
}
.fw-subsection {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.fw-subsection-title {
  font-size: 0.98rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text2);
  margin: 0;
}
.fw-subsection-actions {
  margin-top: 0.25rem;
}
.fw-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.fw-stats-chips-block .fw-subsection {
  gap: 0.5rem;
}
.fw-stats-meta-under {
  margin: 0.5rem 0 0;
}
#fw-config-overlay,
#fw-wl-overlay {
  z-index: 110;
}
.modal.fw-dialog-wide {
  max-width: min(640px, 94vw);
}
.fw-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.fw-dialog-head h3 {
  margin: 0;
}
.fw-dialog-wide .form-grid {
  max-width: none;
}
.fw-dialog-wide .form-grid label.checkbox-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.fw-dialog-wide .form-grid label.checkbox-row input {
  width: auto;
  margin-top: 0;
}
.fw-dms-banner {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 2px solid var(--danger);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.fw-dms-text {
  flex: 1;
  min-width: 8rem;
  font-weight: 600;
}
.fw-dialog-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.fw-wl-hint {
  margin: 0 0 0.5rem;
}
.fw-dialog-toolbar {
  margin-bottom: 0.65rem;
}
.fw-wl-table-wrap {
  max-height: min(50vh, 360px);
  overflow: auto;
  margin-bottom: 0.5rem;
}
.fw-wl-dialog .modal-actions {
  margin-top: 0.25rem;
}

/* Firewall status: mode badge + metric chips */
.fw-status-overview {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.fw-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}
.fw-mode-badge {
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  flex: 0 1 auto;
  min-width: 0;
}
.fw-mode-segmented {
  display: inline-flex;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.fw-mode-seg {
  border: none;
  margin: 0;
  padding: 0.4rem 0.95rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--surface2);
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
}
.fw-mode-seg + .fw-mode-seg {
  border-left: 1px solid var(--border);
}
.fw-mode-seg.active.fw-mode-seg-log {
  background: rgba(245, 158, 11, 0.22);
  color: #92400e;
}
.fw-mode-seg.active.fw-mode-seg-enforce {
  background: rgba(34, 197, 94, 0.2);
  color: #166534;
}
.fw-mode-seg:not(.active):hover {
  background: var(--border);
  color: var(--text);
}
.fw-mode-log {
  background: rgba(245, 158, 11, 0.16);
  color: #92400e;
  border: 1px solid rgba(217, 119, 6, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}
.fw-mode-enforce {
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
  border: 1px solid rgba(22, 163, 74, 0.4);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}
.fw-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
}
.fw-metric {
  flex: 0 1 auto;
  min-width: 6rem;
  max-width: 12rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}
.fw-metric-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  margin-bottom: 0.25rem;
  line-height: 1.25;
}
.fw-metric-val {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.3;
  word-break: break-all;
}

.firewall-pre {
  margin: .5rem 0 0;
  white-space: pre-wrap;
  font-size: .85rem;
  font-family: ui-monospace, monospace;
}
.firewall-stats-meta { margin: 0 0 .35rem; font-weight: 500; }
.form-error {
  color: var(--danger);
  font-size: .9rem;
  margin: .5rem 0;
}
.form-error.hidden { display: none; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th, .data-table td {
  padding: .55rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th {
  color: var(--text2);
  font-weight: 600;
  background: var(--surface2);
  position: sticky;
  top: 0;
}
.data-table tr:hover td { background: var(--surface2); }
/* Rooms list: fixed layout + explicit columns so Category/Featured/Online stay aligned */
#rooms-table {
  table-layout: fixed;
  width: 100%;
}
#rooms-table col.rooms-colgroup-photo { width: 52px; }
#rooms-table col.rooms-colgroup-id { width: 11%; }
#rooms-table col.rooms-colgroup-label { width: auto; }
/* Wide enough for header "Category" + centered flag in body */
#rooms-table col.rooms-colgroup-category { width: 7.25rem; }
#rooms-table col.rooms-colgroup-featured { width: 5.75rem; }
#rooms-table col.rooms-colgroup-online { width: 5.5rem; }

/* Rooms list: same row colors as Android (expired overrides featured) */
#rooms-table tr.room-row-featured td {
  background: var(--room-row-featured-bg);
}
#rooms-table tr.room-row-featured:hover td {
  background: color-mix(in srgb, var(--room-row-featured-bg) 88%, var(--text) 12%);
}
#rooms-table tr.room-row-expired td {
  background: var(--room-row-expired-bg);
}
#rooms-table tr.room-row-expired:hover td {
  background: color-mix(in srgb, var(--room-row-expired-bg) 90%, var(--text) 10%);
}

/* Rooms table: compact ID column; Online = count + max line */
#rooms-table .rooms-col-roomid {
  width: 1%;
  white-space: nowrap;
  padding-left: 0.45rem !important;
  padding-right: 0.45rem !important;
  vertical-align: middle;
}
/* Header: match other columns (do not use emoji cell font-size on th). */
#rooms-table th.rooms-col-category {
  padding-left: 0.35rem !important;
  padding-right: 0.35rem !important;
  text-align: center;
  white-space: normal;
  word-break: keep-all;
  vertical-align: middle;
  font-size: inherit;
  line-height: 1.25;
  font-weight: 600;
}
/* Body: larger glyphs for flag emoji only */
#rooms-table td.rooms-col-category {
  padding-left: 0.35rem !important;
  padding-right: 0.35rem !important;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 1.35rem;
  line-height: 1.2;
}
#rooms-table .rooms-col-featured {
  width: 1%;
  min-width: 6ch;
  padding-left: 0.35rem !important;
  padding-right: 0.35rem !important;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text2);
  font-size: inherit;
}
#rooms-table .rooms-col-online {
  width: 1%;
  min-width: 7ch;
  padding-left: 0.35rem !important;
  padding-right: 0.35rem !important;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  box-sizing: border-box;
}
#rooms-table .rooms-online-line {
  font-weight: 500;
  color: var(--text);
  line-height: 1.25;
}
#rooms-table .rooms-online-max {
  font-size: 0.78rem;
  color: var(--text2);
  margin-top: 0.2rem;
  line-height: 1.3;
}

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

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: end;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-bar label {
  font-size: .8rem;
  color: var(--text2);
}
.filter-bar input, .filter-bar select {
  display: block;
  margin-top: .2rem;
  padding: .45rem .6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 600px;
}
.form-grid label {
  font-size: .8rem;
  color: var(--text2);
}
.form-grid input, .form-grid select {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .5rem .65rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
}
.form-grid input:focus, .form-grid select:focus { outline: 2px solid var(--primary); border-color: transparent; }
.form-grid textarea {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .5rem .65rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: .85rem;
  line-height: 1.45;
  min-height: 14rem;
  resize: vertical;
}
.form-grid textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.form-grid label.full-width { grid-column: 1 / -1; }
.stickers-page { max-width: 920px; }
.stickers-list { margin-bottom: 1rem; overflow-x: auto; }
.stickers-list .data-table { margin-top: 0; }
.stickers-list .stickers-col-url {
  max-width: min(420px, 45vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stickers-list .sticker-app-visible { color: var(--text2); font-size: 0.8rem; }
.stickers-list .sticker-app-hidden {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}
.stickers-list .stickers-col-actions { white-space: nowrap; }
.stickers-list .stickers-col-actions .btn-sm { margin-right: 0.35rem; }
.stickers-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

/* Sticker pack preview (admin) */
.sticker-preview-dialog {
  max-width: min(920px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.sticker-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 0.5rem;
  flex: 1;
  min-height: 120px;
  max-height: min(62vh, 520px);
  overflow-y: auto;
  padding: 0.25rem 0;
}
.sticker-preview-cell {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-height: 5.5rem;
}
.sticker-preview-cell img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.sticker-preview-cell .sticker-preview-idx {
  font-size: 0.65rem;
  color: var(--text2);
}
.sticker-preview-cell .sticker-preview-miss {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--danger);
  text-align: center;
  padding: 0.2rem;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px dashed var(--border);
  word-break: break-all;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: .75rem;
  margin-top: .5rem;
}

.hint { color: var(--text2); font-size: .8rem; margin-bottom: .75rem; }
.upgrade-hint { color: var(--danger); font-size: .85rem; margin-bottom: .75rem; }

/* Create Room: muted note under master email (not the red billing-style upgrade-hint). */
.create-room-master-hint {
  margin: -0.25rem 0 0.35rem 0;
  font-size: 0.85rem;
  color: var(--text2);
  line-height: 1.35;
}

/* Chat photos: grid of cards */
.chatphotos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1rem 1.1rem;
  margin-top: 0.5rem;
}
.chat-photo-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-photo-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  display: block;
}
.chat-photo-card-img:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.chat-photo-card-placeholder {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 1.5rem;
}
.chat-photo-card-meta {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text2);
  text-align: center;
  word-break: break-word;
}
.chat-photo-card-meta .chat-photo-card-user {
  font-weight: 600;
  color: var(--text);
}
.chat-photo-card-meta .chat-photo-card-roomid {
  margin-top: 0.15rem;
  font-size: 0.78rem;
}

/* Chat photo lightbox (standard modal) */
.modal:has(.chat-photo-viewer-dialog) {
  max-width: min(92vw, 640px);
}
.modal:has(.chat-photo-viewer-dialog) #modal-title {
  display: none;
}
.chat-photo-viewer-dialog {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}
.chat-photo-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.chat-photo-viewer-heading {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}
.chat-photo-viewer-img {
  max-width: 100%;
  max-height: min(68vh, 520px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  margin: 0 auto;
  display: block;
}
.chat-photo-viewer-footer {
  margin-top: 0.15rem;
}
.chat-photo-viewer-footer-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  padding: 0.9rem 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.chat-photo-viewer-summary {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.25rem;
}
.chat-photo-viewer-upload {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}
.chat-photo-viewer-summary-label {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text2);
  line-height: 1.2;
}
.chat-photo-viewer-upload-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.chat-photo-viewer-retention {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.12rem;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border));
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  max-width: min(46%, 200px);
  text-align: right;
}
.chat-photo-viewer-retention-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--warning) 75%, var(--text2));
  line-height: 1.2;
}
.chat-photo-viewer-retention-time {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--warning);
  line-height: 1.2;
  white-space: nowrap;
}
.chat-photo-viewer-retention--expired {
  align-items: flex-end;
  max-width: min(55%, 240px);
  border-color: color-mix(in srgb, var(--text2) 35%, var(--border));
  background: color-mix(in srgb, var(--text2) 8%, var(--surface));
}
.chat-photo-viewer-retention-expired-msg {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text2);
  text-align: right;
}
.chat-photo-viewer-kv {
  display: grid;
  grid-template-columns: minmax(4.25rem, max-content) 1fr;
  column-gap: 0.85rem;
  row-gap: 0.45rem;
  margin: 0;
  padding: 0.15rem 0 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.chat-photo-viewer-kv dt {
  margin: 0;
  padding: 0;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text2);
  align-self: baseline;
}
.chat-photo-viewer-kv dd {
  margin: 0;
  padding: 0;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
  align-self: baseline;
}
.chat-photo-viewer-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  padding-top: 0.55rem;
  margin-top: 0.05rem;
  border-top: 1px solid var(--border);
}
.chat-photo-viewer-delete {
  flex-shrink: 0;
}

@media (max-width: 440px) {
  .chat-photo-viewer-summary {
    flex-direction: column;
    align-items: stretch;
  }
  .chat-photo-viewer-retention,
  .chat-photo-viewer-retention--expired {
    max-width: none;
    align-items: flex-start;
    text-align: left;
  }
  .chat-photo-viewer-retention-label,
  .chat-photo-viewer-retention-time,
  .chat-photo-viewer-retention-expired-msg {
    text-align: left;
    align-self: flex-start;
  }
}

.filter-input { width: 100%; max-width: 400px; padding: .5rem .75rem; margin-bottom: .75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: .9rem; }

#config-yaml {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .82rem;
  padding: .75rem;
  resize: vertical;
  tab-size: 2;
}
#config-yaml:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 1rem; }
.modal label {
  display: block;
  margin-bottom: .45rem;
  font-size: .8rem;
  color: var(--text2);
}
.modal input, .modal select, .modal textarea {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .45rem .6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
}
/* Checkboxes/radios must not use full-width block layout (breaks label+text rows). */
.modal input[type="checkbox"],
.modal input[type="radio"] {
  display: inline-block;
  width: auto;
  min-width: 1rem;
  margin-top: 0;
  padding: 0;
  flex-shrink: 0;
  vertical-align: middle;
}
.modal label.checkbox-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.modal label.checkbox-row input[type="checkbox"] {
  display: inline-block;
  width: auto;
  margin-top: 0;
}

.cleanup-dialog-options {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}
.modal label.cleanup-option {
  margin-bottom: 0;
  align-items: flex-start;
  gap: 0.65rem;
}
.cleanup-option-text {
  flex: 1;
  min-width: 0;
  line-height: 1.45;
  font-size: 0.9rem;
  color: var(--text);
  padding-top: 0.1rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  justify-content: flex-start;
  margin-top: 1rem;
}
.modal-actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-left: auto;
}

/* Universal confirm — mirrors Android UniversalAlertDialog (rounded card, footer band, text buttons) */
.ua-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 1rem;
}
.ua-confirm {
  width: min(100%, 85vw);
  max-width: 420px;
  background: #f8f9fb;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.ua-confirm-inner {
  padding: 1.25rem 1.35rem 0.5rem;
  max-height: min(50vh, 320px);
  overflow-y: auto;
}
.ua-confirm-title {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.35;
}
.ua-confirm-message {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}
.ua-confirm-type-wrap {
  margin-top: 0.85rem;
}
.ua-confirm-type-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 0.35rem;
}
.ua-confirm-type-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.95rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
}
.ua-confirm-type-input:focus {
  outline: 2px solid #374151;
  outline-offset: 1px;
  border-color: transparent;
}
.ua-confirm-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}
.ua-confirm-footer {
  margin-top: 0.65rem;
  padding: 0;
  background: #fff;
  border-top: 1px solid #d1d5db;
  min-height: 52px;
}
.ua-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem 0.5rem;
}
.ua-confirm-btn {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.ua-confirm-btn:focus-visible {
  outline: 2px solid #374151;
  outline-offset: 2px;
}
.ua-confirm-btn--cancel {
  color: #6b7280;
}
.ua-confirm-btn--cancel:hover {
  background: rgba(107, 114, 128, 0.1);
}
.ua-confirm-btn--primary {
  color: #374151;
}
.ua-confirm-btn--primary:hover {
  background: rgba(55, 65, 81, 0.08);
}
.ua-confirm-btn--destructive {
  color: #c72c2c;
}
.ua-confirm-btn--destructive:hover {
  background: rgba(199, 44, 44, 0.08);
}
.ban-scope-row, .ban-duration-row, .ban-duration-chips {
  margin-bottom: .75rem;
}
.ban-scope-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 0.75rem;
}
.ban-scope-row .ban-scope-label {
  font-size: .85rem;
  color: var(--text2);
  flex-shrink: 0;
}
.ban-scope-row .ban-scope-opt {
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
}
.ban-duration-row label:first-child {
  display: block;
  margin-bottom: .35rem;
  font-size: .8rem;
  color: var(--text2);
}
.ban-scope-opt, .ban-duration-opt {
  display: inline-block;
  margin-right: 1rem;
  margin-bottom: .35rem;
  font-size: .85rem;
  cursor: pointer;
}
.ban-scope-opt input, .ban-duration-opt input {
  display: inline-block;
  width: auto;
  margin: 0 .35rem 0 0;
}

/* Room detail: fixed height, left nav list + scrollable content */
.room-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 1rem;
}
.room-detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 920px;
  height: 80vh;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.room-detail-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.room-detail-title-block {
  flex: 1;
  min-width: 0;
}
.room-detail-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
}
.room-detail-id {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text2);
  margin-top: 0.2rem;
  line-height: 1.2;
  word-break: break-all;
}
.btn-icon {
  width: 36px; height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
}
.btn-icon:hover { background: var(--border); }
.btn-icon.room-detail-close {
  flex-shrink: 0;
  border-radius: 50%;
  font-size: 1.45rem;
  font-weight: 300;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.btn-icon.room-detail-close:hover {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface2));
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  color: var(--danger);
}
.room-detail-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}
/* Match #sidebar nav-link: same background strip, colors, font, active bar */
.room-detail-tablist {
  flex: 0 0 220px;
  width: 220px;
  max-width: 40%;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem 0;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
}
.room-tab-btn {
  display: block;
  width: 100%;
  padding: 0.6rem 1.25rem;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  border-left: 3px solid transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: inherit;
  font-weight: 400;
  font-family: inherit;
  line-height: inherit;
  transition: all 0.15s;
}
.room-tab-btn:hover {
  background: rgba(255, 255, 255, 0.55);
  color: var(--text);
}
.room-tab-btn.active {
  border-left-color: var(--primary);
  color: var(--text);
  background: rgba(255, 255, 255, 0.75);
  font-weight: 400;
}
.room-detail-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: auto;
}
.room-tab-pane { font-size: .85rem; }
.room-tab-pane .data-table { font-size: .9rem; }
.room-detail-content .data-table th { position: static; }
.room-row-clickable { cursor: pointer; }

/* Room dialog — Online users tab (nickname colors + country subline) */
.room-online-wrap {
  max-width: 100%;
  min-width: 0;
}
.room-online-col-main {
  min-width: 0;
}
.room-online-table {
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
/* Same vertical padding on every body cell so border-bottom lines up (do not use display:flex on <td>). */
.room-online-table tbody td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
}
.room-online-table .online-user-cell {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.room-online-col-country {
  min-width: 0;
}
.room-online-table .online-user-country-col {
  font-size: 0.85rem;
  color: var(--text2);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.online-user-country-text--empty {
  opacity: 0.55;
}
.room-online-actions-col {
  width: 9rem;
  min-width: 9rem;
  max-width: 9rem;
  text-align: right;
  white-space: nowrap;
  box-sizing: border-box;
  padding-left: 0.5rem;
  padding-right: 0.75rem;
}
.room-online-actions-inner {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
}
.online-user-roleline {
  font-size: 0.78rem;
  color: var(--text2);
  margin-top: 0.2rem;
  line-height: 1.3;
}

/* Room dialog — Members tab (align with Android RoomMembersAdapter colors / layout) */
.room-members-wrap {
  max-width: 100%;
  min-width: 0;
}
.room-members-col-main {
  min-width: 0;
}
.room-members-table {
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.room-members-table .rm-member-cell {
  vertical-align: middle;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.room-members-actions-col {
  width: 5.5rem;
  min-width: 5.5rem;
  max-width: 5.5rem;
  box-sizing: border-box;
  white-space: nowrap;
  vertical-align: middle;
  text-align: right;
  padding-left: 0.35rem !important;
  padding-right: 0.35rem !important;
}
.rm-member-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.rm-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  line-height: 0;
}
.rm-icon-btn:hover {
  background: var(--surface2);
}
.rm-icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.rm-icon-btn-img {
  display: block;
  height: 22px;
  width: auto;
  max-width: 36px;
  object-fit: contain;
}
.rm-member-uname {
  font-size: 0.95rem;
  line-height: 1.25;
  word-break: break-word;
}
.rm-member-uname--1 { color: rgb(146, 73, 158); }
.rm-member-uname--2 { color: rgb(27, 14, 190); font-weight: 700; }
.rm-member-uname--3 { color: rgb(39, 144, 2); font-weight: 700; }
.rm-member-uname--4 { color: rgb(202, 4, 4); font-weight: 700; }
.rm-member-uname--4girl { color: rgb(224, 13, 239); font-weight: 700; }
.rm-member-uname--5 { color: rgb(255, 154, 0); font-weight: 700; }
.rm-member-uname--0 { color: #444444; }
.rm-member-roleline {
  font-size: 0.78rem;
  color: var(--text2);
  margin-top: 0.2rem;
  line-height: 1.3;
}
.rm-member-badges {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}
.rm-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  line-height: 1.4;
  font-weight: 500;
}
.rm-badge--google {
  background: #4285f422;
  color: #4285f4;
  border: 1px solid #4285f444;
}
.rm-badge--pwd {
  background: #34a85322;
  color: #34a853;
  border: 1px solid #34a85344;
}
.rm-badge--none {
  background: #88888822;
  color: var(--text2);
  border: 1px solid #88888844;
}

/* Edit member modal — structured sections + account cards */
.modal:has(.mem-edit-dialog) {
  max-width: 560px;
}
.mem-edit-dialog {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.mem-edit-block {
  margin: 0;
}
.mem-edit-block-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  margin: 0 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.mem-edit-full {
  display: block;
  margin-bottom: 0.7rem;
}
.mem-edit-full:last-child {
  margin-bottom: 0;
}
.mem-edit-account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  align-items: stretch;
}
@media (max-width: 520px) {
  .mem-edit-account-grid {
    grid-template-columns: 1fr;
  }
}
.mem-edit-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 100%;
  box-sizing: border-box;
}
.mem-edit-card--muted {
  justify-content: center;
  min-height: auto;
}
.mem-edit-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.mem-edit-card-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}
.mem-edit-card-hint {
  font-size: 0.76rem;
  color: var(--text2);
  margin: 0;
  line-height: 1.45;
}
.mem-edit-card-field {
  margin: 0;
}
.mem-edit-card-btn {
  align-self: flex-start;
  margin-top: 0.1rem;
}

.btn-danger-outline {
  color: #e74c3c;
  border-color: #e74c3c;
  background: transparent;
}
.btn-danger-outline:hover:not(:disabled) {
  background: #e74c3c11;
}
.btn-danger-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Room Settings tab — mirrors Android fragment_room_mgmt_settings structure */
.room-settings-scroll {
  max-width: 640px;
}
/* Do not use .form-grid here: its 2-col grid + input{width:100%} breaks radio/checkbox rows. */
.rs-settings-form {
  display: block;
  max-width: 640px;
}
.rs-settings-form .form-actions {
  margin-top: 1rem;
}
.rs-settings-form .rd-room-general-footer {
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}
.rs-settings-form .rd-room-general-footer .rd-general-save-btn {
  margin-inline-start: auto;
}
.rs-section {
  margin-bottom: 1.35rem;
}
.rs-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.35rem;
}
.rs-section-rule {
  height: 1px;
  background: var(--border);
  margin-bottom: 0.65rem;
}
.rs-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 0.35rem;
}
.rs-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.rs-radio {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.35;
  width: 100%;
  text-align: left;
}
.rs-radio input[type="radio"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  width: auto;
  min-width: 1rem;
}
.rs-radio > span {
  flex: 0 1 auto;
  min-width: 0;
  text-align: left;
}
.rs-input,
.rs-textarea,
select.rs-input.rs-select {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  box-sizing: border-box;
}
select.rs-input.rs-select {
  cursor: pointer;
}
.rg-expires-remaining {
  font-weight: 400;
  color: var(--text2);
  font-size: 0.88rem;
  margin-left: 0.35rem;
}
.rs-textarea {
  min-height: 4.5rem;
  resize: vertical;
}
.rs-check {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  margin: 0.25rem 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.rs-check input[type="checkbox"] {
  flex-shrink: 0;
  width: auto;
  margin-top: 0.15rem;
}
.rs-gate-indent {
  padding-left: 1.25rem;
  margin-top: 0.35rem;
}
.rs-muted {
  font-size: 0.82rem;
  color: var(--text2);
  margin: 0.35rem 0 0.75rem;
}
.rs-photo-preview {
  max-width: 96px;
  max-height: 96px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  margin-bottom: 0.35rem;
}
.rs-photo-actions {
  margin: 0.35rem 0 0.5rem;
}
.online-actions { display: flex; gap: .3rem; flex-wrap: nowrap; }

.room-photo-cell {
  width: 52px;
  padding: .4rem !important;
  vertical-align: middle;
  overflow: visible;
}
.room-avatar-wrap {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 40px;
  vertical-align: middle;
}
.room-avatar-wrap .room-photo {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface2);
  display: block;
}
.room-lock-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.25));
}
.room-id-cell { vertical-align: middle; }
.room-id-line { font-weight: 500; color: var(--text); line-height: 1.25; }
.room-id-expiry {
  font-size: .78rem;
  color: var(--text2);
  margin-top: .2rem;
  line-height: 1.3;
}
/* Must follow .room-id-expiry and use 2-class specificity so color wins over base .room-id-expiry */
.room-id-expiry.room-id-expiry--urgent {
  color: var(--danger);
}
.room-id-expiry.room-id-expiry--soon {
  color: var(--warning);
}
.room-id-expiry.room-id-expiry--expired {
  color: var(--danger);
}
.room-label-topic-cell { max-width: 200px; }
.room-label { font-weight: 500; color: var(--text); }
.room-topic { font-size: .8rem; color: var(--text2); margin-top: .2rem; }

/* Linked accounts section inside Edit Nickname modal */
.linked-accounts-section {
  margin-top: .5rem;
  margin-bottom: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
}
.linked-accounts-title {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .5rem;
}
.linked-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .85rem;
  padding: .25rem 0;
}
.linked-account-row + .linked-account-row {
  border-top: 1px solid var(--border);
  padding-top: .4rem;
  margin-top: .2rem;
}
.linked-account-row.muted { color: var(--text2); font-style: italic; }

.pw-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-top: .2rem;
}
.pw-row input { flex: 1; }

/* Billing */
.billing-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.billing-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.billing-card-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.billing-card-primary .billing-label { color: rgba(255,255,255,.8); }
.billing-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); }
.billing-value { font-size: 1.4rem; font-weight: 600; }

.serverstate-section {
  margin-bottom: 2rem;
}
.serverstate-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Server State — Memory / Disk / CPU donut row */
.serverstate-resource-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
  flex: 1 1 100%;
  margin-bottom: 1rem;
}
.serverstate-donut-card {
  flex: 1 1 200px;
  max-width: 100%;
  min-width: 180px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1rem 1.5rem;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}
.serverstate-donut-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.65rem;
  letter-spacing: 0.02em;
}
.serverstate-donut-body {
  position: relative;
  width: min(200px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
}
.serverstate-donut-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.serverstate-donut-track {
  stroke: var(--border);
  stroke-width: 6;
}
.serverstate-donut-ring {
  /* stroke color set inline from usage % (green → red) */
  stroke-width: 6;
  stroke-linecap: round;
}
.serverstate-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.35rem 0.75rem 1.1rem;
  pointer-events: none;
}
.serverstate-donut-mini {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  line-height: 1.2;
}
.serverstate-donut-num {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  margin: 0.1rem 0;
}
.serverstate-donut-line {
  display: block;
  width: 52%;
  max-width: 5.5rem;
  height: 1px;
  background: var(--border);
  margin: 0.2rem 0;
}
.serverstate-donut-cpu {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.serverstate-donut-dash {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text2);
}
.serverstate-network-row {
  flex: 1 1 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.serverstate-row-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text2);
}
.serverstate-network-inner {
  display: flex;
  gap: 1rem;
  flex-wrap: nowrap;
}
@media (max-width: 600px) {
  .serverstate-network-inner { flex-wrap: wrap; }
}

.billing-tests-section { margin-top: 1rem; }
.billing-tests-output {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: ui-monospace, monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}
.billing-tests-output .pass { color: var(--success); }
.billing-tests-output .fail { color: var(--danger); }

/* Responsive */
@media (max-width: 768px) {
  #sidebar { width: 60px; }
  #sidebar .sidebar-header .sidebar-logo, #sidebar li a span, #sidebar .badge { display: none; }
  #content { margin-left: 60px; padding: 1rem; }
}
