:root {
  font-family: "Trebuchet MS", "Lucida Sans", "Lucida Grande", Arial, sans-serif;
  --bg: #0b0f14;
  --bg-elev: #0f1620;
  --bg-elev-2: #0c131c;
  --text: #e8eef6;
  --muted: #a7b2c4;
  --border: #1d2632;
  --control-bg: #111a25;
  --control-border: #233145;
  --table-stripe: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --bg-elev-2: #f0f3f8;
  --text: #1c2430;
  --muted: #5a6475;
  --border: #d9e0ea;
  --control-bg: #ffffff;
  --control-border: #cdd6e3;
  --table-stripe: rgba(0, 0, 0, 0.03);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.is-hidden {
  display: none !important;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.topbar .left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.topbar .center {
  justify-self: center;
  font-weight: 600;
}

.product {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.product-logo {
  width: 36px;
  height: 36px;
  display: block;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  flex-wrap: wrap;
}

.status {
  font-size: 12px;
  opacity: 0.8;
  line-height: 1.2;
}

.sse-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: #64748b;
  box-shadow: 0 0 0 0 rgba(148, 163, 184, 0);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.sse-indicator.sse-ok {
  background: #22c55e;
}

.sse-indicator.sse-idle {
  background: #94a3b8;
}

.sse-indicator.sse-offline {
  background: #ef4444;
}

.sse-indicator.sse-blink {
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.15);
}

.queue-stats {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.3;
}
.status-button {
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.queue-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.queue-menu {
  position: absolute;
  top: 34px;
  left: 0;
  min-width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.queue-divider {
  opacity: 0.6;
}

.topbar-menu {
  position: relative;
}

.topbar-menu summary {
  list-style: none;
}

.topbar-menu summary::-webkit-details-marker {
  display: none;
}

.menu-button {
  padding: 6px 10px;
}

.menu-avatar-button {
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
}

.menu-avatar {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
  background: var(--bg-elev);
}

.menu-dropdown {
  position: absolute;
  top: 36px;
  right: 0;
  min-width: 150px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.menu-label {
  font-size: 12px;
  opacity: 0.8;
  padding: 0 6px;
}

.menu-select {
  width: 100%;
}

.menu-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  justify-content: center;
}

.menu-inline .menu-label {
  padding: 0;
}

.menu-inline .menu-select {
  width: auto;
  min-width: 72px;
}

.lang-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.menu-apply {
  padding: 4px 8px;
}

.menu-theme {
  padding: 6px;
  border-radius: 8px;
}

.menu-theme-icon {
  display: inline-block;
  font-size: 14px;
  line-height: 1;
}

.menu-item {
  background: transparent;
  border: 0;
  color: var(--text);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  font: inherit;
}

.menu-item:hover {
  background: var(--bg-elev-2);
}

.menu-item.is-active {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}

.menu-danger {
  color: #ef4444;
}

.queue-section + .queue-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.queue-title {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 6px;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}

.queue-item-status {
  opacity: 0.7;
}

.queue-item-actions .btn {
  padding: 2px 6px;
  font-size: 12px;
}

.status.dirty {
  color: #ef4444;
  opacity: 1;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
  margin-top: 10px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  opacity: 0.8;
  margin-right: 6px;
}

input, select, button, .btn {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--control-border);
  border-radius: 8px;
  padding: 6px 10px;
}

.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

.table-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 6px;
}

.table-filter-summary {
  font-size: 12px;
  opacity: 0.7;
}

.table-filter-row {
  display: none;
  background: var(--bg-elev-2);
}

.table-wrap.filters-open .table-filter-row {
  display: table-row;
}

.table-filter-row td {
  padding: 6px 8px;
}

.table-filter-row input,
.table-filter-row select {
  width: 100%;
}

.table-filter-range {
  display: flex;
  gap: 6px;
}

.table-filter-range input {
  flex: 1 1 0;
}

th.has-filter {
  position: relative;
  padding-right: 18px;
}

th.has-filter .filter-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--control-border);
  opacity: 0.5;
}

th.filter-active .filter-indicator {
  background: #3b82f6;
  opacity: 1;
}

.table-view-dialog {
  max-width: 840px;
  width: auto;
}

.table-view-body {
  max-height: 60vh;
  overflow: auto;
}

.table-view-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.table-view-table th,
.table-view-table td {
  font-size: 13px;
  padding: 6px 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.table-view-table th:nth-child(1),
.table-view-table td:nth-child(1),
.table-view-table th:nth-child(6),
.table-view-table td:nth-child(6) {
  text-align: center;
}

.table-view-row td:nth-child(3) {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-view-row input[type="number"] {
  width: 80px;
}

.table-view-row .btn {
  padding: 4px 8px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.85;
}

.table-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-page {
  min-width: 70px;
  text-align: center;
}

.table th.sortable,
.grid th.sortable {
  cursor: pointer;
}

.table tbody tr:nth-child(even),
.grid tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.align-right {
  text-align: right;
}

.align-center {
  text-align: center;
}

.align-left {
  text-align: left;
}

.is-hidden {
  display: none;
}

button.primary,
.btn.primary {
  border-color: #3b82f6;
}

button.danger,
.btn.danger {
  border-color: #ef4444;
}

.btn:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  border-color: #3b82f6;
}

button.danger {
  border-color: #ef4444;
}

.lang-select {
  width: auto;
  min-width: 72px;
}

.theme-toggle {
  display: inline-flex;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

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

.hidden {
  display: none !important;
}

.job-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background: var(--bg-elev-2);
  font-size: 12px;
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .topbar .center {
    justify-self: start;
  }
  .actions {
    justify-self: start;
  }
}
  .topbar .left {
    flex-wrap: wrap;
  }
