:root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-secondary: #2c2c2e;
    --text: #ffffff;
    --text-muted: #8e8e93;
    --accent: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --purple: #bf5af2;
    --orange: #ff9f0a;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
  body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Helvetica, Arial, sans-serif;
    padding-top: max(58px, calc(env(safe-area-inset-top) + 20px));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 20px));
    user-select: none;
    -webkit-user-select: none;
  }
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
  }
  .title-group h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
  }
  .title-group p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--card);
  }
  .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
  }
  .dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
  .dot.offline { background: var(--red); }

  .section-divider-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin: 28px 4px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* Segmented control */
  .segmented-control {
    display: flex;
    background: var(--card);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 12px;
  }
  .segment-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .segment-btn.active {
    background: #636366;
    color: var(--text);
  }

  /* Navigatore del periodo con frecce */
  .period-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 20px;
  }
  .nav-btn {
    background: var(--card-secondary);
    border: none;
    color: var(--accent);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
  }
  .period-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.2px;
  }

  /* Big stat card */
  .hero-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
  }
  .hero-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .hero-time {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 8px 0 4px;
    color: var(--text);
  }
  .hero-sub {
    font-size: 14px;
    color: var(--text-muted);
  }

  /* Sessions card (Timeline) */
  .sessions-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
  }
  .sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
  }
  .sessions-title {
    font-size: 16px;
    font-weight: 700;
  }
  .sessions-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .sessions-badge {
    background: rgba(10, 132, 255, 0.2);
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 12px;
  }
  .session-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--card-secondary);
    border-radius: 12px;
    margin-bottom: 8px;
  }
  .session-item:last-child {
    margin-bottom: 0;
  }
  .session-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .session-dot.in_corso { background: var(--green); box-shadow: 0 0 8px var(--green); }
  .session-dot.normale { background: var(--accent); }
  .session-dot.blackout { background: var(--red); box-shadow: 0 0 8px var(--red); }
  .session-main {
    flex: 1;
  }
  .session-time {
    font-size: 14px;
    font-weight: 700;
  }
  .session-tag {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .session-dur {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
  }

  /* Bar chart */
  .chart-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px 14px;
    margin-bottom: 20px;
  }
  .chart-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
  }
  .bars-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 120px;
    padding-bottom: 24px;
    position: relative;
    border-bottom: 1px solid var(--card-secondary);
  }
  .bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    position: relative;
  }
  .bar-fill {
    width: 60%;
    max-width: 24px;
    background: var(--accent);
    border-radius: 6px 6px 2px 2px;
    transition: height 0.3s ease;
    min-height: 4px;
  }
  .bar-fill.active-day {
    background: var(--green);
  }
  .bar-label {
    position: absolute;
    bottom: -22px;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
  }
  .bar-val {
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
  }

  /* App breakdown */
  .apps-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
  }
  .apps-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
  }
  .app-row {
    margin-bottom: 16px;
  }
  .app-row:last-child {
    margin-bottom: 0;
  }
  .app-header {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 6px;
  }
  .app-name {
    font-weight: 600;
  }
  .app-duration {
    font-weight: 600;
    color: var(--text-muted);
  }
  .progress-bg {
    width: 100%;
    height: 8px;
    background: var(--card-secondary);
    border-radius: 4px;
    overflow: hidden;
  }
  .progress-bar {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.3s ease;
  }
  .empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 25px 0;
    font-size: 14px;
  }

  /* Crashes card */
  .crashes-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
  }
  .crashes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
  }
  .crashes-title {
    font-size: 16px;
    font-weight: 700;
  }
  .crashes-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .crashes-badge {
    background: rgba(255, 69, 58, 0.2);
    color: var(--red);
    font-weight: 700;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 12px;
  }
  .month-group {
    background: var(--card-secondary);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
  }
  .month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
  }
  .month-header span.count {
    color: var(--text-muted);
    font-size: 13px;
  }
  .events-container {
    padding: 0 14px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }
  .event-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  .event-item:last-child {
    border-bottom: none;
  }
  .event-icon {
    color: var(--red);
  }

  /* Running apps card */
  .running-apps-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
  }
  .running-apps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
  }
  .running-apps-title {
    font-size: 16px;
    font-weight: 700;
  }
  .running-apps-badge {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--card-secondary);
    padding: 4px 10px;
    border-radius: 12px;
  }
  .running-app-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.2s ease;
  }
  .running-app-row:last-child {
    border-bottom: none;
  }
  .running-app-row.in-use-row {
    background: rgba(48, 209, 88, 0.07);
    border-radius: 10px;
    padding-left: 10px;
    padding-right: 10px;
    margin: 3px 0;
    border-bottom: none;
  }
  .running-app-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
  }
  .running-app-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #636366;
    flex-shrink: 0;
    transition: all 0.2s ease;
  }
  .running-app-dot.in-use {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
  }
  .running-app-name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .running-app-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .badge-in-use {
    display: inline-flex;
    align-items: center;
    background: rgba(48, 209, 88, 0.18);
    color: var(--green);
    border: 1px solid rgba(48, 209, 88, 0.35);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    line-height: 1.2;
    flex-shrink: 0;
  }
  .running-app-proc {
    font-size: 11px;
    color: var(--text-muted);
  }
  .kill-btn {
    background: rgba(255, 69, 58, 0.12);
    color: var(--red);
    border: 1px solid rgba(255, 69, 58, 0.3);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 10px;
    transition: opacity 0.2s ease;
  }
  .kill-btn:active {
    opacity: 0.7;
  }
  .close-all-btn {
    background: rgba(255, 69, 58, 0.12);
    color: var(--red);
    border: 1px solid rgba(255, 69, 58, 0.3);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .close-all-btn:active {
    opacity: 0.7;
    transform: scale(0.96);
  }
  .badge-multi-win {
    display: inline-flex;
    align-items: center;
    background: rgba(10, 132, 255, 0.18);
    color: var(--accent);
    border: 1px solid rgba(10, 132, 255, 0.35);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    line-height: 1.2;
    flex-shrink: 0;
    cursor: pointer;
  }
  .badge-multi-win:active {
    opacity: 0.7;
  }
  .app-submenu {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    margin: 6px 0 10px 18px;
    padding: 4px 8px;
    display: none;
  }
  .app-submenu.open {
    display: block;
    animation: modalPop 0.15s ease-out;
  }
  .sub-window-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
  }
  .sub-window-row:last-child {
    border-bottom: none;
  }
  .sub-window-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    transition: background 0.15s ease;
  }
  .sub-window-info:active {
    background: rgba(255, 255, 255, 0.08);
  }
  .sub-window-title {
    font-size: 12px;
    color: #e5e5ea;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
  }
  .sub-window-active-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 6px;
    flex-shrink: 0;
    box-shadow: 0 0 6px var(--green);
  }
  .sub-close-btn {
    background: rgba(255, 69, 58, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 69, 58, 0.3);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
    transition: opacity 0.2s ease;
  }
  .sub-close-btn:active {
    opacity: 0.6;
  }

  /* Closed apps section */
  .closed-apps-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 16px 0 14px;
  }
  .closed-apps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  .closed-apps-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .closed-apps-badge {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--card-secondary);
    padding: 3px 8px;
    border-radius: 10px;
  }
  .closed-app-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  }
  .closed-app-row:last-child {
    border-bottom: none;
  }
  .closed-app-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #48484a;
    flex-shrink: 0;
  }
  .closed-app-name {
    font-size: 13px;
    font-weight: 600;
    color: #c7c7cc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .closed-app-meta {
    font-size: 11px;
    color: var(--text-muted);
  }
  .start-btn {
    background: rgba(48, 209, 88, 0.15);
    color: var(--green);
    border: 1px solid rgba(48, 209, 88, 0.35);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 10px;
    transition: opacity 0.2s ease;
  }
  .start-btn:active {
    opacity: 0.7;
  }

  /* Downloads & Updates card */
  .downloads-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
  }
  .downloads-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
  }
  .downloads-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .downloads-badge {
    font-size: 12px;
    background: rgba(10, 132, 255, 0.2);
    color: #0a84ff;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
  }
  .downloads-badge.empty {
    background: var(--card-secondary);
    color: var(--text-muted);
  }
  .download-item {
    background: var(--card-secondary);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
  }
  .download-item:last-child {
    margin-bottom: 0;
  }
  .download-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
  }
  .download-app-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0a84ff;
    background: rgba(10, 132, 255, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 4px;
  }
  .download-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
    line-height: 1.3;
  }
  .download-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .status-downloading {
    background: rgba(48, 209, 88, 0.2);
    color: var(--green);
  }
  .status-paused {
    background: rgba(255, 159, 10, 0.2);
    color: var(--yellow);
  }
  .download-progress-container {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    height: 7px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
  }
  .download-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0a84ff, #5e5ce6);
    border-radius: 4px;
    transition: width 0.3s ease;
  }
  .download-progress-bar.paused {
    background: #ff9f0a;
  }
  .download-progress-bar.completed {
    background: #30d158;
  }
  .download-progress-bar.cancelled {
    background: #636366;
  }
  .download-progress-bar.error {
    background: #ff453a;
  }
  .status-completed {
    background: rgba(48, 209, 88, 0.2);
    color: var(--green);
  }
  .status-cancelled {
    background: rgba(142, 142, 147, 0.2);
    color: var(--text-muted);
  }
  .status-error {
    background: rgba(255, 69, 58, 0.2);
    color: var(--red);
  }
  .dl-btn-dismiss {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11px;
    padding: 6px 10px;
  }
  .downloads-badge.completed {
    background: rgba(48, 209, 88, 0.2);
    color: var(--green);
  }
  .download-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
  }
  .download-speed-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 11.5px;
    font-weight: 600;
  }
  .download-speed-row.paused {
    color: var(--yellow);
    background: rgba(255, 159, 10, 0.08);
    border-color: rgba(255, 159, 10, 0.15);
    justify-content: flex-start;
    gap: 6px;
  }
  .download-speed-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #64d2ff;
  }
  .download-eta-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ffd60a;
  }
  .download-speed-pill .speed-icon,
  .download-eta-pill .eta-icon {
    font-size: 12px;
  }
  .download-timeline-box {
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
  }
  .download-timeline-toggle {
    width: 100%;
    background: transparent;
    border: none;
    padding: 7px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
  }
  .download-timeline-toggle:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
  }
  .timeline-chevron {
    font-size: 9px;
    transition: transform 0.2s ease;
    display: inline-block;
  }
  .timeline-chevron.expanded {
    transform: rotate(180deg);
  }
  .download-timeline-list {
    padding: 8px 12px 10px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
  }
  .timeline-step {
    position: relative;
    padding-left: 18px;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 11px;
  }
  .timeline-step:last-child {
    padding-bottom: 0;
  }
  .timeline-step::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 6px;
    bottom: -6px;
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
  }
  .timeline-step:last-child::before {
    display: none;
  }
  .timeline-dot {
    position: absolute;
    left: 0;
    top: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #0a84ff;
    border: 2px solid var(--card-secondary);
    box-sizing: border-box;
  }
  .timeline-dot.start { background: #0a84ff; }
  .timeline-dot.pause { background: #ff9f0a; }
  .timeline-dot.resume { background: #5e5ce6; }
  .timeline-dot.complete { background: #30d158; }
  .timeline-dot.cancel { background: #8e8e93; }
  .timeline-dot.error { background: #ff453a; }
  .timeline-label {
    color: var(--text);
    font-weight: 500;
  }
  .timeline-time {
    color: var(--text-muted);
    font-size: 10.5px;
    margin-left: 8px;
    white-space: nowrap;
  }
  .download-actions {
    display: flex;
    gap: 8px;
  }
  .dl-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
  }
  .dl-btn:active {
    transform: scale(0.97);
    opacity: 0.7;
  }
  .dl-btn-pause {
    background: rgba(255, 159, 10, 0.18);
    color: #ff9f0a;
    border: 1px solid rgba(255, 159, 10, 0.3);
  }
  .dl-btn-resume {
    background: rgba(48, 209, 88, 0.18);
    color: var(--green);
    border: 1px solid rgba(48, 209, 88, 0.3);
  }
  .dl-btn-cancel {
    background: rgba(255, 69, 58, 0.18);
    color: var(--red);
    border: 1px solid rgba(255, 69, 58, 0.3);
  }
  .download-steam-notice {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 0 2px 0;
  }

  /* Screen capture & Live camera card */
  .screen-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
  }
  .screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
  }
  .screen-title {
    font-size: 16px;
    font-weight: 700;
  }
  .screen-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .screen-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    background: rgba(48, 209, 88, 0.12);
    border: 1px solid rgba(48, 209, 88, 0.25);
    padding: 3px 8px;
    border-radius: 10px;
  }
  .screen-view-container {
    width: 100%;
    min-height: 180px;
    background: #000000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
  .screen-placeholder {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 13px;
  }
  .screen-image {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
  }
  .screen-image.zoomed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.96);
    z-index: 99999;
  }
  .screen-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  .screen-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .screen-controls {
    display: flex;
    gap: 10px;
    margin-top: 14px;
  }
  .screen-btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: opacity 0.2s ease;
  }
  .screen-btn:active { opacity: 0.7; }
  .screen-btn.primary {
    background: var(--card-secondary);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  .screen-btn.live {
    background: rgba(255, 69, 58, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 69, 58, 0.3);
  }
  .screen-btn.live.active {
    background: var(--red);
    color: #ffffff;
    animation: pulse 1.5s infinite;
  }
  .screen-btn.clear {
    flex: 0 0 40px;
    background: var(--card-secondary);
    color: var(--text-muted);
  }
  @keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.75; }
    100% { opacity: 1; }
  }
  .screen-meta {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 10px;
  }

  /* Remote control card */
  .control-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
  }
  .control-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
  }
  .control-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
  }
  .actions-row {
    display: flex;
    gap: 12px;
  }
  .action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.2s ease;
  }
  .action-btn:active {
    transform: scale(0.97);
  }
  .action-btn.wake {
    background: rgba(48, 209, 88, 0.15);
    color: var(--green);
    border: 1px solid rgba(48, 209, 88, 0.4);
  }
  .action-btn.restart {
    background: rgba(255, 159, 10, 0.15);
    color: var(--orange);
    border: 1px solid rgba(255, 159, 10, 0.4);
  }
  .action-btn.shutdown {
    background: rgba(255, 69, 58, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 69, 58, 0.4);
  }

  /* Modal Dialog */
  .modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
  }
  .modal-overlay.active {
    display: flex !important;
  }
  .modal-box {
    background: #1c1c1e;
    border-radius: 20px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75);
    animation: modalPop 0.2s ease-out;
  }
  @keyframes modalPop {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
  }
  .modal-icon {
    font-size: 38px;
    margin-bottom: 10px;
  }
  .modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #fff;
  }
  .modal-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 22px;
  }
  .modal-actions {
    display: flex;
    gap: 12px;
  }
  .modal-btn {
    flex: 1;
    padding: 13px 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
  }
  .modal-btn:active {
    opacity: 0.8;
  }
  .modal-btn.cancel {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }
  .modal-btn.confirm.shutdown {
    background: #ff453a;
    color: #fff;
  }
  .modal-btn.confirm.restart {
    background: #ff9f0a;
    color: #fff;
  }
  .modal-btn.confirm.wake {
    background: #30d158;
    color: #000;
    font-weight: 700;
  }

  /* Toast Notification Banner */
  .toast-banner {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    display: none;
  }
  .toast-banner.success {
    background: #30d158;
    color: #000;
  }
  .toast-banner.error {
    background: #ff453a;
    color: #fff;
  }
  .toast-banner.info {
    background: #0a84ff;
    color: #fff;
  }

/* Device selector & Pairing Modal */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-gear {
  background: var(--card-secondary);
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s ease, transform 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  z-index: 10;
}
.btn-gear:active {
  background: #3a3a3c;
  transform: scale(0.95);
}
.hostname-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 2px;
}
.device-chevron {
  font-size: 10px;
  opacity: 0.8;
}
.modal-box.pairing-box {
  max-width: 420px;
  text-align: left;
  padding: 20px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header .modal-title {
  font-size: 17px;
  font-weight: 700;
}
.modal-close-x {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.pairing-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.pairing-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}
.pairing-desc code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  color: #fff;
}
.pairing-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 16px 0;
}
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}
.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-secondary);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.device-item.active {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.12);
}
.device-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.device-item-name {
  font-size: 14px;
  font-weight: 600;
}
.device-item-badge {
  font-size: 10px;
  color: var(--accent);
  background: rgba(10, 132, 255, 0.2);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}
.device-item-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}
.device-item-del:hover {
  color: var(--red);
}
.pairing-input-wrap {
  display: flex;
  gap: 8px;
}
.pairing-input {
  flex: 1;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 8px 12px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.pairing-input:focus {
  border-color: var(--accent);
}