* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 12px/1.35 Tahoma, Verdana, "Segoe UI", sans-serif;
  color: #000;
  background: #3a6ea5 url("img/bliss.jpg") center / cover no-repeat fixed;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

#desktop { position: fixed; inset: 0 0 40px 0; }

/* ---------- desktop icon ---------- */
.desk-icon {
  position: absolute; top: 14px; left: 12px; width: 84px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 1px dotted transparent; padding: 4px 2px;
}
.desk-icon img { width: 48px; height: 48px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.desk-icon span {
  color: #fff; text-shadow: 1px 1px 1px #000, 0 0 2px #000; font-size: 11px; text-align: center; padding: 1px 3px;
}
.desk-icon:focus-visible, .desk-icon.sel { border-color: #fff; }
.desk-icon.sel span { background: #316ac5; text-shadow: none; }
.desk-icon.sel img { filter: sepia(1) hue-rotate(180deg) saturate(3) brightness(.8); }

/* ---------- window ---------- */
.window {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 75vw; min-width: min(340px, 94vw); max-width: 1100px;
  height: 75vh; min-height: 320px; max-height: calc(100% - 16px);
  display: flex; flex-direction: column;
  background: #ece9d8;
  border: 3px solid #0831d9; border-top: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 2px 4px 18px rgba(0,0,0,.55);
}
.window.hidden { display: none; }
.window.maxed { left: 0; top: 0; transform: none; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }

.titlebar {
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 3px 0 6px; flex: none;
  border-radius: 7px 7px 0 0; margin: 0 -3px;
  background: linear-gradient(180deg, #0997ff 0%, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7 96%, #003dd7 100%);
  border-top: 1px solid #3c8cf8;
  user-select: none;
}
.t-icon { width: 16px; height: 16px; border-radius: 2px; }
.titlebar h1 {
  flex: 1; margin: 0; font: bold 13px "Trebuchet MS", Tahoma, sans-serif; color: #fff;
  text-shadow: 1px 1px #0f1089; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.t-btns { display: flex; gap: 2px; }
.t-btn {
  position: relative; width: 22px; height: 22px; padding: 0;
  border: 1px solid #fff; border-radius: 3px;
  background: radial-gradient(circle at 90% 90%, #0054e9 0%, #2263d5 55%, #4479e4 70%, #a3bbec 90%, #fff 100%);
  box-shadow: inset 0 -1px 2px rgba(0,0,0,.25);
}
.t-btn:hover { filter: brightness(1.15); }
.t-btn:active { filter: brightness(.85); }
.t-btn.close { background: radial-gradient(circle at 90% 90%, #cc4600 0%, #dc6527 55%, #cd7546 70%, #ffccb2 90%, #fff 100%); }
.t-btn i { position: absolute; inset: 0; }
.t-btn.min i::before { content: ""; position: absolute; left: 5px; bottom: 5px; width: 8px; height: 3px; background: #fff; }
.t-btn.max i::before { content: ""; position: absolute; left: 4px; top: 4px; width: 12px; height: 12px; border: 1px solid #fff; border-top-width: 3px; }
.t-btn.close i::before, .t-btn.close i::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2.5px; background: #fff; border-radius: 1px;
}
.t-btn.close i::before { transform: translate(-50%, -50%) rotate(45deg); }
.t-btn.close i::after  { transform: translate(-50%, -50%) rotate(-45deg); }

.menubar { display: flex; gap: 2px; padding: 2px 4px; border-bottom: 1px solid #d6d2c2; flex: none; }
.menubar span { padding: 1px 6px; color: #000; }
.menubar span:hover { background: #316ac5; color: #fff; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px; border-bottom: 1px solid #fff; box-shadow: 0 1px #d6d2c2; flex: none;
}
.ranges { display: flex; gap: 4px; }
.ranges button {
  min-width: 46px; height: 23px; padding: 0 10px;
  border: 1px solid #003c74; border-radius: 3px;
  background: linear-gradient(180deg, #fff 0%, #ecebe6 86%, #d6d0c5 100%);
  box-shadow: inset -1px -1px #d6d0c5;
}
.ranges button:hover { box-shadow: inset 0 0 0 2px #f8b636, inset -1px -1px #e5a01a; }
.ranges button[aria-selected="true"] {
  background: linear-gradient(180deg, #cdcac3 0%, #e3e3db 10%, #e5e4de 90%, #f2f1ec 100%);
  box-shadow: inset 0 0 0 2px #7da2ce; font-weight: bold;
}
.overall { display: flex; align-items: center; gap: 6px; font-weight: bold; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #999; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.dot.up { background: radial-gradient(circle at 35% 35%, #b6f5a8, #2f9e1f 60%, #1d6d12); }
.dot.down { background: radial-gradient(circle at 35% 35%, #ffb3a8, #d4290f 60%, #8f1a07); }

.body {
  flex: 1; overflow: auto; padding: 10px;
  background: #fff; margin: 6px; border: 1px solid #7f9db9;
  display: grid; gap: 10px; align-content: start;
}

/* ---------- service rows ---------- */
.svc { border: 1px solid #d0d0bf; border-radius: 4px; padding: 8px 10px 6px; background: linear-gradient(180deg, #fcfcfe, #f4f3ee); }
.svc-head { display: flex; align-items: center; gap: 10px; }
.logo { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: #eee; }
.svc-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.svc-name a { font-weight: bold; font-size: 13px; color: #0033cc; text-decoration: none; }
.svc-name a:hover { text-decoration: underline; }
.meta { color: #555; font-size: 11px; }
.badge {
  display: flex; align-items: center; gap: 5px; padding: 3px 8px 3px 4px; border-radius: 12px; font-weight: bold; white-space: nowrap;
  border: 1px solid #aaa; background: #f0f0f0;
}
.badge::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: #999 center / 10px no-repeat;
}
.badge.up { color: #1b6e12; border-color: #7cc36d; background: #eefbe9; }
.badge.up::before {
  background-color: #2f9e1f;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5.2 4 7.6 8.6 2.6' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.badge.down { color: #a31b06; border-color: #e3897a; background: #fdeeea; }
.badge.down::before {
  background-color: #d4290f;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5' stroke='white' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
.badge.pending { color: #8a5a00; border-color: #e6c068; background: #fff8e1; }
.badge.pending::before { background-color: #f0a30a; }

.bars {
  display: flex; gap: 2px; height: 30px; margin-top: 8px; padding: 2px;
  border: 1px solid #7f9db9; background: #fff;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,.15);
}
.bar { flex: 1 1 0; min-width: 1px; border-radius: 1px; background: #dcdcdc; border: 0; padding: 0; }
.bar.up { background: linear-gradient(180deg, #7ad96a, #2f9e1f); }
.bar.down { background: linear-gradient(180deg, #ff7a64, #c8230b); }
.bar.part { background: linear-gradient(180deg, #ff7a64 0%, #c8230b 45%, #2f9e1f 55%, #7ad96a 100%); }
.bar:hover, .bar.sel { outline: 2px solid #316ac5; outline-offset: 0; }
.axis { display: flex; justify-content: space-between; color: #555; font-size: 10px; margin-top: 3px; }
.axis .pct { font-weight: bold; color: #222; }

.statusbar {
  display: flex; justify-content: space-between; gap: 8px; flex: none;
  padding: 3px 6px; border-top: 1px solid #fff; box-shadow: 0 -1px #d6d2c2; color: #333; font-size: 11px;
}
.statusbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar span + span { border-left: 1px solid #d6d2c2; padding-left: 8px; flex: none; }

.empty { padding: 30px; text-align: center; color: #555; }

/* ---------- taskbar ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 40px; padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: stretch;
  background: linear-gradient(180deg, #1f2f86 0%, #3165c4 3%, #3682e5 6%, #4490e6 10%, #3883e5 12%, #2b71e0 15%, #2663da 18%, #235bd6 20%, #2258d5 23%, #2157d6 38%, #245ddb 54%, #2562df 86%, #245fdc 89%, #2158d4 92%, #1d4ec0 95%, #1941a5 98%);
  z-index: 10;
}
.start {
  display: flex; align-items: center; gap: 6px; padding: 0 22px 0 10px; margin-right: 10px;
  border: 0; border-radius: 0 12px 12px 0;
  background: radial-gradient(circle at 10% 110%, #388e1a 0%, transparent 60%), linear-gradient(180deg, #3c9f3c 0%, #48b048 8%, #3da53d 30%, #33a433 60%, #2e8d2e 90%, #276c27 100%);
  box-shadow: inset -2px 0 4px rgba(0,0,0,.25), 2px 0 3px rgba(0,0,0,.3);
  color: #fff; font: italic bold 19px "Trebuchet MS", Tahoma, sans-serif; text-shadow: 1px 1px 2px #1a4a1a;
}
.start img { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255,255,255,.8); }
.start:hover { filter: brightness(1.1); }
.start:active { filter: brightness(.9); }
.tasks { flex: 1; display: flex; align-items: center; min-width: 0; padding: 0 4px; }
.task {
  display: flex; align-items: center; gap: 6px; height: 30px; max-width: 180px; padding: 0 10px;
  color: #fff; border: 1px solid #1c4ab5; border-radius: 3px;
  background: linear-gradient(180deg, #3c81f3, #3373e6 50%, #2f69dc);
  box-shadow: inset 1px 1px rgba(255,255,255,.3);
}
.task img { width: 16px; height: 16px; border-radius: 2px; }
.task span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.active { background: linear-gradient(180deg, #1e52b7, #1948a5); box-shadow: inset 1px 1px 2px rgba(0,0,0,.5); }
.task.hidden { display: none; }
.tray {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  color: #fff; font-size: 12px;
  background: linear-gradient(180deg, #0c59b9 1%, #139ee9 6%, #18b5f2 10%, #139beb 14%, #1290e8 19%, #0d8dea 63%, #0d9ff1 81%, #0f9eed 88%, #119be9 91%, #1392e2 94%, #137ed7 97%, #095bc9 100%);
  border-left: 1px solid #092e8a; box-shadow: inset 1px 0 1px #18bbff;
}
.tray-dot { width: 10px; height: 10px; border-radius: 50%; background: #aaa; box-shadow: 0 0 0 1px rgba(255,255,255,.6); }
.tray-dot.up { background: #3fc22a; }
.tray-dot.down { background: #e2321a; }

@media (max-width: 600px) {
  .window { height: 75vh; }
  .menubar { display: none; }
  .task span { display: none; }
  .start { font-size: 17px; padding-right: 16px; }
  .bars { gap: 1px; height: 28px; }
  .body { padding: 8px; margin: 4px; }
  .svc { padding: 7px 8px 5px; }
}
@media (prefers-reduced-motion: no-preference) {
  .window:not(.hidden) { animation: pop .12s ease-out; }
  @keyframes pop { from { opacity: .3; } to { opacity: 1; } }
}
