[hidden] { display: none !important; }

.fleet-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
.fleet-kpi { display: grid; align-content: center; gap: 7px; min-width: 0; padding: 18px 20px;
  border: 1px solid var(--border); border-top: 3px solid var(--purple); border-radius: 12px; background: var(--surface); }
.fleet-kpi.vm { border-top-color: var(--green); }
.fleet-kpi.vm.needs-attention { border-top-color: var(--red); }
.fleet-kpi.hashrate { border-top-color: var(--purple); background: var(--panel); }
.fleet-kpi-label { color: var(--muted); font-size: .72rem; font-weight: 850; letter-spacing: .13em; }
.fleet-kpi-value { font-size: clamp(1.75rem, 4vw, 2.55rem); line-height: 1.08; font-weight: 850;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fleet-kpi.vm .fleet-kpi-value { color: var(--green); }
.fleet-kpi.vm.needs-attention .fleet-kpi-value { color: var(--red); }
.fleet-kpi.hashrate .fleet-kpi-value { color: var(--purple); }
.fleet-kpi-detail { color: var(--muted); font-size: .79rem; }
.fleet-kpi.accounts.needs-attention { border-top-color: var(--red); }
.fleet-kpi.accounts.needs-attention .fleet-kpi-detail { color: var(--red); font-weight: 800; }
@media(max-width:600px) { .fleet-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .fleet-kpi { padding: 14px; } .fleet-kpi.hashrate { grid-column: 1 / -1; }
  .fleet-kpi.hashrate .fleet-kpi-value { font-size: clamp(2rem, 8vw, 2.65rem); }
}

.account.signal-silent { border: 3px solid var(--red); box-shadow: 0 0 0 1px var(--red);
  animation: account-signal-pulse 1.7s ease-in-out infinite; }
@keyframes account-signal-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--red); }
  50% { box-shadow: 0 0 0 4px var(--red), 0 0 22px 2px var(--red); }
}
.account-signal-tag { display: block; width: fit-content; margin-top: 7px; padding: 4px 8px;
  border-radius: 5px; background: var(--red); color: #211117; font-size: .72rem; font-weight: 900; letter-spacing: .03em; }
.account-signal-detail { padding: 10px 18px; border-top: 1px solid var(--red);
  background: var(--panel); color: var(--red); font-size: .87rem; font-weight: 750; line-height: 1.5; }
.account-recovery-tag { display: block; margin-top: 7px; color: var(--yellow);
  font-size: .73rem; font-weight: 850; line-height: 1.4; }
.inline-progress { display: block; color: var(--yellow); font-size: .72rem; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.account-head > .account-progress { grid-column: 1 / -1; padding: 0 3px 3px; }
.worker > .worker-progress {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 2px 3px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The luminous rim belongs to the entire account, not individual VM rows.
   Steady phase-offsets from JS keep the orbit continuous across 5s UI refreshes. */
@property --rim-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes account-rim-orbit { to { --rim-angle: 360deg; } }
@keyframes account-neon-breathe {
  0%, 100% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--rim-color) 64%, transparent),
    0 0 17px color-mix(in srgb, var(--rim-color) 30%, transparent); }
  50% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--rim-color) 82%, transparent),
    0 0 33px color-mix(in srgb, var(--rim-color) 48%, transparent),
    inset 0 0 17px color-mix(in srgb, var(--rim-color) 8%, transparent); }
}
@keyframes account-working-glow {
  0%, 100% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--rim-color) 75%, transparent),
    0 0 18px color-mix(in srgb, var(--rim-color) 35%, transparent); }
  50% { box-shadow: 0 0 0 2px var(--rim-color),
    0 0 39px color-mix(in srgb, var(--rim-color) 62%, transparent),
    inset 0 0 24px color-mix(in srgb, var(--rim-color) 11%, transparent); }
}
.account {
  position: relative;
  --account-accent: var(--purple);
  transition: border-color .25s ease, box-shadow .3s ease, background-color .3s ease;
}
.account .account-head { position: relative; padding-top: 38px; }
.account::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 3px;
  border-radius: inherit;
  pointer-events: none;
  background: conic-gradient(from var(--rim-angle),
    transparent 0deg 125deg,
    color-mix(in srgb, var(--rim-color) 30%, transparent) 150deg,
    var(--rim-color) 185deg,
    white 201deg,
    var(--rim-color) 216deg,
    transparent 246deg 281deg,
    color-mix(in srgb, var(--rim-color) 65%, transparent) 305deg,
    var(--rim-color) 316deg,
    transparent 339deg,
    transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  filter: drop-shadow(0 0 6px var(--rim-color)) drop-shadow(0 0 12px var(--rim-color));
  animation: account-rim-orbit var(--rim-duration, 12s) linear infinite;
  animation-delay: var(--rim-delay, 0s);
}
.account--healthy {
  --account-accent: var(--green);
  --rim-color: #c2ff4d;
  --rim-duration: 4.8s;
  border-color: var(--green);
  animation: account-neon-breathe 4.8s ease-in-out infinite;
  animation-delay: var(--rim-delay, 0s);
}
.account--active {
  --account-accent: var(--yellow);
  --rim-color: #ffe873;
  --rim-duration: 2.4s;
  border-color: var(--yellow);
  animation: account-working-glow 2.4s ease-in-out infinite;
  animation-delay: var(--rim-delay, 0s);
}
html[data-theme="gruvbox"] .account--healthy { --rim-color: #deff63; }
html[data-theme="gruvbox"] .account--active { --rim-color: #ffdd59; }
.account--issue { --account-accent: var(--red); border: 2px solid var(--red);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 38%, transparent),
    0 0 18px color-mix(in srgb, var(--red) 17%, transparent); }
.account--hold { --account-accent: var(--purple); border-color: var(--muted); }
.account--waiting { --account-accent: var(--yellow); border-color: var(--border); }
.account--hold::before, .account--waiting::before, .account--issue::before { content: none; }
.account.signal-silent.account--issue { animation: none; border: 2px solid var(--red);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 38%, transparent),
    0 0 18px color-mix(in srgb, var(--red) 17%, transparent); }

