/* Liquid glass admin UI — design tokens (light default) */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fb;
  --bg-mesh-1: rgba(83, 182, 255, 0.14);
  --bg-mesh-2: rgba(27, 143, 90, 0.1);
  --text: #0b1220;
  --text-muted: #475569;
  --primary: #1b8f5a;
  --secondary: #53b6ff;
  --border: #d8dee8;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(216, 222, 232, 0.9);
  --glass-shadow: 0 8px 32px rgba(11, 18, 32, 0.08);
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --input-bg: #ffffff;
  --nav-hover: rgba(11, 18, 32, 0.06);
  --row-border: rgba(11, 18, 32, 0.08);
  --backdrop: rgba(11, 18, 32, 0.4);
  --focus: #1b8f5a;
  --danger: #c53030;
  --toggle-bg: #ffffff;
  --toggle-border: #d8dee8;
  --toggle-icon: #0b1220;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-mesh-1: rgba(83, 182, 255, 0.1);
  --bg-mesh-2: rgba(34, 192, 122, 0.07);
  --text: #f6f8fb;
  --text-muted: #94a3b8;
  --primary: #22c07a;
  --secondary: #53b6ff;
  --border: #2d3748;
  --glass-bg: rgba(21, 29, 46, 0.78);
  --glass-border: rgba(45, 55, 72, 0.95);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --surface: #151d2e;
  --surface-elevated: #1a2332;
  --input-bg: #0b1220;
  --nav-hover: rgba(255, 255, 255, 0.08);
  --row-border: rgba(255, 255, 255, 0.08);
  --backdrop: rgba(0, 0, 0, 0.55);
  --focus: #22c07a;
  --danger: #fc8181;
  --toggle-bg: #1a2332;
  --toggle-border: #2d3748;
  --toggle-icon: #f6f8fb;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, var(--bg-mesh-1), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, var(--bg-mesh-2), transparent),
    var(--bg);
}

.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-radius: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem;
  padding: 0.75rem 1.25rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.brand span {
  color: var(--primary);
}

.topnav {
  display: flex;
  gap: 0.5rem;
  flex: 1;
}

.topnav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
}

