:root {
      color-scheme: dark;
      --bg: #0d1210;
      --panel: #171e1a;
      --panel-2: #202923;
      --line: #344138;
      --text: #f2f6f3;
      --muted: #9eada3;
      --green: #75c84a;
      --green-dark: #376d29;
      --red: #e3484f;
      --gold: #e5a83b;
      --blue: #59a7e8;
      --shadow: 0 14px 38px rgba(0, 0, 0, .28);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: var(--bg);
      color: var(--text);
    }

    * { box-sizing: border-box; }

    body {
      min-width: 320px;
      margin: 0;
      background:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
        radial-gradient(circle at 12% 0%, rgba(67, 132, 52, .22), transparent 34rem),
        var(--bg);
      background-size: 32px 32px, 32px 32px, auto, auto;
    }

    button, input { font: inherit; }
    button { color: inherit; }

    main {
      width: min(1180px, calc(100% - 32px));
      margin: 0 auto;
      padding: 32px 0 56px;
    }

    .topbar {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 24px;
      margin-bottom: 22px;
    }

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

    h1 { margin: 0; font-size: clamp(27px, 4vw, 42px); line-height: 1.05; letter-spacing: -.035em; }
    h2 { margin: 0; font-size: 19px; }
    p { margin: 0; }

    .connection-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

    .button {
      min-height: 40px;
      border: 1px solid #53853f;
      border-radius: 7px;
      padding: 9px 15px;
      background: linear-gradient(#6eae4d, #508f35);
      box-shadow: inset 0 1px rgba(255,255,255,.18), 0 4px 12px rgba(0,0,0,.2);
      font-weight: 800;
      cursor: pointer;
    }

    .button:hover { filter: brightness(1.08); }
    .button.secondary { border-color: var(--line); background: var(--panel-2); box-shadow: none; }

    .statusbar {
      display: flex;
      align-items: center;
      gap: 9px;
      flex-wrap: wrap;
      margin-bottom: 18px;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      min-height: 31px;
      padding: 6px 10px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: rgba(23, 30, 26, .88);
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }

    .badge::before { width: 7px; height: 7px; border-radius: 50%; background: #768079; content: ""; }
    .badge.ok { color: #a9e48d; border-color: #385e2e; }
    .badge.ok::before { background: var(--green); box-shadow: 0 0 10px var(--green); }
    .badge.bad { color: #ff989d; border-color: #673338; }
    .badge.bad::before { background: var(--red); }
    .badge.neutral::before { display: none; }

    .overview {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 12px;
    }

    .stat, .panel {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: linear-gradient(145deg, rgba(33, 43, 36, .96), rgba(20, 27, 23, .98));
      box-shadow: var(--shadow);
    }

    .stat { min-height: 112px; padding: 17px; position: relative; overflow: hidden; }
    .stat::after { position: absolute; right: -18px; bottom: -30px; width: 82px; height: 82px; border: 16px solid rgba(117,200,74,.06); transform: rotate(22deg); content: ""; }
    .stat-label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
    .stat-value { display: block; margin-top: 8px; font-size: 28px; font-weight: 850; letter-spacing: -.035em; }
    .stat-detail { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

    .dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 12px; }
    .panel { padding: 18px; min-width: 0; }
    .panel + .panel, .dashboard-grid + .panel, .panel + .dashboard-grid { margin-top: 12px; }

    .section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
    .section-note { margin-top: 3px; color: var(--muted); font-size: 12px; }

    .range-picker { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #101612; }
    .range-button { border: 0; border-radius: 5px; padding: 5px 8px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
    .range-button.active { background: var(--green-dark); color: #efffe9; }

    .chart-wrap { position: relative; height: 230px; }
    #tpsChart { display: block; width: 100%; height: 100%; }
    .chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; }
    .chart-empty[hidden] { display: none; }

    .server-facts { display: grid; gap: 0; margin: 0; }
    .fact { display: grid; grid-template-columns: 104px minmax(0,1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(75, 91, 80, .48); }
    .fact:last-child { border-bottom: 0; }
    .fact dt { color: var(--muted); font-size: 12px; }
    .fact dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 700; text-align: right; }

    .players-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .player-card { border: 1px solid var(--line); border-radius: 9px; padding: 15px; background: rgba(12, 17, 14, .48); }
    .player-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
    .player-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
    .avatar { display: grid; place-items: center; flex: 0 0 38px; height: 38px; border: 2px solid #4c5c50; background: #29332b; color: var(--green); font-size: 18px; font-weight: 900; image-rendering: pixelated; }
    .player-name { overflow: hidden; text-overflow: ellipsis; font-weight: 850; white-space: nowrap; }
    .player-mode { margin-top: 2px; color: var(--muted); font-size: 11px; text-transform: capitalize; }
    .ping { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-weight: 700; }
    .vitals { display: grid; gap: 8px; }
    .vital-row { display: grid; grid-template-columns: 54px minmax(0,1fr) 52px; align-items: center; gap: 8px; }
    .vital-name { color: var(--muted); font-size: 11px; }
    .vital-value { color: var(--muted); font-size: 11px; text-align: right; }
    .pips { display: flex; align-items: center; gap: 2px; min-width: 0; min-height: 17px; }
    .pip-icon { display: block; width: 17px; height: 17px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 #000); }
    .player-meta { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; margin-top: 13px; padding-top: 12px; border-top: 1px solid rgba(75, 91, 80, .48); color: var(--muted); font-size: 11px; }
    .player-meta strong { color: var(--text); font-weight: 750; }

    .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
    table { width: 100%; border-collapse: collapse; background: rgba(11, 16, 13, .38); }
    th, td { padding: 10px 12px; border-bottom: 1px solid rgba(69, 83, 74, .55); text-align: left; font-size: 12px; vertical-align: middle; }
    thead th { background: #222c25; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
    tbody tr:last-child td { border-bottom: 0; }
    tbody tr:hover { background: rgba(117, 200, 74, .045); }
    .numeric { text-align: right; font-variant-numeric: tabular-nums; }
    .download-cell { width: 106px; text-align: center; }
    .download-link { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 6px 10px; border: 1px solid #49643f; border-radius: 5px; background: #2b382e; color: #dff5d4; font-size: 11px; font-weight: 800; text-decoration: none; white-space: nowrap; }
    .download-link:hover { border-color: var(--green); background: #354a38; }
    .download-link.unavailable,
    .download-link.unavailable:hover { border-color: #5e4141; background: #352727; color: #bd9a9a; cursor: not-allowed !important; }

    details { border: 1px solid var(--line); border-radius: 9px; background: var(--panel); overflow: hidden; }
    details + details { margin-top: 10px; }
    summary { padding: 13px 16px; background: var(--panel-2); cursor: pointer; font-weight: 800; }
    .details-body { padding: 14px; }
    .details-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
    .download-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
    .details-toolbar input { width: min(300px, 100%); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #0e1410; color: var(--text); }
    .bulk-download { min-height: 35px; border: 1px solid #53853f; border-radius: 6px; padding: 7px 11px; background: #376d29; color: #f2ffed; font-size: 11px; font-weight: 850; cursor: pointer; white-space: nowrap; }
    .bulk-download:disabled { cursor: wait; opacity: .55; }
    .download-status { min-height: 18px; margin: 8px 0 0; color: var(--muted); font-size: 11px; text-align: right; }
    .download-status.error { color: #ff989d; }
    .download-status.warning { color: #e9bd68; }
    pre { max-height: 350px; margin: 0; padding: 14px; overflow: auto; border-radius: 7px; background: #090d0a; color: #dce8df; font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
    .empty { padding: 22px; color: var(--muted); font-style: italic; text-align: center; }

    @media (max-width: 900px) {
      .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .dashboard-grid { grid-template-columns: 1fr; }
    }

    @media (max-width: 640px) {
      main { width: min(100% - 20px, 1180px); padding-top: 20px; }
      .topbar { display: block; }
      .connection-actions { justify-content: flex-start; margin-top: 16px; }
      .overview { grid-template-columns: 1fr 1fr; gap: 8px; }
      .stat { min-height: 98px; padding: 13px; }
      .stat-value { font-size: 23px; }
      .players-grid { grid-template-columns: 1fr; }
      .panel { padding: 13px; }
      .section-head { align-items: flex-start; flex-direction: column; }
      .range-picker { width: 100%; }
      .range-button { flex: 1; }
      .pips { gap: 1px; }
      .pip-icon { width: 14px; height: 14px; }
    }