/* Expanded cards have a clear beginning, contained VM area and quiet end cap. */
.account.is-expanded { border-width: 2px; margin-block: 5px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--account-accent) 52%, transparent),
    0 0 30px color-mix(in srgb, var(--account-accent) 19%, transparent); }
.account.is-expanded .account-head {
  background: var(--panel);
  background: linear-gradient(105deg,
    color-mix(in srgb, var(--account-accent) 13%, var(--surface)),
    color-mix(in srgb, var(--account-accent) 4%, var(--surface)) 58%, var(--surface));
}
.account-expanded-label { display: block; width: fit-content; margin-top: 6px;
  color: var(--account-accent); font-size: .65rem; font-weight: 850;
  letter-spacing: .13em; line-height: 1.25; }
.account.is-expanded .workers {
  position: relative;
  padding: 11px 17px 19px 27px;
  border-top: 1px solid color-mix(in srgb, var(--account-accent) 43%, var(--border));
  background: var(--surface);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--account-accent) 6%, var(--surface)), var(--surface) 62%);
}
.account.is-expanded .workers::before {
  content: ""; position: absolute; top: 15px; bottom: 19px; left: 13px;
  width: 2px; border-radius: 3px; pointer-events: none;
  background: linear-gradient(180deg, var(--account-accent),
    color-mix(in srgb, var(--account-accent) 45%, var(--border)) 72%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--account-accent) 42%, transparent);
}
.account.is-expanded .worker:hover { background: color-mix(in srgb, var(--account-accent) 5%, transparent); }
.account-endcap { margin-top: 9px; padding: 12px 7px 0; text-align: right;
  border-top: 1px solid color-mix(in srgb, var(--account-accent) 32%, var(--border));
  color: color-mix(in srgb, var(--account-accent) 68%, var(--muted));
  font-size: .66rem; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; }
