:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg-app: #09090b;
  --bg-panel: #18181b;
  --bg-card: #27272a;
  --bg-surface: #27272a;

  --border-subtle: #3f3f46;
  --border-strong: #52525b;

  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-primary-text: #ffffff;

  --status-active-bg: rgba(34, 197, 94, 0.15);
  --status-active-text: #4ade80;

  --status-warning-bg: rgba(234, 179, 8, 0.15);
  --status-warning-text: #facc15;

  --status-error-bg: rgba(239, 68, 68, 0.15);
  --status-error-text: #f87171;

  --status-paused-bg: rgba(59, 130, 246, 0.15);
  --status-paused-text: #60a5fa;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);

  --donut-empty: #3f3f46;

  --bg-list-hover: rgba(255, 255, 255, 0.03);
  --bg-list-selected: rgba(59, 130, 246, 0.15);

  --shell-max-width: 1400px;
}

[data-theme="light"] {
  --bg-app: #f4f4f5;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --bg-surface: #f4f4f5;

  --border-subtle: #e4e4e7;
  --border-strong: #d4d4d8;

  --text-main: #18181b;
  --text-muted: #71717a;

  --status-active-bg: #dcfce7;
  --status-active-text: #16a34a;

  --status-warning-bg: #fef3c7;
  --status-warning-text: #f59e0b;

  --status-error-bg: #fee2e2;
  --status-error-text: #ef4444;

  --status-paused-bg: #dbeafe;
  --status-paused-text: #2563eb;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --bg-list-hover: rgba(0, 0, 0, 0.04);
  --bg-list-selected: rgba(59, 130, 246, 0.1);

  --donut-empty: #e4e4e7;
}

* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body[data-theme="dark"] {
  color-scheme: dark;
}

body[data-theme="light"] {
  color-scheme: light;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-header {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-content {
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-logo {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.header-actions button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.header-actions button:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--text-muted);
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 32px 24px 80px;
  position: relative;
}

.tabs menu[role="tablist"] {
  display: flex;
  gap: 24px;
  margin: 0 0 32px 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--border-subtle);
}

.tabs menu[role="tablist"] button {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 0 0 12px 0;
  cursor: pointer;
  transition: all 0.2s;
}

.tabs menu[role="tablist"] button:hover {
  color: var(--text-main);
}

.tabs menu[role="tablist"] button[aria-selected="true"] {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .two-column {
    grid-template-columns: 1fr;
  }
}

.two-column--equal {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
  .two-column--equal {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel h3 {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-banner {
  background: linear-gradient(to right bottom, var(--bg-card), var(--bg-surface));
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 32px;
}

.hero-banner h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.hero-banner p {
  color: var(--text-muted);
  margin: 0 0 24px 0;
  line-height: 1.6;
  max-width: 600px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.stat-meta {
  color: var(--text-muted);
  font-size: 14px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 32px;
  justify-content: center;
  flex-wrap: wrap;
}

.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--donut-data, var(--donut-empty));
  position: relative;
  flex-shrink: 0;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 24px;
  background: var(--bg-card);
  border-radius: 50%;
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
}

.donut-center strong {
  display: block;
  font-size: 16px;
  color: var(--text-main);
}

.donut-center div {
  font-size: 12px;
  color: var(--text-muted);
}

.legend {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.legend li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  gap: 12px;
}

.legend li:last-child {
  border-bottom: none;
}

.legend-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  min-width: 0;
  flex: 1;
}

.legend-label-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--legend-color, #888);
}

.legend-detail {
  display: flex;
  gap: 12px;
}

.legend-detail-value {
  font-family: monospace;
  color: var(--text-main);
  min-width: 4ch;
  text-align: right;
}

.text-success,
.legend-detail-value.success {
  color: var(--status-active-text);
}

.text-limited,
.legend-detail-value.limited {
  color: var(--status-warning-text);
}

.text-error,
.legend-detail-value.error {
  color: var(--status-error-text);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-muted);
  line-height: 1;
  white-space: nowrap;
}

.status-pill.active {
  background: var(--status-active-bg);
  color: var(--status-active-text);
}

.status-pill.ok {
  background: var(--status-active-bg);
  color: var(--status-active-text);
}

.status-pill.limited {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
}

.status-pill.rate_limit {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
}

