:root {
  /* Shared design tokens for the framework-free UI. Keep new colors here so
     buttons, dialogs, and table states remain visually consistent. */
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --text: #17211b;
  --muted: #647067;
  --line: #dce3dc;
  --primary: #1f6f5b;
  --primary-strong: #155342;
  --primary-soft: #e2f1eb;
  --danger: #b43f3f;
  --danger-soft: #f7e6e4;
  --shadow: 0 18px 50px rgba(29, 47, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(31, 111, 91, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(160, 91, 53, 0.08), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.shell {
  width: calc(100% - 24px);
  margin: 0 auto;
  padding: 34px 0;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

code {
  overflow-wrap: anywhere;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 420px);
  justify-content: center;
  align-content: center;
  justify-items: stretch;
  gap: 24px;
  min-height: calc(100vh - 68px);
}

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

.brand-block h1,
.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 0.98;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.auth-card,
.toolbar,
.table-panel {
  padding: 18px;
}

.auth-card,
.dialog-card {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #314039;
  font-size: 0.88rem;
  font-weight: 700;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.time-process-control {
  display: grid;
  gap: 10px;
}

.time-process-summary,
.time-process-marks {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.time-process-summary {
  color: #314039;
  font-size: 0.9rem;
  font-weight: 800;
}

.time-process-summary strong {
  color: var(--primary);
  font-size: 1.1rem;
}

.time-process-slider {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--primary);
}

.time-process-slider:focus {
  box-shadow: none;
}

.time-process-marks {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.14);
}

.primary,
.secondary,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

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

.primary:hover {
  background: var(--primary-strong);
}

.secondary {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.secondary.is-active {
  background: var(--primary);
  color: #fff;
}

.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #edf2ef;
  color: #26362e;
}

.icon-button:hover,
.secondary:hover {
  filter: brightness(0.97);
}

.icon-button svg,
.primary svg,
.secondary svg,
.danger svg,
.search-wrap svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.is-loading svg {
  animation: spin 0.9s linear infinite;
}

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

.message {
  min-height: 20px;
  margin: 0;
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.message.error {
  color: var(--danger);
}

.steam-status-username {
  display: inline;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  padding: 0 2px;
  font: inherit;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.steam-status-username:hover,
.steam-status-username:focus-visible {
  background: var(--primary-soft);
  outline: none;
}

#steamScheduleStatusText {
  line-height: 1.45;
  white-space: pre-line;
}

.dialog-card.logs-card {
  width: 100%;
  max-height: min(78dvh, calc(100dvh - 40px));
  grid-template-rows: auto minmax(220px, 1fr) auto;
  gap: 0;
  overflow: hidden;
  padding: 0;
}

.logs-card .dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px 20px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.logs-card .dialog-head h2,
.logs-card .dialog-head p {
  margin: 0;
}

.logs-card .dialog-head > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.logs-output {
  width: 100%;
  height: clamp(320px, 58dvh, 680px);
  min-height: 220px;
  max-height: calc(100dvh - 190px);
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  resize: vertical;
  border: 0;
  border-radius: 0;
  background: #101914;
  color: #e7f2ec;
  padding: 18px 20px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  scroll-behavior: smooth;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  tab-size: 2;
}

.logs-card .dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0;
  padding: 14px 20px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

#logsDialog {
  width: min(1180px, calc(100dvw - 40px));
  max-width: calc(100dvw - 40px);
}

.schedule-countdown {
  margin: 0;
  color: var(--primary-strong);
  font-size: 1.05rem;
  font-weight: 800;
}

.app-layout {
  display: grid;
  gap: 16px;
  position: relative;
  padding-left: 188px;
}

.topbar,
.toolbar,
.table-head,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toolbar {
  flex-wrap: nowrap;
  justify-content: flex-start;
  min-width: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.top-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-actions {
  position: fixed;
  top: 142px;
  left: 12px;
  z-index: 20;
  width: 176px;
  flex: 0 0 176px;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  margin-left: 0;
  white-space: nowrap;
}

.toolbar-actions .primary,
.toolbar-actions .secondary,
.toolbar-actions .danger {
  width: 100%;
  flex: 0 0 auto;
  justify-content: flex-start;
}

.filter-menu,
.get-link-menu,
.extract-games-menu,
.steam-automation-menu {
  position: relative;
  width: 100%;
}

.filter-menu > .secondary,
.get-link-menu > .secondary,
.extract-games-menu > .secondary,
.steam-automation-menu > .secondary {
  width: 100%;
}

.filter-popover,
.get-link-popover,
.extract-games-popover,
.steam-automation-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  display: grid;
  gap: 12px;
  width: 220px;
  padding: 14px;
  border: 1px solid #17211b;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 24, 19, 0.18);
}

.get-link-popover,
.extract-games-popover,
.steam-automation-popover {
  gap: 6px;
}

.get-link-popover button,
.extract-games-popover button,
.steam-automation-popover button {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 750;
}

.get-link-popover button:hover,
.get-link-popover button:focus-visible,
.extract-games-popover button:hover,
.extract-games-popover button:focus-visible,
.steam-automation-popover button:hover,
.steam-automation-popover button:focus-visible {
  background: var(--primary-soft);
  color: var(--primary-strong);
  outline: none;
}

.filter-popover h2 {
  margin: 0 0 2px;
  color: var(--text);
  font-size: 0.9rem;
}

.filter-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 750;
  min-height: 28px;
  border-radius: 7px;
  padding: 3px 6px;
}

.filter-option-red {
  color: #c63620;
  background: rgba(255, 73, 29, 0.08);
  box-shadow: inset 4px 0 0 #ff491d;
}

.filter-option-green {
  color: #0d7f20;
  background: rgba(25, 197, 31, 0.08);
  box-shadow: inset 4px 0 0 #19c51f;
}

.filter-option-both {
  color: #26342d;
  background: linear-gradient(90deg, rgba(25, 197, 31, 0.12), rgba(255, 73, 29, 0.12));
  box-shadow: inset 4px 0 0 #19c51f, inset -4px 0 0 #ff491d;
}

.filter-option-empty {
  color: #526158;
  background: #f4f7f4;
  box-shadow: inset 4px 0 0 #a8b5ad;
}

.filter-option input {
  width: 16px;
  min-height: 16px;
  flex: 0 0 16px;
  accent-color: #3157ff;
}

.filter-option-red input {
  accent-color: #ff491d;
}

.filter-option-green input {
  accent-color: #19c51f;
}

.filter-option-both input {
  accent-color: #19c51f;
}

.filter-popover .primary {
  min-height: 32px;
  border-radius: 999px;
  background: #3157ff;
}

.user-chip {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.table-head h2,
.dialog-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.table-head p {
  margin: 5px 0 0;
}

.ai-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f6faf8;
  border: 1px solid var(--line);
  justify-self: end;
}

.ai-button:hover {
  filter: brightness(0.97);
}

.ai-button img {
  width: 28px;
  height: 28px;
}

.search-wrap {
  position: relative;
  flex: 0 1 420px;
  width: min(420px, 100%);
  max-width: 420px;
  min-width: 220px;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-wrap input {
  padding-left: 40px;
}

.table-panel {
  overflow: hidden;
  min-width: 0;
}

.table-wrap {
  /* Wide tables scroll horizontally on desktop; mobile switches to stacked rows
     below so dense account metadata remains readable. */
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.load-rows-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 0 2px;
}

.load-rows-button {
  min-width: 170px;
  justify-content: center;
}

.load-rows-button.is-complete {
  opacity: 0.5;
}

.all-rows-loaded {
  color: var(--muted);
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1240px;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f7faf7;
  color: #41514a;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sortable-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sort-controls {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.sort-arrow {
  width: 16px;
  min-height: 18px;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  color: #87948c;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
}

.sort-arrow:hover,
.sort-arrow:focus-visible {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.sort-arrow.is-active {
  color: #fff;
  background: var(--primary);
}

td {
  color: #24342c;
  font-size: 0.92rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr.is-selected-row {
  background: #f0f8f4;
  box-shadow: inset 4px 0 0 var(--primary);
}

.copy-cell {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.copy-cell:hover {
  color: var(--primary);
}

.password-pill {
  color: #314039;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.password-error {
  color: var(--danger);
}

.country-text,
.note-text,
.games-text,
.reason-text {
  display: block;
  max-height: 74px;
  overflow: auto;
  color: var(--muted);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.games-text {
  max-height: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.link-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.link-open-button {
  width: 32px;
  height: 32px;
}

.link-open-button svg {
  width: 16px;
  height: 16px;
}

.selected-row-button.is-selected {
  background: var(--primary);
  color: #fff;
}

.actions-col {
  width: 250px;
  text-align: right;
}

.status-checkbox {
  width: 34px;
  height: 34px;
  min-height: 34px;
  flex: 0 0 34px;
  appearance: none;
  border: 3px solid currentColor;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  padding: 0;
}

.status-checkbox.green {
  color: #19c51f;
}

.status-checkbox.red {
  color: #ff4f17;
}

.status-checkbox:checked {
  background: currentColor;
  box-shadow: inset 0 0 0 7px #fff;
}

.status-checkbox:focus-visible {
  outline: 3px solid rgba(31, 111, 91, 0.22);
  outline-offset: 2px;
}

.status-checkbox:disabled {
  cursor: wait;
  opacity: 0.55;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  color: var(--muted);
}

dialog {
  width: min(520px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 24, 19, 0.48);
}

.dialog-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  box-shadow: 0 24px 70px rgba(10, 18, 14, 0.28);
}

.dialog-actions {
  justify-content: flex-end;
  position: sticky;
  bottom: -18px;
  margin: 0 -18px -18px;
  padding: 12px 18px 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.proxy-sections {
  display: grid;
  gap: 14px;
}

.proxy-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.proxy-section h3 {
  margin: 0;
  color: #314039;
  font-size: 0.92rem;
}

.proxy-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.redundancy-proxy-list {
  display: grid;
  gap: 14px;
}

.proxy-dialog-actions {
  justify-content: space-between;
}

.proxy-action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.redundancy-button {
  min-width: 112px;
  min-height: 40px;
  justify-content: center;
}

.proxy-remove-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  flex: 0 0 34px;
}

#ollamaDialog {
  width: min(720px, calc(100% - 28px));
}

.ai-card {
  max-height: min(760px, calc(100vh - 32px));
}

.ai-status {
  margin: 4px 0 0;
  font-size: 0.84rem;
  font-weight: 700;
}

.ai-status.error {
  color: var(--danger);
}

.ai-permissions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-permissions label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  padding: 0 10px;
  color: #314039;
}

.ai-permissions input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--primary);
  padding: 0;
}

.ai-clear-button {
  min-height: 36px;
  padding: 0 12px;
}

.ai-messages {
  min-height: 260px;
  max-height: 360px;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

.ai-message {
  max-width: 88%;
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1.45;
}

.ai-message.user {
  justify-self: end;
  background: var(--primary);
  color: #fff;
}

.ai-message.assistant {
  justify-self: start;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.ai-message.tool {
  justify-self: start;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: #314039;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.ai-username-copy {
  border-radius: 4px;
  background: transparent;
  color: #1267c4;
  padding: 0;
  font: inherit;
  font-weight: 800;
  text-align: left;
  overflow-wrap: anywhere;
}

.ai-username-copy:hover {
  color: #0b4f98;
  text-decoration: underline;
}

.ai-form {
  display: flex;
  gap: 10px;
}

.ai-form input {
  flex: 1;
}

@media (max-width: 980px) {
  .app-layout {
    padding-left: 0;
  }

  .toolbar {
    overflow-x: auto;
  }

  .toolbar-actions {
    position: static;
    width: auto;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    margin-left: auto;
  }

  .toolbar-actions .primary,
  .toolbar-actions .secondary,
  .toolbar-actions .danger {
    width: auto;
    justify-content: center;
  }

  .filter-menu,
  .filter-menu > .secondary,
  .get-link-menu,
  .get-link-menu > .secondary,
  .extract-games-menu,
  .extract-games-menu > .secondary,
  .steam-automation-menu,
  .steam-automation-menu > .secondary {
    width: auto;
  }

  .filter-popover {
    right: 0;
    left: auto;
  }
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 20px, 1400px);
    padding: 18px 0;
  }

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

  .topbar,
  .table-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    align-items: center;
    gap: 12px;
    overflow-x: auto;
  }

  .search-wrap {
    flex: 1 1 220px;
    min-width: 180px;
  }

  .top-actions,
  .toolbar-actions,
  .ai-form {
    width: 100%;
  }

  .toolbar-actions {
    width: auto;
  }

  .filter-popover {
    width: min(220px, calc(100vw - 40px));
  }

  .primary,
  .secondary,
  .danger {
    flex: 1;
  }

  .toolbar-actions .primary,
  .toolbar-actions .secondary,
  .toolbar-actions .danger {
    flex: 0 0 auto;
  }

  .user-chip {
    flex: 1;
  }

  .ai-form {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(135deg, rgba(31, 111, 91, 0.07), transparent 42%),
      var(--bg);
  }

  .shell {
    width: min(100% - 16px, 1400px);
    padding: 12px 0 20px;
  }

  .app-layout {
    gap: 12px;
  }

  .brand-block h1,
  .topbar h1 {
    font-size: clamp(1.75rem, 10vw, 2.35rem);
    line-height: 1.05;
  }

  .topbar {
    gap: 12px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px 40px;
    gap: 8px;
  }

  .user-chip {
    max-width: none;
    min-width: 0;
    min-height: 40px;
    display: flex;
    align-items: center;
    padding-inline: 12px;
  }

  .auth-card,
  .toolbar,
  .table-panel,
  .dialog-card {
    padding: 14px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    overflow: visible;
  }

  .search-wrap {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: none;
  }

  .toolbar-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    flex: none;
    margin: 0;
  }

  .toolbar-actions .primary,
  .toolbar-actions .secondary,
  .toolbar-actions .danger,
  .filter-menu > .secondary,
  .get-link-menu > .secondary,
  .extract-games-menu > .secondary,
  .steam-automation-menu > .secondary {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding-inline: 9px;
    font-size: 0.84rem;
  }

  .filter-menu,
  .get-link-menu,
  .extract-games-menu,
  .steam-automation-menu {
    width: 100%;
    min-width: 0;
  }

  .toolbar-actions > #addButton {
    grid-column: 1 / -1;
  }

  .filter-popover,
  .get-link-popover,
  .extract-games-popover,
  .steam-automation-popover {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: 14px;
    left: 10px;
    width: auto;
    max-height: min(70vh, 420px);
    overflow: auto;
  }

  .table-head {
    gap: 8px;
  }

  .table-head p {
    margin-top: 3px;
  }

  .table-panel:has(#emptyState:not(.hidden)) .table-wrap {
    display: none;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  /* Mobile renders each table row as a card-like record while preserving the
     same DOM table for desktop accessibility and existing row-generation code. */
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  tbody td {
    display: grid;
    grid-template-columns: minmax(76px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-height: 44px;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  tbody td:last-child {
    border-bottom: 0;
  }

  tbody td::before {
    color: #526158;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.4;
    text-transform: uppercase;
  }

  tbody td:nth-child(1)::before {
    content: "Name";
  }

  tbody td:nth-child(2)::before {
    content: "Username";
  }

  tbody td:nth-child(3)::before {
    content: "Password";
  }

  tbody td:nth-child(4)::before {
    content: "Link";
  }

  tbody td:nth-child(5)::before {
    content: "Country";
  }

  tbody td:nth-child(6)::before {
    content: "Note";
  }

  tbody td:nth-child(7)::before {
    content: "Games";
  }

  tbody td:nth-child(8)::before {
    content: "Reason";
  }

  tbody td:nth-child(9)::before {
    content: "Actions";
  }

  .copy-cell {
    min-width: 0;
    min-height: 24px;
    align-items: flex-start;
    line-height: 1.35;
  }

  .link-actions {
    min-width: 0;
    justify-content: flex-start;
  }

  .country-text,
  .note-text,
  .games-text,
  .reason-text {
    max-height: 96px;
  }

  .games-text {
    max-height: none;
  }

  .actions-col {
    width: auto;
    text-align: left;
  }

  .row-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .status-checkbox {
    width: 38px;
    height: 38px;
    min-height: 38px;
    flex-basis: 38px;
  }

  .empty-state {
    min-height: 220px;
  }

  dialog {
    width: min(100% - 16px, 520px);
  }

  .dialog-actions {
    bottom: -14px;
    margin: 0 -14px -14px;
    padding: 12px 14px 14px;
  }
}

@media (max-width: 390px) {
  .toolbar-actions {
    grid-template-columns: 1fr;
  }

  tbody td {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
