  /* ============================================================
     Header
     ============================================================ */
  .header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 64px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, rgba(17, 24, 39, 0.85) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 30px rgba(0, 0, 0, 0.3);
  }

  /* --- Logo + Title --- */
  .header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 340px;
  }

  .logo {
    width: 42px;
    height: 42px;
    position: relative;
    flex-shrink: 0;
  }

  .logo svg {
    width: 100%;
    height: 100%;
  }

  .logo-glow {
    position: absolute;
    inset: -6px;
    border-radius: 4px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.25) 0%, transparent 70%);
    filter: blur(10px);
    animation: logo-pulse 3s ease-in-out infinite;
  }

  @keyframes logo-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1) rotate(0deg); }
    50% { opacity: 0.9; transform: scale(1.1) rotate(2deg); }
  }

  .title-group {
    display: flex;
    align-items: baseline;
    gap: 10px;
  }

  .title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    line-height: 1;
    white-space: nowrap;
  }

  .title span {
    color: var(--accent-cyan);
  }

  .subtitle {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    line-height: 1;
    padding-top: 1px;
    white-space: nowrap;
  }

  /* --- Center: Status Cluster --- */
  .header-center {
    display: flex;
    align-items: center;
    gap: 24px;
  }

  .status-item {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 0 10px;
    height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.2s ease;
  }

  .status-item:hover {
    border-color: rgba(0, 255, 136, 0.2);
    box-shadow: var(--shadow-glow);
  }

  .status-label {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .status-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
  }

  /* --- Online Indicator --- */
  .online-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
  }

  .online-indicator.is-online {
    border-color: rgba(0, 255, 136, 0.25);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.08);
  }

  .online-indicator.is-offline {
    border-color: rgba(255, 71, 87, 0.25);
    box-shadow: 0 0 12px rgba(255, 71, 87, 0.08);
  }

  .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    position: relative;
  }

  .is-online .status-dot {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: dot-blink 2s ease-in-out infinite;
  }

  .is-offline .status-dot {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
    animation: dot-blink-fast 1s ease-in-out infinite;
  }

  @keyframes dot-blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--accent-green); }
    50% { opacity: 0.5; box-shadow: 0 0 16px var(--accent-green); }
  }

  @keyframes dot-blink-fast {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }

  .online-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
  }

  .is-online .online-text { color: var(--accent-green); }
  .is-offline .online-text { color: var(--accent-red); }

  /* --- Ping --- */
  #ping-item { gap: 5px; }

  .ping-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 17px;
  }

  .ping-value.good { color: var(--accent-green); }
  .ping-value.ok { color: var(--accent-yellow); }
  .ping-value.warn { color: var(--accent-orange); }
  .ping-value.bad { color: var(--accent-red); }
  .ping-value.offline { color: var(--text-muted); }

  .ping-unit {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
  }

  /* --- Ping Bar Indicator --- */
  .ping-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
  }

  .ping-bar {
    width: 3px;
    border-radius: 1px;
    background: var(--text-muted);
    transition: background 0.3s ease;
  }

  .ping-bar.b1 { height: 4px; }
  .ping-bar.b2 { height: 7px; }
  .ping-bar.b3 { height: 10px; }
  .ping-bar.b4 { height: 14px; }

  .ping-bars.good .ping-bar { background: var(--accent-green); }
  .ping-bars.ok .ping-bar.b1,
  .ping-bars.ok .ping-bar.b2,
  .ping-bars.ok .ping-bar.b3 { background: var(--accent-yellow); }
  .ping-bars.ok .ping-bar.b4 { background: var(--text-muted); }
  .ping-bars.warn .ping-bar.b1,
  .ping-bars.warn .ping-bar.b2 { background: var(--accent-orange); }
  .ping-bars.warn .ping-bar.b3,
  .ping-bars.warn .ping-bar.b4 { background: var(--text-muted); }
  .ping-bars.bad .ping-bar.b1 { background: var(--accent-red); }
  .ping-bars.bad .ping-bar.b2,
  .ping-bars.bad .ping-bar.b3,
  .ping-bars.bad .ping-bar.b4 { background: var(--text-muted); }

  /* --- Flip Clock --- */
  .time-block {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .flip-clock {
    display: flex;
    align-items: center;
    gap: 3px;
  }

  .flip-digit {
    position: relative;
    width: 26px;
    height: 36px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 5px;
  }

  /* Divider line in the middle */
  .flip-digit::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    height: 1px;
    background: rgba(0,0,0,0.4);
    z-index: 5;
    pointer-events: none;
  }

  .flip-digit-inner {
    position: absolute;
    left: 0; right: 0;
    top: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
  }

  /* New digit: starts above, slides down */
  .flip-digit-inner.flip-new {
    animation: flip-in 0.35s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    z-index: 2;
  }

  /* Old digit: starts in place, slides down and fades */
  .flip-digit-inner.flip-old {
    animation: flip-out 0.35s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
    z-index: 1;
  }

  @keyframes flip-in {
    0%   { transform: translateY(-100%); opacity: 0.6; }
    100% { transform: translateY(0);     opacity: 1; }
  }

  @keyframes flip-out {
    0%   { transform: translateY(0);      opacity: 1; }
    100% { transform: translateY(100%);   opacity: 0; }
  }

  .flip-colon {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-cyan);
    opacity: 0.6;
    animation: colon-blink 1s ease-in-out infinite;
    line-height: 1;
    padding: 0 1px;
  }

  @keyframes colon-blink {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.15; }
  }

  .time-label {
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .time-label.pm { color: var(--accent-cyan); }
  .time-label.msk { color: var(--accent-purple); }

  /* --- Separator --- */
  .header-sep {
    width: 1px;
    height: 32px;
    background: var(--border);
    flex-shrink: 0;
  }

  /* --- Profile Button --- */
  .header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
  }

  .profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
  }

  .profile-btn:hover {
    background: var(--bg-card-hover);
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 16px rgba(0, 212, 255, 0.12);
    transform: scale(1.05);
  }

  .profile-btn[aria-expanded="true"] {
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 0 18px rgba(0, 212, 255, 0.18);
  }

  .profile-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--bg-primary);
    flex-shrink: 0;
    text-transform: uppercase;
  }

  /* ============================================================
     Profile Menu (dropdown)
     ============================================================ */
  .profile-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 300px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 500;
    transform-origin: top right;

    /* Closed state — invisible, not interactive */
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    visibility: hidden;
    transition:
      opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1),
      transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s linear 0.18s;
  }

  .profile-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
    transition:
      opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
      transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s linear 0s;
  }

  .profile-menu-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 14px;
  }

  .profile-field {
    margin-bottom: 12px;
  }
  .profile-field label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 6px;
  }
  .profile-field input {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
  }
  .profile-field input:focus {
    border-color: var(--accent-cyan);
  }
  .profile-field input::placeholder {
    color: var(--text-muted);
    font-size: 11px;
  }

  .profile-save-btn {
    width: 100%;
    padding: 9px;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--bg-primary);
    background: var(--accent-cyan);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity 0.2s;
  }
  .profile-save-btn:hover { opacity: 0.85; }
  .profile-save-btn:disabled { opacity: 0.4; cursor: default; }

  .profile-msg {
    margin-top: 8px;
    min-height: 14px;
    font-size: 11px;
    text-align: center;
    transition: color 0.2s;
  }
  .profile-msg.ok { color: var(--accent-green); }
  .profile-msg.err { color: var(--accent-red); }

  /* Retention input is narrow with the message inline next to it. */
  .profile-retention-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .profile-retention-row input {
    width: 96px;
    text-align: center;
    /* Hide native spin buttons — they collide with the small width. */
    appearance: textfield;
  }

  .profile-retention-row input::-webkit-outer-spin-button,
  .profile-retention-row input::-webkit-inner-spin-button {
    appearance: none;
    margin: 0;
  }

  .profile-retention-row .profile-msg {
    margin: 0;
    text-align: left;
    min-width: 60px;
  }

  .profile-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 14px -16px;
  }

  .profile-logout-btn {
    width: 100%;
    padding: 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent-red);
    background: transparent;
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .profile-logout-btn:hover {
    background: rgba(255, 71, 87, 0.08);
    border-color: rgba(255, 71, 87, 0.55);
  }

  /* ============================================================
     Login Overlay
     ============================================================ */
  .login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
  }
  html.unauthed .login-overlay { display: flex; }

  .login-card {
    width: 320px;
    padding: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .login-logo {
    text-align: center;
    margin-bottom: 24px;
  }
  .login-logo svg { display: block; margin: 0 auto 12px; }
  .login-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 1px;
    text-transform: uppercase;
  }
  .login-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-top: 4px;
  }

  .login-field {
    margin-bottom: 14px;
  }
  .login-field label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 6px;
  }
  .login-field input {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
  }
  .login-field input:focus {
    border-color: var(--accent-cyan);
  }

  .login-btn {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--bg-primary);
    background: var(--accent-cyan);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity 0.2s;
  }
  .login-btn:hover { opacity: 0.85; }
  .login-btn:disabled { opacity: 0.4; cursor: default; }

  .login-error {
    margin-top: 12px;
    font-size: 11px;
    color: var(--accent-red);
    text-align: center;
    min-height: 16px;
  }

  /* ============================================================
     Responsive — progressive hiding
     ============================================================ */
  @media (max-width: 1120px) {
    .header { padding: 0 16px; gap: 10px; }
    .header-left { min-width: unset; }
    .header-center { gap: 10px; }
    .title-group {
      flex-direction: column;
      gap: 2px;
    }
    .flip-digit { width: 22px; height: 30px; }
    .flip-digit-inner { font-size: 18px; }
    .flip-colon { font-size: 18px; }
  }

  @media (max-width: 950px) {
    #ping-item { padding: 0 8px; gap: 4px; }
  }

  @media (max-width: 850px) {
    #ping-item { padding: 0 8px; gap: 4px; }
    #msk-block, #msk-sep { display: none; }
  }

  @media (max-width: 700px) {
    #utc-block, #utc-sep { display: none; }
    .header-center { gap: 8px; }
  }