.status-pill.exceeded {
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

.status-pill.quota {
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

.status-pill.error {
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

.status-pill.deactivated,
.status-pill.paused {
  background: var(--status-paused-bg);
  color: var(--status-paused-text);
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.account-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  border-color: var(--accent-primary);
  background: var(--bg-surface);
}

.account-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.account-card header>div {
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}

.account-card header .status-pill {
  flex-shrink: 0;
}

.account-card header>div>div:first-child {
  font-weight: 500;
  font-size: 15px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-card .account-id {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 4px;
}

.progress-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-row+.progress-row {
  margin-top: 24px;
}

.progress-row label {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

[role="progressbar"] {
  height: 6px;
  background: var(--border-strong);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

[role="progressbar"] div {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 99px;
}

[role="progressbar"].limited div {
  background: var(--status-warning-text);
}

[role="progressbar"].error div {
  background: var(--status-error-text);
}

[role="progressbar"].success div {
  background: var(--status-active-text);
}

.account-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.account-actions button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent-primary);
  background: var(--accent-primary);
  color: var(--accent-primary-text);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.account-actions button:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}



.inline-actions {
  display: flex;
  gap: 8px;
}

.inline-actions button {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent-primary);
  background: var(--accent-primary);
  color: var(--accent-primary-text);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.inline-actions button:hover {
  border-color: var(--accent-primary-hover);
  background: var(--accent-primary-hover);
}

.controls-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
  justify-content: space-between;
}

.controls-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  min-width: 120px;
}

.filter-input:focus {
  border-color: var(--accent-primary);
}

.filter-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 32px 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2358A6FF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px top 50%;
  background-size: 10px auto;
}

.filter-select[multiple] {
  padding-right: 12px;
  background-image: none;
}

.filter-select option {
  background: var(--bg-surface);
  color: var(--text-main);
}

.single-select {
  position: relative;
}

.single-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 120px;
  cursor: pointer;
  position: relative;
  background-image: none;
}

.single-select-trigger::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 10px;
  height: 10px;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2358A6FF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.25s ease;
}

.single-select-trigger[aria-expanded="true"] {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.single-select-trigger[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(180deg);
}

.single-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: max-content;
  min-width: 140px;
  padding: 8px;
  padding-top: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  box-shadow: var(--shadow-md);
}

.single-select-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 16px;
  width: 10px;
  height: 10px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  border-top: 1px solid var(--border-subtle);
  transform: rotate(45deg);
}

.single-select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--text-main);
  font-size: 13px;
}

.single-select-item:hover {
  background: var(--bg-list-hover);
}

.single-select-item.is-selected {
  background: var(--bg-list-selected);
}

.single-select-item input[type="radio"] {
  display: none;
}

.multi-select {
  position: relative;
}

.multi-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 180px;
  cursor: pointer;
  position: relative;
  background-image: none;
}

.multi-select-trigger::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 10px;
  height: 10px;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2358A6FF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.25s ease;
}

.multi-select-trigger:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.multi-select-trigger[aria-expanded="true"] {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.multi-select-trigger[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(180deg);
}


.multi-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: max-content;
  min-width: 220px;
  max-width: 360px;
  padding: 8px;
  padding-top: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  box-shadow: var(--shadow-md);
  overflow: visible;
}

.multi-select-scroller {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  /* Add padding to ensure scrollbar doesn't overlap content tightly if needed, 
     but we removed padding from parent. Wait, parent has padding 8px. 
     The scroller is inside. */
}

.multi-select-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 16px;
  width: 10px;
  height: 10px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  border-top: 1px solid var(--border-subtle);
  transform: rotate(45deg);
}

