:root {
  --bg: #0b0d10;
  --panel: #111418;
  --ink: #e8edf2;
  --muted: #8c96a3;
  --line: #242a31;
  --line-soft: #1a1f25;
  --primary: #00c2a8;
  --primary-dark: #35e5cf;
  --primary-soft: rgba(0, 194, 168, 0.13);
  --accent: #f6b34b;
  --accent-soft: rgba(246, 179, 75, 0.14);
  --danger: #ff4d5e;
  --danger-soft: rgba(255, 77, 94, 0.13);
  --sidebar: #16181d;
  --sidebar-2: #111318;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Noto Sans Thai", "IBM Plex Sans Thai", "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 14px;
  color: #fff;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #f8d98f;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.35;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #d9ece8;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  text-align: left;
  padding: 0 14px;
  font-weight: 700;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-tab.active {
  color: #10201d;
  background: #fff;
  border-color: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.connection-card {
  margin-top: auto;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.connection-card p {
  margin: 4px 0 0;
  color: #d9ece8;
  font-size: 13px;
  line-height: 1.4;
}

.status-dot {
  width: 12px;
  height: 12px;
  margin-top: 3px;
  border-radius: 50%;
  background: #f59e0b;
  flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.14);
}

.status-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.content {
  width: 100%;
  max-width: none;
  padding: 28px 34px;
  overflow: hidden;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

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

.spawn-note {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(460px, 42vw);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.spawn-note select,
.spawn-new-name {
  flex: 1;
  min-width: 220px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.spawn-note select:focus,
.spawn-new-name:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.spawn-plus-button {
  width: 42px;
  min-width: 42px;
  font-size: 22px;
  line-height: 1;
  color: #08110f;
  background: var(--primary);
  border-color: var(--primary);
}

.spawn-manager-dialog {
  width: min(620px, calc(100vw - 28px));
  padding: 0;
  overflow: hidden;
  border: 1px solid #2a333d;
  background:
    linear-gradient(180deg, rgba(0, 201, 178, 0.06), transparent 34%),
    #111418;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.spawn-manager-dialog .dialog-head {
  padding: 18px 22px;
  border-bottom: 1px solid #252d36;
  background: #12161b;
}

.spawn-manager-dialog .dialog-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.spawn-manager-subtitle {
  margin: 5px 0 0;
  color: #8f9aa7;
  font-size: 12px;
  font-weight: 700;
}

.spawn-manager-body {
  display: grid;
  gap: 16px;
  padding: 20px 22px 18px;
}

.spawn-manager-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid #222a33;
  border-radius: 10px;
  background: #0c1015;
}

.spawn-manager-add input {
  min-height: 44px;
  border: 1px solid #303a45;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #090c10;
  outline: none;
}

.spawn-manager-add input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 201, 178, 0.14);
}

.spawn-name-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.spawn-name-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 10px 8px 14px;
  border: 1px solid #26303a;
  border-radius: 10px;
  background: linear-gradient(180deg, #111820, #0b0f14);
  box-shadow: inset 3px 0 0 rgba(0, 201, 178, 0.55);
}

.spawn-name-item span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spawn-empty {
  padding: 32px 12px;
  border: 1px dashed #303842;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  background: #0b0e12;
}

.small-button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.spawn-manager-dialog .dialog-actions {
  margin: 0;
  padding: 14px 22px 18px;
  border-top: 1px solid #222a33;
  background: #0f1318;
}

.primary-button,
.secondary-button,
.danger-button,
.link-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: rgba(15, 118, 110, 0.24);
  padding: 0 14px;
  text-decoration: none;
}

.link-button:hover {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.primary-button {
  color: #fff;
  background: var(--primary);
  padding: 0 16px;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

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

.secondary-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  padding: 0 14px;
}

.danger-button {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f1c3bd;
  padding: 0 14px;
}

.secondary-button:hover,
.danger-button:hover,
.icon-button:hover,
.text-button:hover {
  border-color: #b9c5cf;
  box-shadow: var(--shadow-soft);
}

.icon-button {
  width: 42px;
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  font-size: 20px;
}

.toolbar {
  display: grid;
  grid-template-columns: auto minmax(280px, 420px) auto auto auto minmax(170px, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.updated-at {
  margin: -10px 0 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toolbar-time {
  margin: 0 0 0 auto;
  white-space: nowrap;
  justify-self: end;
  color: #7b8792;
}

.sheet-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sheet-picker select {
  min-width: 210px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.sheet-picker select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.toolbar input,
.settings-form input,
.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.toolbar input:focus,
.settings-form input:focus,
.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.toolbar input {
  max-width: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.table-wrap,
.settings-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  padding: 18px;
}

.inline-panel {
  margin-top: 16px;
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 700;
}

.summary-list {
  display: grid;
  gap: 8px;
}

.summary-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfcfd;
}

.summary-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.summary-row strong {
  font-size: 17px;
}

.summary-row > strong {
  min-width: 76px;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  color: var(--accent);
  background: var(--accent-soft);
}

.compact {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.table-wrap {
  overflow: auto;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(18, 38, 63, 0.06);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pagination-bar span {
  margin-right: auto;
}

.pagination-bar label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-bar select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.pagination-bar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.command-builder {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

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

.command-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.command-builder-head strong {
  display: block;
  font-size: 15px;
}

.command-builder-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.command-id-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.command-id-field input {
  width: 82px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.command-id-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.command-builder textarea {
  width: 100%;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f8fafb;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

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

.select-cell input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th,
td {
  height: 52px;
  padding: 10px 9px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #45525f;
  font-size: 12px;
  font-weight: 800;
  background: #f6f8fa;
}

.celebrity-table thead th[data-group]::before {
  content: attr(data-group);
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.celebrity-table th:nth-child(3),
.celebrity-table td:nth-child(3),
.celebrity-table th:nth-child(4),
.celebrity-table td:nth-child(4) {
  background: #fff;
}

.celebrity-table th:nth-child(5),
.celebrity-table td:nth-child(5),
.celebrity-table th:nth-child(6),
.celebrity-table td:nth-child(6),
.celebrity-table th:nth-child(7),
.celebrity-table td:nth-child(7) {
  background: #fbf7ee;
}

.celebrity-table th:nth-child(9),
.celebrity-table td:nth-child(9),
.celebrity-table th:nth-child(10),
.celebrity-table td:nth-child(10),
.celebrity-table th:nth-child(11),
.celebrity-table td:nth-child(11) {
  background: #f0faf8;
}

.celebrity-table th:nth-child(12),
.celebrity-table td:nth-child(12),
.celebrity-table th:nth-child(13),
.celebrity-table td:nth-child(13),
.celebrity-table th:nth-child(14),
.celebrity-table td:nth-child(14),
.celebrity-table th:nth-child(15),
.celebrity-table td:nth-child(15) {
  background: #f4f7ff;
}

.celebrity-table th:nth-child(5),
.celebrity-table td:nth-child(5),
.celebrity-table th:nth-child(9),
.celebrity-table td:nth-child(9),
.celebrity-table th:nth-child(12),
.celebrity-table td:nth-child(12),
.celebrity-table th:nth-child(16),
.celebrity-table td:nth-child(16) {
  border-left: 2px solid #cbd5df;
}

tbody tr:nth-child(even) td {
  background: #fbfcfd;
}

tbody tr:hover td {
  background: var(--primary-soft);
}

.celebrity-table tbody tr:hover td {
  filter: brightness(0.985);
}

th:first-child,
td:first-child {
  width: 52px;
  text-align: center;
}

th:nth-child(2),
td:nth-child(2) {
  width: 126px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 145px;
}

.celebrity-table th:nth-child(5),
.celebrity-table td:nth-child(5),
.celebrity-table th:nth-child(6),
.celebrity-table td:nth-child(6),
.celebrity-table th:nth-child(7),
.celebrity-table td:nth-child(7) {
  width: 96px;
  text-align: center;
}

.celebrity-table th:nth-child(8),
.celebrity-table td:nth-child(8),
.celebrity-table th:nth-child(9),
.celebrity-table td:nth-child(9),
.celebrity-table th:nth-child(10),
.celebrity-table td:nth-child(10),
.celebrity-table th:nth-child(11),
.celebrity-table td:nth-child(11),
.celebrity-table th:nth-child(12),
.celebrity-table td:nth-child(12),
.celebrity-table th:nth-child(13),
.celebrity-table td:nth-child(13),
.celebrity-table th:nth-child(14),
.celebrity-table td:nth-child(14),
.celebrity-table th:nth-child(15),
.celebrity-table td:nth-child(15) {
  width: 122px;
}

.celebrity-table th:nth-child(2),
.celebrity-table td:nth-child(2) {
  width: 56px;
  text-align: center;
}

.celebrity-table th:nth-child(3),
.celebrity-table td:nth-child(3) {
  width: 126px;
}

.celebrity-table th:nth-child(4),
.celebrity-table td:nth-child(4) {
  width: 145px;
}

.celebrity-table th:nth-child(16),
.celebrity-table td:nth-child(16) {
  width: 132px;
}

.cars-table th:nth-child(4),
.cars-table td:nth-child(4),
.cars-table th:nth-child(5),
.cars-table td:nth-child(5),
.cars-table th:nth-child(6),
.cars-table td:nth-child(6) {
  width: 132px;
}

.cars-table th:nth-child(2),
.cars-table td:nth-child(2) {
  width: 56px;
  text-align: center;
}

.cars-table th:nth-child(3),
.cars-table td:nth-child(3) {
  width: 124px;
}

.cars-table th:nth-child(4),
.cars-table td:nth-child(4),
.cars-table th:nth-child(5),
.cars-table td:nth-child(5),
.cars-table th:nth-child(6),
.cars-table td:nth-child(6),
.cars-table th:nth-child(7),
.cars-table td:nth-child(7) {
  width: 120px;
}

.cars-table th:nth-child(8),
.cars-table td:nth-child(8) {
  width: 150px;
}

th:last-child,
td:last-child {
  width: 96px;
}

.field-createdAt,
.field-updatedAt {
  width: 112px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

th:nth-last-child(3),
td:nth-last-child(3),
th:nth-last-child(2),
td:nth-last-child(2) {
  width: 112px;
  text-align: center;
}

td.note-cell {
  min-width: 170px;
  white-space: normal;
  line-height: 1.45;
}

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

.check-mark,
.dash-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  height: 24px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.check-mark {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.22);
}

.dash-mark {
  color: #9aa4ad;
  background: #f2f4f6;
  border: 1px solid #e3e8ed;
}

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

.text-button {
  min-height: 30px;
  border: 1px solid #cdd7df;
  border-radius: 8px;
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 0 10px;
}

.copy-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.copy-cell span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-copy-button {
  flex: 0 0 auto;
  min-height: 28px;
  border: 1px solid #303842;
  border-radius: 7px;
  padding: 0 9px;
  color: #d9e1e8;
  background: #171d24;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.mini-copy-button:hover {
  border-color: var(--primary);
  color: #08110f;
  background: var(--primary);
}

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

.settings-form {
  display: grid;
  gap: 16px;
  max-width: 760px;
  padding: 18px;
}

.settings-form label,
.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

dialog {
  width: min(780px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
}

dialog::backdrop {
  background: rgba(12, 20, 18, 0.52);
}

#recordForm {
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-section {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #242a31;
  border-radius: 8px;
  background: #0d1015;
}

.form-section h4 {
  margin: 0;
  color: #f3f7fb;
  font-size: 14px;
  font-weight: 900;
}

.form-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-section-grid > label,
.form-section-grid > .checkbox-field {
  min-width: 0;
}

.form-section-grid .field-twitterSkinFrame,
.form-section-grid .field-itemSpawnName,
.form-section-grid .field-carReceiverDiscord,
.form-section-grid .field-carSpawnName {
  grid-column: auto;
}

.form-section-grid .checkbox-field {
  min-height: 52px;
}

.form-section-grid label:has(textarea) {
  grid-column: 1 / -1;
}

.form-section:last-child .form-section-grid > label {
  grid-column: 1 / -1;
}

.form-grid > label:last-child {
  grid-column: 1 / -1;
}

.checkbox-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  cursor: pointer;
}

.form-grid .checkbox-field,
.form-section-grid .checkbox-field {
  display: flex;
  grid-auto-flow: unset;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
}

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

.checkbox-field span {
  font-size: 14px;
}

.form-grid textarea {
  min-height: 86px;
  resize: vertical;
}

.dialog-actions {
  justify-content: flex-end;
  margin: 18px 0 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #1f2937;
  box-shadow: var(--shadow);
  transform: translateY(80px);
  opacity: 0;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.hidden {
  display: none !important;
}

.empty {
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .spawn-note,
  .spawn-note select,
  .spawn-new-name {
    width: 100%;
  }

  .spawn-note {
    align-items: flex-start;
    flex-direction: column;
    min-width: 0;
  }

  .content {
    padding: 18px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar-time {
    justify-self: start;
    margin-left: 0;
  }

  .sheet-picker {
    align-items: flex-start;
    flex-direction: column;
  }

  .sheet-picker select,
  .toolbar input,
  .toolbar button {
    width: 100%;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-bar span {
    margin-right: 0;
  }

  .pagination-bar label,
  .pagination-bar select,
  .pagination-bar button {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
  }

  tbody tr:nth-child(even) td,
  tbody tr:hover td {
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: 120px 1fr;
    min-height: 42px;
    height: auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left !important;
    white-space: normal;
  }

  td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .celebrity-table td:nth-child(1)::before,
  .cars-table td:nth-child(1)::before { content: "ลำดับ"; }
  .celebrity-table td:nth-child(2)::before { content: "เลือก"; }
  .celebrity-table td:nth-child(3)::before { content: "ชื่อ"; }
  .celebrity-table td:nth-child(4)::before { content: "Discord"; }
  .celebrity-table td:nth-child(5)::before { content: "เพชร"; }
  .celebrity-table td:nth-child(6)::before { content: "Points"; }
  .celebrity-table td:nth-child(7)::before { content: "กรอบสกิน"; }
  .celebrity-table td:nth-child(8)::before { content: "ชื่อเสก ทวิต"; }
  .celebrity-table td:nth-child(9)::before { content: "เบอร์โทร"; }
  .celebrity-table td:nth-child(10)::before { content: "คนรับเบอร์"; }
  .celebrity-table td:nth-child(11)::before { content: "Discord ผู้รับ"; }
  .celebrity-table td:nth-child(12)::before { content: "ทะเบียนรถบิน"; }
  .celebrity-table td:nth-child(13)::before { content: "คนรับรถ"; }
  .celebrity-table td:nth-child(14)::before { content: "DC คนรับรถ"; }
  .celebrity-table td:nth-child(15)::before { content: "ชื่อเสกรถ"; }
  .celebrity-table td:nth-child(16)::before,
  .cars-table td:nth-child(8)::before { content: "หมายเหตุ"; }
  .celebrity-table td:nth-child(17)::before,
  .cars-table td:nth-child(9)::before { content: "สร้าง"; }
  .celebrity-table td:nth-child(18)::before,
  .cars-table td:nth-child(10)::before { content: "แก้ไข"; }
  .celebrity-table td:nth-child(19)::before,
  .cars-table td:nth-child(11)::before { content: "จัดการ"; }

  .cars-table td:nth-child(2)::before { content: "เลือก"; }
  .cars-table td:nth-child(3)::before { content: "ชื่อเจ้าของ"; }
  .cars-table td:nth-child(4)::before { content: "Discord เจ้าของ"; }
  .cars-table td:nth-child(5)::before { content: "ชื่อคนรับ"; }
  .cars-table td:nth-child(6)::before { content: "Discord ผู้รับ"; }
  .cars-table td:nth-child(7)::before { content: "ทะเบียน"; }

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

@media (max-width: 620px) {
  .nav-tabs,
  .form-grid {
    grid-template-columns: 1fr;
  }

  h2 {
    font-size: 24px;
  }

  .metric strong {
    font-size: 28px;
  }
}

/* Dark dashboard theme */
.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1c22 0%, #121419 100%);
}

.sidebar .eyebrow {
  color: #f6c35f;
}

.nav-tab {
  color: #aeb7c2;
  border-color: #2a3038;
  background: #1b1f25;
}

.nav-tab:hover {
  color: #e9eef4;
  background: #222832;
}

.nav-tab.active {
  color: #ffffff;
  border-color: #343c47;
  background: #2a3038;
  box-shadow: inset 3px 0 0 var(--primary);
}

.connection-card,
.metric,
.panel,
.table-wrap,
.settings-form,
.toolbar,
.command-builder,
dialog,
.summary-row,
tbody tr {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

.connection-card p,
.updated-at,
.toolbar-time,
.metric span,
.summary-row span,
.panel-head span,
.command-builder-head span,
.settings-form label,
.form-grid label,
.sheet-picker,
.spawn-note,
.command-id-field {
  color: var(--muted);
}

.primary-button {
  color: #041311;
  background: var(--primary);
  box-shadow: 0 0 20px rgba(0, 194, 168, 0.16);
}

.primary-button:hover {
  background: #35e5cf;
}

.secondary-button,
.icon-button,
.text-button,
.link-button {
  color: #d9e1e8;
  border-color: #303842;
  background: #171b21;
}

.secondary-button:hover,
.icon-button:hover,
.text-button:hover,
.link-button:hover {
  border-color: #46515f;
  background: #202630;
}

.link-button {
  color: var(--primary-dark);
  background: rgba(0, 194, 168, 0.08);
  border-color: rgba(0, 194, 168, 0.25);
}

.danger-button,
.danger {
  color: #ff9aa4;
  border-color: rgba(255, 77, 94, 0.28);
  background: var(--danger-soft);
}

.toolbar input,
.settings-form input,
.form-grid input,
.form-grid textarea,
.form-grid select,
.sheet-picker select,
.spawn-note select,
.spawn-new-name,
.command-id-field input,
.pagination-bar select,
.command-builder textarea {
  color: var(--ink);
  border-color: #303842;
  background: #0e1116;
}

.command-builder textarea {
  color: #b7c0ca;
  background: #0b0e12;
}

.toolbar input::placeholder,
.form-grid input::placeholder,
.command-builder textarea::placeholder {
  color: #626d79;
}

thead th {
  color: #aeb8c4;
  background: #161a20;
  border-bottom-color: #252b33;
}

td {
  color: #dbe2e9;
}

tbody tr:nth-child(even) td {
  background: #0f1217;
}

tbody tr:hover td {
  background: #151c22;
}

.celebrity-table tbody tr:hover td {
  filter: none;
}

.celebrity-table th:nth-child(3),
.celebrity-table td:nth-child(3),
.celebrity-table th:nth-child(4),
.celebrity-table td:nth-child(4) {
  background: rgba(255, 255, 255, 0.015);
}

.celebrity-table th:nth-child(5),
.celebrity-table td:nth-child(5),
.celebrity-table th:nth-child(6),
.celebrity-table td:nth-child(6),
.celebrity-table th:nth-child(7),
.celebrity-table td:nth-child(7) {
  background: rgba(246, 179, 75, 0.055);
}

.celebrity-table th:nth-child(9),
.celebrity-table td:nth-child(9),
.celebrity-table th:nth-child(10),
.celebrity-table td:nth-child(10),
.celebrity-table th:nth-child(11),
.celebrity-table td:nth-child(11) {
  background: rgba(0, 194, 168, 0.055);
}

.celebrity-table th:nth-child(12),
.celebrity-table td:nth-child(12),
.celebrity-table th:nth-child(13),
.celebrity-table td:nth-child(13),
.celebrity-table th:nth-child(14),
.celebrity-table td:nth-child(14),
.celebrity-table th:nth-child(15),
.celebrity-table td:nth-child(15) {
  background: rgba(90, 130, 255, 0.075);
}

.celebrity-table th:nth-child(5),
.celebrity-table td:nth-child(5),
.celebrity-table th:nth-child(9),
.celebrity-table td:nth-child(9),
.celebrity-table th:nth-child(12),
.celebrity-table td:nth-child(12),
.celebrity-table th:nth-child(16),
.celebrity-table td:nth-child(16) {
  border-left-color: #38414c;
}

.check-mark {
  color: #061815;
  background: rgba(0, 194, 168, 0.88);
  border-color: rgba(0, 194, 168, 0.5);
}

.dash-mark {
  color: #8d97a3;
  background: #1b2027;
  border-color: #2a313a;
}

.panel-head span,
.summary-row > strong {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.summary-row > strong {
  color: #f6c35f;
  background: var(--accent-soft);
}

.metric::before {
  background: linear-gradient(180deg, var(--primary), #6b8cff);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

/* Modal readability polish */
dialog {
  color: var(--ink);
  background: #111418;
  border: 1px solid #242a31;
}

#recordForm h3,
.dialog-head h3 {
  color: #f3f7fb;
  font-size: 18px;
  font-weight: 850;
}

.settings-form label,
.form-grid label {
  color: #aeb8c4;
  font-size: 13px;
  font-weight: 800;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  color: #edf3f8;
  border-color: #303842;
  background: #0c0f14;
}

.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 194, 168, 0.13);
}

.checkbox-field {
  border-color: #303842;
  background: #0c0f14;
  color: #dce5ed;
}

.checkbox-field:hover {
  border-color: #435060;
  background: #121821;
}

.checkbox-field span {
  color: #aeb8c4;
  font-size: 14px;
  font-weight: 850;
}

.checkbox-field input {
  accent-color: var(--primary);
}

.checkbox-field input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid #4a5665;
  border-radius: 4px;
  background: #0a0d12;
}

.checkbox-field input[type="checkbox"]::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 2px;
  transform: scale(0);
  transition: transform 0.12s ease;
  background: var(--primary);
}

.checkbox-field input[type="checkbox"]:checked {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 194, 168, 0.12);
}

.checkbox-field input[type="checkbox"]:checked::before {
  transform: scale(1);
}

.dialog-head {
  border-bottom-color: #242a31;
}
