:root {
  --bg-main: #f4f6f8;
  --bg-card: #ffffff;
  --bg-table-row: #ffffff;
  --bg-table-row-alt: #f9fafb;
  --border-color: #e2e8f0;
  --text-main: #1a202c;
  --text-muted: #718096;
  --accent: #3182ce;
  --accent-soft: rgba(49, 130, 206, 0.1);
  --danger: #e53e3e;
  --success: #38a169;
  --warning: #d69e2e;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: linear-gradient(to bottom, #f7fafc, #edf2f7);
  color: var(--text-main);
}

/* Layout */
.app {
  max-width: 1100px;
  margin: 24px auto;
  padding: 16px 20px 28px;
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 16px;
  border-bottom: 1px solid var(--border-color);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: radial-gradient(circle at 20% 0, #ffd66b, #f0803c 45%, #bb2a79);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(0, 0, 0, 0.05);
}

.app-title {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.app-subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 12px rgba(74, 211, 149, 0.8);
}

.status-text {
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.refresh-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}

.refresh-btn:hover {
  background: rgba(49, 130, 206, 0.2);
  box-shadow: 0 0 0 1px rgba(49, 130, 206, 0.4);
}

.refresh-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Toolbar */
.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.sort-select {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: white;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.sort-select:focus {
  border-color: var(--accent);
}

/* Content */
.content {
  padding-top: 16px;
}

.table-wrapper {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

/* Table */
.live-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.live-table thead {
  background: #f7fafc;
}

.live-table th,
.live-table td {
  padding: 10px 14px;
  text-align: center;
  vertical-align: middle;
}

.live-table th:first-child,
.live-table td:first-child {
  text-align: left;
}

.live-table th {
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.live-table tbody tr {
  background: var(--bg-table-row);
  transition: background 0.1s;
}

.live-table tbody tr:nth-child(even) {
  background: var(--bg-table-row-alt);
}

.live-table tbody tr:hover {
  background: #f1f5f9;
}

.live-table tbody tr+tr {
  border-top: 1px solid var(--border-color);
}

.col-channel {
  width: 40%;
}

/* Channel Cell */
.channel-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-avatar {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 0 0, #ffd66b, #f0803c 50%, #bb2a79);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.channel-avatar-img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background: #eee;
}

.channel-info-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-text-main {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.channel-text-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  line-clamp: 1;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 300px;
}

/* Badges */
.badge-hot {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  background: #fff5f5;
  color: #e53e3e;
  border: 1px solid #feb2b2;
  margin-left: 6px;
}

.badge-hot-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #e53e3e;
}

/* Number Cells */
.cell-number {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: center;
}

.cell-number.xu-high {
  color: var(--warning);
  font-weight: 700;
}

.cell-number.slot-low {
  color: var(--danger);
}

.cell-number.slot-high {
  color: var(--success);
}

/* Highlight */
.row-highlight-gold {
  background-color: #fffaf0 !important;
}

.row-highlight-gold td {
  border-bottom-color: #fce8b2;
}

.row-highlight-gold:hover {
  background-color: #fff3c4 !important;
}

/* View Link */
.view-link {
  display: inline-block;
  padding: 6px 14px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s;
  text-align: center;
}

.view-link:hover {
  background: #2b6cb0;
  text-decoration: none;
}

/* Placeholder */
.placeholder-row {
  text-align: center;
}

.placeholder-text {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}

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

/* Mobile */
@media (max-width: 768px) {
  .app {
    margin: 12px;
    padding: 14px 12px;
  }

  .app-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-group {
    justify-content: space-between;
  }

  .col-channel {
    width: auto;
  }

  .channel-text-sub {
    max-width: 180px;
  }

  /* Hide Chờ (3) and View (5) on mobile, keep Slot (4) */
  .live-table th:nth-child(3),
  .live-table th:nth-child(5),
  .live-table td:nth-child(3),
  .live-table td:nth-child(5) {
    display: none;
  }
}