.multi-select-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.multi-select-action {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.multi-select-action:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.multi-select-item:hover {
  background: var(--bg-list-hover);
}

.multi-select-item input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

.multi-select-label {
  color: var(--text-main);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.filter-apply {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent-primary);
  background: var(--accent-primary);
  color: var(--accent-primary-text);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.filter-apply:hover {
  border-color: var(--accent-primary-hover);
  background: var(--accent-primary-hover);
}

.filter-apply:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.table-wrap--requests th,
.table-wrap--requests td {
  text-align: center;
}

.table-wrap--requests td:nth-child(2),
.table-wrap--requests td:nth-child(5) {
  text-align: left;
}



table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
  table-layout: fixed;
}

.cell-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-cell {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.error-cell.placeholder {
  justify-content: center;
}

.error-cell.placeholder .error-text {
  text-align: center;
}

.error-text {
  flex: 1;
  min-width: 0;
}

.error-text.truncated {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-error {
  vertical-align: middle;
}

.error-toggle {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  font-size: 11px;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
  margin-top: 3px;
  font-weight: 500;
  line-height: 1.2;
  min-width: 32px;
  text-align: left;
  flex-shrink: 0;
}

.error-toggle:hover {
  text-decoration: underline;
}

/* ... existing styles ... */

.list-actions .searchbox button {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0;
  right: 8px;
  width: auto;
}

.list-actions .searchbox button:hover {
  background: transparent;
}

/* ... existing styles ... */

.summary-list strong {
  color: var(--text-main);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  text-align: right;
}

th {
  background: var(--bg-surface);
  padding: 12px 20px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr {
  transition: background-color 0.15s;
}

tr:hover td {
  background: var(--bg-list-hover);
  color: var(--text-main);
}

tr:hover td.text-success {
  color: var(--status-active-text);
}

tr:hover td.text-limited {
  color: var(--status-warning-text);
}

tr:hover td.text-error {
  color: var(--status-error-text);
}

tr:hover {
  outline: none;
}

tr.highlighted td {
  background: var(--bg-list-selected);
  border-bottom-color: var(--border-subtle);
}

tr.highlighted td:first-child {
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

input[type="text"],
input[type="search"],
input[type="file"] {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

input:focus {
  border-color: var(--accent-primary);
}

.list-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.searchbox {
  flex: 1;
  max-width: 320px;
  position: relative;
}

.searchbox button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

button {
  font-family: inherit;
}

.list-actions button,
.dialog-actions button {
  background: var(--accent-primary);
  color: var(--accent-primary-text);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.list-actions button:hover {
  background: var(--accent-primary-hover);
}

.list-actions label[role="button"] {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--accent-primary);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--accent-primary-text);
  position: relative;
  background: var(--accent-primary);
  transition: background 0.2s;
}

.list-actions label[role="button"] input {
  position: absolute;
  opacity: 0;
  width: 0;
}

.list-actions label[role="button"]:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.dialog-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.window.message-dialog,
.window.auth-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90%;
  max-width: 480px;
  background: var(--bg-panel);
  z-index: 51;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  /* Ensure children don't bleed out */
}

/* Title Bar - Common for all dialogs */
.title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

.title-bar-text {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-main);
}

.title-bar-controls button {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  border-radius: 4px;
  transition: all 0.2s;
}

.title-bar-controls button:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.title-bar-controls button::before,
.title-bar-controls button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 1.5px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.title-bar-controls button::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.window.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.window-body {
  padding: 20px;
}

.text-muted {
  color: var(--text-muted);
  font-size: 13px;
}

.summary-list>div {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

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

.summary-list strong {
  color: var(--text-main);
  font-weight: 500;
}

.settings-fieldset {
  margin-top: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 16px;
}

.settings-fieldset legend {
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-left: -4px;
}

.settings-fieldset label {
  font-size: 14px;
  color: var(--text-main);
}

.settings-fieldset input[type="checkbox"] {
  accent-color: var(--accent-primary);
  margin-right: 8px;
}

.settings-fieldset .text-muted {
  margin-top: 6px;
  margin-left: 22px;
}

.token-fieldset {
  margin-top: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 16px;
}

.token-fieldset legend {
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-left: -4px;
}

.token-fieldset .summary-list>div:last-child {
  border-bottom: none;
}

.auth-dialog__panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.auth-dialog__lead {
  margin: 0 0 20px 0;
  line-height: 1.5;
  color: var(--text-main);
}

.auth-dialog__detail {
  margin-bottom: 24px;
}

.auth-dialog__steps {
  margin: 0 0 24px 0;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-dialog__device-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.auth-dialog__methods {
  margin: 20px 0 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-dialog__methods legend {
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-left: -4px;
}

.auth-dialog__option {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  background: var(--bg-surface);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
}

.auth-dialog__option:hover {
  border-color: var(--accent-primary);
  background: var(--bg-list-hover);
}

.auth-dialog__option input[type="radio"] {
  position: absolute;
  top: 14px;
  left: 12px;
  margin: 0;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.auth-dialog__option:has(input:checked) {
  border-color: var(--accent-primary);
  background: var(--bg-list-hover);
}

.auth-dialog__option label {
  margin-left: 24px;
  font-weight: 500;
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
}

.auth-dialog__option-meta {
  margin-left: 24px;
  font-size: 12px;
  margin-top: 2px;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-dialog__actions,
.message-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

.auth-dialog__actions button,
.message-dialog__actions button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

/* Secondary Button */
.auth-dialog__actions button:not(.default),
.message-dialog__actions button:not(.default) {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.auth-dialog__actions button:not(.default):hover,
.message-dialog__actions button:not(.default):hover {
  background: var(--bg-surface);
  border-color: var(--text-muted);
}

/* Primary Button */
.auth-dialog__actions button.default,
.message-dialog__actions button.default {
  background: var(--accent-primary) !important;
  border: 1px solid var(--accent-primary) !important;
  color: var(--accent-primary-text) !important;
}

.auth-dialog__actions button.default:hover,
.message-dialog__actions button.default:hover {
  background: var(--accent-primary-hover) !important;
  border-color: var(--accent-primary-hover) !important;
}

.auth-dialog__code-value {
  font-family: monospace;
  font-size: 24px;
  letter-spacing: 4px;
  background: var(--bg-surface);
  padding: 4px 4px 4px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  color: var(--accent-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.auth-dialog__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.auth-dialog__status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.auth-dialog__status-text {
  font-weight: 600;
  color: var(--accent-primary);
  font-size: 14px;
}

.url-copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px;
}

.url-copy-row a {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  font-family: monospace;
  font-size: 13px;
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-primary) !important;
  transition: color 0.2s;
}

.url-copy-row a:hover {
  text-decoration: underline;
  color: var(--accent-primary-hover) !important;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex-shrink: 0;
  width: 70px;
  text-align: center;
  box-sizing: border-box;
}

.copy-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--text-muted);
}

.copy-btn.copy-success {
  color: #10b981 !important;
  border-color: #10b981 !important;
}

.auth-dialog__status-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 16px;
  padding: 8px 24px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
  z-index: 20;
}

.animate {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* Loading State */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-app);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  display: block;
}