.topnav a.active,
.topnav a:hover {
  color: var(--text);
  background: var(--nav-hover);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-chip {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.main-content--wide {
  max-width: none;
  padding: 0 1rem 2.5rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
}

.lede {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

/* —— Auth pages (login / first-time setup) —— */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}

.auth-brand-text {
  font-weight: 700;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0 1rem 3rem;
}

.auth-section {
  width: 100%;
  max-width: 480px;
}

.auth-badge {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(27, 143, 90, 0.12);
  border-radius: 999px;
}

[data-theme="dark"] .auth-badge {
  background: rgba(34, 192, 122, 0.15);
}

.auth-card {
  padding: 2rem;
  margin: 0;
}

.auth-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

.auth-subtitle {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.auth-steps {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.auth-steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-step-num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
}

.auth-form-message {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.875rem;
}

.auth-form-message.form-success {
  background: rgba(27, 143, 90, 0.12);
  color: var(--primary);
  border: 1px solid rgba(27, 143, 90, 0.25);
}

[data-theme="dark"] .auth-form-message.form-success {
  background: rgba(34, 192, 122, 0.12);
  color: var(--primary);
}

.auth-form-message.form-error {
  background: rgba(197, 48, 48, 0.08);
  color: var(--danger);
  border: 1px solid rgba(197, 48, 48, 0.2);
}

.auth-hint {
  margin: 0.5rem 0 1.25rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.auth-footnote {
  margin: 1.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.auth-footnote a,
.auth-switch a {
  color: var(--secondary);
  font-weight: 600;
}

.auth-switch {
  margin: 1.25rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.btn-block {
  width: 100%;
  padding: 0.75rem 1rem;
}

.auth-form.stack-form label:first-of-type {
  margin-top: 0;
}

.stack-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
}

.stack-form input,
.stack-form textarea,
.stack-form select,
.toolbar select,
.toolbar input[type="search"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.stack-form input:focus-visible,
.stack-form textarea:focus-visible,
select:focus-visible,
input[type="search"]:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.stack-form > button[type="submit"] {
  margin-top: 1rem;
}

.btn-primary,
.btn-secondary,
.btn-tertiary,
.btn-icon,
.btn-danger {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: none;
  padding: 0.6rem 1rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-tertiary {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

.btn-icon {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  width: 2.5rem;
  height: 2.5rem;
}

/* Theme toggle — sun in dark mode, moon in light mode */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--toggle-border);
  border-radius: 10px;
  background: var(--toggle-bg);
  color: var(--toggle-icon);
  cursor: pointer;
  line-height: 0;
  vertical-align: middle;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.theme-toggle-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  position: relative;
}

.theme-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

[data-theme="light"] .theme-icon-sun,
[data-theme="dark"] .theme-icon-moon {
  display: none;
}

[data-theme="light"] .theme-icon-moon,
[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  margin-bottom: 1rem;
}

.toolbar select {
  width: auto;
  min-width: 180px;
}

.toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
}

/* —— Translations workspace —— */
.translations-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 260px) 1fr;
  gap: 1rem;
  align-items: start;
}

.main-content--wide .translations-workspace {
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
}

.filters-panel {
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
}

.filter-group {
  margin-bottom: 1.1rem;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.filter-row select {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.filter-group input[type="search"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.btn-sm {
  padding: 0.55rem 0.75rem;
  min-width: 2.5rem;
  font-weight: 700;
  line-height: 1;
}

.translations-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1.15rem;
  margin-bottom: 1rem;
}

.bundle-meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.translations-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.translation-group {
  overflow: hidden;
}

.translation-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.translation-group-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.translation-group-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.translation-group-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 0.65rem;
  padding: 0.85rem;
}

.translation-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}

.translation-key {
  display: block;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  word-break: break-all;
}

.translation-value {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
  min-height: 2.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.translation-value.is-dirty {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(27, 143, 90, 0.2);
}

.empty-state,
.list-footnote {
  color: var(--text-muted);
  font-size: 0.9375rem;
  padding: 1.25rem;
  text-align: center;
}

.list-footnote {
  font-size: 0.8125rem;
  padding: 0.5rem 0.25rem 0;
}

.dialog-panel form {
  padding: 1.5rem;
  min-width: min(100%, 420px);
}

.dialog-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

dialog form code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8125rem;
}

@media (max-width: 860px) {
  .translations-workspace {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    position: static;
  }

  .users-workspace {
    grid-template-columns: 1fr;
  }
}

/* —— Users page —— */
.users-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.users-workspace--solo {
  grid-template-columns: minmax(0, 420px);
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.125rem;
}

.panel-lede {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.panel-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.account-panel,
.admins-panel {
  padding: 1.25rem;
}

.account-form {
  max-width: 420px;
}

.account-form label:first-of-type {
  margin-top: 0;
}

.auth-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0.5rem 0 1rem;
}

.auth-checkbox input {
  margin-top: 0.2rem;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell .btn-sm {
  margin-right: 0.35rem;
}

.muted-inline {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.users-table-wrap {
  overflow-x: auto;
}

@media (max-width: 720px) {
  .translation-row {
    grid-template-columns: 1fr;
  }
}

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

.form-error {
  color: var(--danger);
  font-size: 0.875rem;
}

.users-table-wrap {
  padding: 0.5rem;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--row-border);
}

dialog {
  border: none;
  padding: 0;
  max-width: 480px;
  width: calc(100% - 2rem);
  background: transparent;
}

dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(4px);
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.toast-region {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
}

.toast {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-top: 0.5rem;
  box-shadow: var(--glass-shadow);
}

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