.account-state-badge {
  position: absolute;
  z-index: 3;
  top: 7px;
  right: 13px;
  max-width: calc(100% - 26px);
  padding: 3px 8px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: var(--surface);
  background: color-mix(in srgb, var(--account-accent) 10%, var(--surface));
  box-shadow: 0 0 11px color-mix(in srgb, var(--account-accent) 13%, transparent);
  font-size: .73rem;
  font-weight: 850;
  letter-spacing: .035em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.account--healthy .account-state-badge { color: var(--green); }
.account--active .account-state-badge { color: var(--yellow); }
.account--hold .account-state-badge { color: var(--muted); box-shadow: none; }
.account--issue .account-state-badge { color: var(--red); }
.account--waiting .account-state-badge { color: var(--yellow); box-shadow: none; }
@media (max-width: 560px) {
  .account.is-expanded .workers { padding: 9px 9px 14px 18px; }
  .account.is-expanded .workers::before { left: 7px; }
  .account.is-expanded .worker { grid-template-columns: minmax(0, 1.05fr) minmax(0, .85fr) minmax(0, .95fr); }
  .account.is-expanded .worker > .worker-hash { display: block; min-width: 0; }
  .account.is-expanded .worker > .worker-hash small { font-size: .59rem; letter-spacing: .02em; }
  .account.is-expanded .worker > .worker-hash strong { display: block; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; font-size: clamp(.79rem, 2.5vw, .95rem); }
  .account-endcap { font-size: .61rem; }
}
@media (max-width: 380px) {
  .account.is-expanded .worker { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .account.is-expanded .worker > .worker-hash { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .account, .account::before { animation: none !important; transition: none; }
  .account::before { background: none; }
  .account--healthy { border-color: var(--green); }
}
@media (prefers-reduced-motion: reduce) { .account.signal-silent { animation: none; box-shadow: 0 0 0 2px var(--red); } }

.pool-due {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: .93rem;
  line-height: 1.5;
}
.pool-due strong { color: var(--purple); font-variant-numeric: tabular-nums; }
.pool-due small { color: var(--muted); display: block; }
.pool-due .pool-error { color: var(--yellow); }
.payout-list { display: grid; gap: 14px; }
.payout-card { max-width: none; }
.payout-card h2 { margin-top: 0; }
.payout-card .subtitle { margin: 8px 0; }
.payout-history { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; overflow-wrap: anywhere; }
.payout-history h3 { margin: 0; font-size: .92rem; }
.payout-card .pool-error, #payout-result { color: var(--yellow); }
.payout-eligible { color: var(--green); font-weight: 700; }
.payout-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.payout-form label { min-width: min(100%, 230px); flex: 1; }
.payout-form button { min-height: 44px; }
.account-actions .add-vm { background: var(--green); border-color: var(--green); color: #1d2411; }
.account-actions .remove-vm { border-color: var(--red); color: var(--red); }
.account-actions .key-button { border-color: var(--yellow); color: var(--yellow); }
.account-actions .balance-button { border-color: var(--purple); color: var(--purple); }
#key-editor form { display: grid; gap: 14px; min-width: min(90vw, 340px); }
#key-editor h2 { margin: 0; }
.worker-actions .state-toggle {
  min-height: 44px;
  padding: .45rem .7rem;
  font-weight: 850;
  letter-spacing: .025em;
  white-space: nowrap;
}
.worker-actions .state-toggle.is-on:not(:disabled) {
  background: var(--green);
  border-color: var(--green);
  color: #1d2411;
}
.worker-actions .state-toggle.is-off:not(:disabled) {
  background: var(--red);
  border-color: var(--red);
  color: #211117;
}
.worker-actions .state-toggle:disabled {
  opacity: 1;
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}
.worker-actions .state-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.usd-visibility { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; margin-left: 8px; padding: 8px; min-width: 44px; min-height: 44px; background: transparent; color: var(--purple); }
.usd-visibility svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.usd-visibility .usd-slash { stroke-width: 2.5; }
.credit-time { align-self: center; font-size: .81rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.credit-time.negative { color: var(--red); font-weight: 800; }
.goal-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; max-width: none; }
.goal-form label { min-width: 130px; flex: 1; }
.goal-form button { align-self: end; }
.goal-form #goal-form-status { flex-basis: 100%; margin: 0; }
.pool-settings { max-width: none; margin: 20px 0; display: grid; gap: 12px; }
.pool-settings form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.pool-settings form label { flex: 1; min-width: min(100%, 260px); }
.pool-settings button { justify-self: start; }
.pool-settings #pool-result { color: var(--yellow); margin: 0; }
.pool-key-list { display: grid; gap: 7px; max-height: 340px; overflow-y: auto; }
.pool-key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); font-size: .86rem; }
.pool-key-row .pool-key-mask { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums; color: var(--purple); }
.pool-key-row.unused { border-color: var(--green); }
.pool-key-row.unused span { color: var(--green); font-weight: 800; }
.pool-key-row.active span { color: var(--yellow); }
.pool-key-row.spent span, .pool-key-row.archived span, .pool-key-row.retiring span { color: var(--muted); }
.goal-mode { padding: 12px 16px; color: var(--yellow); background: var(--surface); border-left: 3px solid var(--yellow); }
.goal-auto-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.goal-auto-bar .goal-mode { flex: 1; }
.auto-marker { font-size: .75rem; color: var(--green); font-weight: 700; }
.auto-marker.needs-keys { color: var(--red); }
.goal-short strong { color: var(--red); }
.goal-schedule { display: grid; gap: 5px; margin-top: 14px; }
.goal-hour { display: grid; grid-template-columns: 100px minmax(0,1fr); gap: 10px; padding: 10px 14px; background: var(--surface); border-radius: 6px; }
.goal-hour strong { font-variant-numeric: tabular-nums; color: var(--purple); }
@media(max-width:560px) { .goal-hour { grid-template-columns: 1fr; gap: 2px; } .goal-form label { flex-basis: 100%; } }

.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.chart-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 14px; }
.chart-toolbar label { min-width: min(100%, 300px); }
.chart-ranges { display: flex; gap: 5px; padding: 4px; background: var(--panel); border-radius: 10px; }
.chart-ranges button { min-height: 38px; border: 0; background: transparent; color: var(--muted); padding: .45rem .75rem; }
.chart-ranges button.active { background: var(--purple); color: var(--bg); }
.chart-summary { font-size: 1.15rem; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--text); padding: 21px 0 5px; }
.chart-summary strong { color: var(--purple); }
.chart-summary .chart-up { color: var(--green); }
.chart-summary .chart-down { color: var(--red); }
#hash-chart { display: block; width: 100%; height: auto; min-height: 205px; color: var(--muted); overflow: visible; }
.chart-point { min-height: 30px; color: var(--purple); font-variant-numeric: tabular-nums; font-size: .88rem; }
.chart-card .subtitle { margin-top: 8px; }
.alert-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.alert-grid .settings-card { margin: 0; max-width: none; display: grid; gap: 12px; align-content: start; }
.alert-grid .settings-card h2 { margin: 0; }
.alert-list { display: grid; gap: 10px; }
.alert-item { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--red); border-radius: 9px; }
.alert-item.recovered { border-left-color: var(--green); }
.alert-item small { display: block; color: var(--muted); margin-top: 6px; }
@media (max-width: 680px) { .alert-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) {
  .chart-card { padding: 13px 10px; }
  .chart-toolbar label { width: 100%; }
  .chart-ranges { width: 100%; }
  .chart-ranges button { flex: 1; }
  #hash-chart { min-height: 160px; }
}

/* The credit badge must remain visible at every viewport size. app.css
   previously hid the fourth metric (the balance) below 800px. */
@media (max-width: 800px) {
  .account-head { grid-template-columns: minmax(0, 1.2fr) minmax(0, .65fr) minmax(0, 1fr) minmax(0, 1.15fr); }
  .account-head > .metric:nth-of-type(4) { display: block; min-width: 0; }
  .account-head .credit { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 560px) {
  .account-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-head > .account-name { grid-column: 1; grid-row: 1; }
  .account-head > .metric:nth-of-type(4) { grid-column: 2; grid-row: 1; }
  .account-head > .metric:nth-of-type(2) { grid-column: 1; grid-row: 2; }
  .account-head > .metric:nth-of-type(3) { display: block; grid-column: 2; grid-row: 2; }
  .account-head > .account-actions { grid-column: 1 / -1; }
}
