    :root {
      --brand-blue: #1d4ed8;
      --brand-blue-100: #dbeafe;
      --brand-gray: #0f172a;
      --muted: #64748b;
      --brand-primary: #6366f1;
      --brand-primary-light: #e0e7ff;
      --brand-gray-200: #e5e7eb;
      --brand-gray-700: #374151;
    }
    body {
      background: #f8fafc;
      color: var(--brand-gray);
      font-family: "Noto Sans TC", "Noto Sans SC", "PingFang TC", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", system-ui, sans-serif;
    }
    .layout {
      display: flex;
      min-height: 100vh;
    }
    .sidebar {
      width: 260px;
      background: #ffffff;
      border-right: 1px solid #e2e8f0;
      padding: 28px 22px;
      position: sticky;
      top: 0;
      height: 100vh;
    }
    .sidebar-brand {
      display: flex;
      align-items: center;
      gap: 12px;
      font-weight: 700;
      font-size: 1.1rem;
    }
    .brand-icon {
      width: 44px;
      height: 44px;
      border-radius: 14px;
      background: #4f46e5;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #ffffff;
      font-size: 22px;
    }
    .sidebar-nav {
      margin-top: 32px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .sidebar-link {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 14px;
      border-radius: 14px;
      color: #475569;
      text-decoration: none;
      font-weight: 600;
    }
    .sidebar-link.active {
      background: #eef2ff;
      color: #4f46e5;
    }
    .sidebar-link svg {
      width: 22px;
      height: 22px;
    }
    .sidebar-footer {
      margin-top: auto;
      padding-top: 18px;
      border-top: 1px solid #e2e8f0;
      color: #94a3b8;
      font-size: 0.9rem;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .sidebar-pill {
      background: #eef2ff;
      color: #4f46e5;
      border-radius: 999px;
      padding: 4px 10px;
      font-weight: 600;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .content {
      flex: 1;
      min-width: 0;
    }
    .under-construction {
      display: none;
      padding: 48px 0;
      text-align: center;
      color: #94a3b8;
      font-size: 1.1rem;
    }
    .under-construction.show {
      display: block;
    }
    @media (max-width: 991px) {
      .layout {
        flex-direction: column;
      }
      .sidebar {
        position: relative;
        width: 100%;
        height: auto;
      }
    }
    .page-header {
      background: #ffffff;
      border-bottom: 1px solid #e2e8f0;
      box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
    }
    .panel {
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: 16px;
      box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    }
    .table-header {
      color: #64748b;
      font-weight: 600;
      background: #f8fafc;
    }
    .race-table td,
    .race-table th {
      vertical-align: middle;
      padding: 18px 16px;
    }
    .status-badge {
      border-radius: 999px;
      padding: 4px 12px;
      font-weight: 600;
      font-size: 0.85rem;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .status-badge.ok {
      background: #dcfce7;
      color: #16a34a;
    }
    .status-badge.alert {
      background: #fee2e2;
      color: #dc2626;
    }
    .status-badge.offline {
      background: #fee2e2;
      color: #dc2626;
    }
    .scheduler-alert {
      border-radius: 12px;
      padding: 12px 16px;
      margin-bottom: 16px;
      background: #fee2e2;
      color: #b91c1c;
      font-weight: 600;
    }
    .progress-pill {
      width: 140px;
      height: 8px;
      border-radius: 999px;
      background: #e5e7eb;
      overflow: hidden;
      display: inline-block;
      margin-right: 10px;
    }
    .progress-pill span {
      display: block;
      height: 100%;
      background: #22c55e;
      border-radius: 999px;
    }
    .race-progress-card {
      background: transparent;
      border-radius: 0;
      padding: 0;
      box-shadow: none;
      max-width: 220px;
    }
    .race-progress-title {
      font-size: 12px;
      color: #6b7280;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 6px;
      gap: 8px;
    }
    .race-progress-count {
      font-size: 12px;
      font-weight: 600;
      color: #475569;
      white-space: nowrap;
    }
    .race-progress-track {
      height: 6px;
      background: #e5e7eb;
      border-radius: 999px;
      overflow: hidden;
      margin-bottom: 8px;
    }
    .race-progress-bar {
      display: block;
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, #22c55e, #86efac);
      border-radius: 999px;
      transition: width 0.4s ease;
    }
    .race-progress-extra {
      border-top: 1px solid #f3f4f6;
      padding-top: 6px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 12px;
      color: #6b7280;
      gap: 8px;
    }
    .race-progress-badge {
      background: #f8fafc;
      padding: 2px 8px;
      border-radius: 999px;
      font-weight: 600;
      color: #2563eb;
      font-size: 12px;
      white-space: nowrap;
    }
    .action-btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 16px;
      border-radius: 8px;
      font-size: 14px;
      font-weight: 600;
      border: none;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    .action-btn[data-action="detail"] {
      background-color: rgba(59, 130, 246, 0.1);
      color: #1d4ed8;
    }
    .action-btn[data-action="detail"]:hover {
      background-color: #1d4ed8;
      color: #ffffff;
    }
    .action-btn[data-action="history"] {
      background-color: rgba(245, 158, 11, 0.1);
      color: #b45309;
    }
    .action-btn[data-action="history"]:hover {
      background-color: #b45309;
      color: #ffffff;
    }
    .action-btn[data-action="import"] {
      background-color: rgba(16, 185, 129, 0.12);
      color: #047857;
    }
    .action-btn[data-action="import"]:hover {
      background-color: #047857;
      color: #ffffff;
    }
    .modal-hero {
      background: linear-gradient(135deg, #3b5bff, #5c6cff);
      color: #ffffff;
      padding: 18px 24px;
      border-radius: 16px 16px 0 0;
    }
    .modal-dialog.modal-detail {
      max-width: 1080px;
    }
    .modal-content.detail-modal {
      border-radius: 18px;
      overflow: hidden;
      box-shadow: 0 24px 40px rgba(15, 23, 42, 0.2);
    }
    .detail-toolbar {
      border: 1px solid #e2e8f0;
      border-radius: 14px;
      padding: 14px 18px;
      background: #ffffff;
    }
    .detail-stats {
      border-top: 1px solid #e2e8f0;
      border-bottom: 1px solid #e2e8f0;
      padding: 18px 8px;
    }
    .detail-table thead th {
      font-weight: 600;
    }
    .detail-table .ring-image {
      max-height: 36px;
      max-width: 140px;
      display: inline-block;
      object-fit: contain;
    }
    .btn-outline-danger {
      border-color: #fca5a5;
      color: #ef4444;
      background: #fff5f5;
    }
    .btn-outline-danger:hover {
      background: #fee2e2;
      border-color: #f87171;
      color: #dc2626;
    }
    .btn-outline-secondary {
      border-color: #e2e8f0;
      color: #475569;
      background: #ffffff;
    }
    .btn-outline-secondary:hover {
      background: #f8fafc;
    }
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 16px;
    }
    .stats-card {
      background: #f8fafc;
      border-radius: 12px;
      padding: 16px;
      text-align: center;
    }
    .stats-card h3 {
      margin: 0;
      font-size: 1.6rem;
      font-weight: 700;
    }
    .section-title {
      font-weight: 600;
    }
    .modal-header {
      border-bottom: 1px solid #e2e8f0;
    }
    .modal-footer {
      border-top: 1px solid #e2e8f0;
    }
    .modal-step {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 0;
    }
    .todo-list {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .todo-item {
      border: 1px solid #e2e8f0;
      border-radius: 16px;
      background: #ffffff;
      padding: 18px 20px;
      display: flex;
      align-items: center;
      gap: 18px;
      transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    }
    .todo-item:hover {
      transform: translateY(-1px);
      box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
    }
    .todo-item.selected {
      border-color: #4f46e5;
      box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
      background: #f5f7ff;
    }
    .todo-check {
      width: 20px;
      height: 20px;
      border-radius: 999px;
      border: 2px solid #cbd5f5;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: #4f46e5;
      font-size: 14px;
      flex-shrink: 0;
    }
    .todo-item.selected .todo-check {
      border-color: #4f46e5;
      background: #4f46e5;
      color: #ffffff;
    }
    .status-dot {
      width: 10px;
      height: 10px;
      border-radius: 999px;
      background: #22c55e;
      margin-top: 6px;
      flex-shrink: 0;
    }
    .status-dot.alert {
      background: #f59e0b;
    }
    .status-dot.error {
      background: #ef4444;
    }
    .badge-soft {
      background: var(--brand-blue-100);
      color: var(--brand-blue);
      font-weight: 600;
    }
    .muted {
      color: var(--muted);
    }
    .step-pill {
      border-radius: 999px;
      padding: 8px 14px;
      font-size: 0.9rem;
      background: #eef2ff;
      color: #475569;
      border: 1px solid #e2e8f0;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-weight: 600;
    }
    .step-pill.active {
      background: #e0e7ff;
      color: #1d4ed8;
      border-color: #c7d2fe;
    }
    .step-arrow {
      color: #cbd5f5;
      font-weight: 600;
    }
    .roster-file-meta {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }
    .roster-preview {
      border-top: 1px solid #e2e8f0;
      padding-top: 12px;
    }
    .search-input {
      border-radius: 14px;
      padding-left: 42px;
      background: #f8fafc;
      border: 1px solid #e2e8f0;
    }
    .search-icon {
      position: absolute;
      left: 16px;
      top: 50%;
      transform: translateY(-50%);
      color: #94a3b8;
    }
    .status-pill {
      background: #fef3c7;
      color: #b45309;
      border-radius: 999px;
      padding: 2px 10px;
      font-size: 0.8rem;
      font-weight: 600;
      margin-left: 8px;
    }
    .status-pill.started {
      background: #dcfce7;
      color: #16a34a;
    }
    .primary-btn {
      background: #4f46e5;
      border-color: #4f46e5;
    }
    #manualImportBtn {
      color: #ffffff;
    }
    #manualImportBtn:hover,
    #manualImportBtn:focus {
      color: #ffffff;
    }
    .modal-body {
      max-height: 70vh;
      overflow-y: auto;
    }
    .spinner-wrap {
      display: flex;
      align-items: center;
      gap: 12px;
      color: var(--muted);
    }
    .vendor-toolbar {
      border: 1px dashed #cbd5f5;
      background: #f8faff;
    }
    .vendor-card {
      border: 1px solid #e2e8f0;
      border-radius: 18px;
      padding: 18px;
      background: #ffffff;
      box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
      height: 100%;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .vendor-status {
      border-radius: 999px;
      padding: 4px 12px;
      font-weight: 600;
      font-size: 0.85rem;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .vendor-status.online {
      background: #dcfce7;
      color: #16a34a;
    }
    .vendor-status.offline {
      background: #fee2e2;
      color: #dc2626;
    }
    .vendor-status.warning {
      background: #fef3c7;
      color: #b45309;
    }
    .vendor-meta {
      display: grid;
      gap: 6px;
      color: var(--muted);
      font-size: 0.9rem;
    }
    .vendor-meta a {
      color: #2563eb;
      text-decoration: none;
      word-break: break-all;
    }
    .vendor-meta a:hover {
      text-decoration: underline;
    }
    .vendor-note {
      background: #f8fafc;
      border-radius: 12px;
      padding: 10px 12px;
      font-size: 0.85rem;
      color: #475569;
      white-space: pre-wrap;
      word-break: break-word;
    }
    .vendor-actions {
      margin-top: auto;
      display: flex;
      justify-content: flex-end;
    }
    .dashboard-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 16px;
    }
    .dashboard-card {
      border-radius: 16px;
      padding: 18px;
      border: 1px solid #e2e8f0;
      background: #ffffff;
      box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    }
    .dashboard-card .label {
      color: #64748b;
      font-size: 0.9rem;
    }
    .dashboard-card .value {
      font-size: 1.6rem;
      font-weight: 700;
      margin-top: 6px;
    }
    .alert-card {
      border-radius: 16px;
      padding: 18px;
      border: 1px solid #fecaca;
      background: #fef2f2;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }
    .monitor-list {
      display: grid;
      gap: 12px;
    }
    .monitor-item {
      border-radius: 14px;
      border: 1px solid #e2e8f0;
      padding: 14px 16px;
      background: #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      cursor: pointer;
    }
    .monitor-item:hover {
      background: #f8fafc;
    }
    .active-races-card {
      border-radius: 18px;
      border: 1px solid #e2e8f0;
      overflow: hidden;
      background: #ffffff;
      box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
    }
    .active-race-item {
      padding: 16px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      cursor: pointer;
      border-top: 1px solid #f1f5f9;
    }
    .active-race-item:first-child {
      border-top: none;
    }
    .active-race-item:hover {
      background: #f8fafc;
    }
    .active-race-icon {
      width: 42px;
      height: 42px;
      border-radius: 14px;
      background: #dcfce7;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
    }
    .active-race-meta {
      color: #64748b;
      font-size: 0.9rem;
    }
    .active-pill {
      border-radius: 999px;
      padding: 3px 10px;
      font-size: 0.75rem;
      font-weight: 600;
      border: 1px solid #bbf7d0;
      background: #dcfce7;
      color: #15803d;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .region-pill {
      border-radius: 999px;
      padding: 2px 8px;
      font-size: 0.75rem;
      background: #eef2ff;
      color: #4f46e5;
    }
    .vendor-status-list {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 320px));
      gap: 12px;
      justify-content: start;
    }
    .vendor-status-item {
      border-radius: 16px;
      border: 1px solid #e2e8f0;
      padding: 16px 18px;
      background: #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
      max-width: 320px;
      width: 100%;
      justify-self: start;
    }
    .vendor-status-left {
      display: flex;
      align-items: center;
      gap: 12px;
      font-weight: 600;
    }
    .vendor-status-right {
      color: #64748b;
      font-weight: 600;
    }
    .status-dot {
      width: 10px;
      height: 10px;
      border-radius: 999px;
      display: inline-block;
      flex: 0 0 10px;
      min-width: 10px;
      max-width: 10px;
    }
    .status-dot.online {
      background: #22c55e;
    }
    .status-dot.warning {
      background: #f59e0b;
    }
    .status-dot.offline {
      background: #ef4444;
    }
    .abnormal-list {
      display: grid;
      gap: 12px;
    }
    .abnormal-item {
      border: 1px solid #e2e8f0;
      border-radius: 12px;
      padding: 12px 14px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      background: #ffffff;
    }
    .abnormal-item.error {
      border-color: #fecaca;
      background: #fef2f2;
    }

    .login-overlay {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(15, 23, 42, 0.72);
      z-index: 2000;
      padding: 24px;
    }
    body.login-active {
      overflow: hidden;
    }
    body.login-active .login-overlay {
      display: flex;
    }
    body.login-active .layout {
      visibility: hidden;
      opacity: 0;
      pointer-events: none;
      user-select: none;
    }
    .login-card {
      width: min(420px, 92vw);
      background: #ffffff;
      border-radius: 18px;
      padding: 24px;
      box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
    }
    .login-card-header {
      margin-bottom: 16px;
      text-align: center;
    }
    .login-title {
      font-size: 1.4rem;
      font-weight: 700;
      margin: 0 0 6px;
      color: #0f172a;
    }
    .login-subtitle {
      margin: 0;
      font-size: 0.9rem;
      color: #64748b;
    }
    .login-card-footer {
      margin-top: 12px;
    }
  
