  /* ========== THEME VARIABLES ========== */
  :root,
  :root[data-theme="light"] {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --input: #ffffff;
    --green: #0e9f6e;
    --green2: #0b7a56;
    --mint: #2dd4a0;
    --gold: #f5b942;
    --red: #e11d48;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
    --welcome-bg: linear-gradient(135deg, #061a33, #0a2a4a 60%, #0b4a47);
    --ring-bg: #0a2a4a;
    --bar-track: #eaf0f8;
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #071426;
    --surface: #0d1f36;
    --text: #eaf1fb;
    --muted: #93a4bd;
    --line: #1f3350;
    --input: #0a1a2e;
    --green: #2dd4a0;
    --green2: #14b88a;
    --mint: #2dd4a0;
    --gold: #f5b942;
    --red: #fb7185;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --welcome-bg: linear-gradient(135deg, #04101f, #0a1f38 60%, #0b3a38);
    --ring-bg: #0a1a2e;
    --bar-track: #152a45;
  }

  /* Apply theme to page */
  body {
    background: var(--bg) !important;
    color: var(--text);
  }

  /* ========== DASHBOARD STYLES (theme-aware) ========== */
  .welcome {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding: 26px 28px;
    border-radius: 20px;
    color: #fff;
    background: var(--welcome-bg);
  }

  .welcome h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.03em;
    margin: 0 0 4px;
  }

  .welcome p {
    margin: 0;
    color: #b8c9de;
    font-size: 14px;
  }

  .kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
  }

  .kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    color: var(--text);
  }

  .kpi .ic {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 17px;
    margin-bottom: 14px;
  }

  .kpi small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
  }

  .kpi b {
    display: block;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.03em;
    margin-top: 4px;
    color: var(--text);
  }

  .kpi .d {
    font-size: 12.5px;
    font-weight: 700;
    margin-top: 6px;
  }

  .up { color: var(--green2); }
  .down { color: var(--red); }
  .flat { color: var(--muted); }

  .cols {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
  }

  .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 22px;
    min-width: 0;
    color: var(--text);
  }

  .panel h3 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 800;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
  }

  .panel h3 a {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--green2);
    text-decoration: none;
  }

  .bars {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    height: 220px;
    padding-top: 10px;
  }

  .bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 8px;
  }

  .bar i {
    width: 100%;
    max-width: 56px;
    border-radius: 10px 10px 4px 4px;
    background: linear-gradient(180deg, var(--mint), var(--green2));
    min-height: 4px;
    transition: .3s;
  }

  .bar:last-child i {
    background: linear-gradient(180deg, var(--gold), #e59a12);
  }

  .bar:hover i { filter: brightness(1.1); }

  .bar span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
  }

  .bar em {
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
  }

  .rank { margin-bottom: 14px; }

  .rank div {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 6px;
    gap: 10px;
    color: var(--text);
  }

  .rank div span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .rank u {
    display: block;
    height: 8px;
    border-radius: 9px;
    background: var(--bar-track);
  }

  .rank u i {
    display: block;
    height: 100%;
    border-radius: 9px;
    background: linear-gradient(90deg, var(--green), var(--mint));
  }

  .quick {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
  }

  .quick a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow);
    transition: .2s;
  }

  .quick a:hover {
    transform: translateY(-3px);
    border-color: var(--green);
  }

  .quick a i {
    color: var(--green2);
    font-size: 18px;
  }

  .pill {
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 99px;
    display: inline-block;
  }

  .pill.ok {
    background: #e8f8f1;
    color: #0b6b4d;
  }

  .pill.wait {
    background: #fff4dc;
    color: #9a6700;
  }

  .pill.low {
    background: #fdecef;
    color: #b4122f;
  }

  :root[data-theme="dark"] .pill.ok {
    background: #0b3d2e;
    color: #6ee7b7;
  }

  :root[data-theme="dark"] .pill.wait {
    background: #3d2e0b;
    color: #fcd34d;
  }

  :root[data-theme="dark"] .pill.low {
    background: #3d0b16;
    color: #fda4af;
  }

  .ring {
    --p: 0;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--mint) calc(var(--p) * 1%), rgba(255, 255, 255, .18) 0);
  }

  .ring div {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--ring-bg);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
  }

  .empty {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    padding: 24px 0;
  }

  /* Table in dark mode */
  .panel table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text);
  }

  .panel th {
    background: var(--bar-track);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
  }

  .panel td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
  }

  /* Theme toggle button */
  #theme {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text);
    transition: background .2s, color .2s;
  }

  #theme:hover {
    background: var(--line);
    color: var(--green2);
  }

  @media (max-width: 960px) {
    .cols { grid-template-columns: 1fr; }
    .welcome .fbrRatio{
      width: 100%;
      justify-content: right;
    }
  }