:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #232732;
  --border: #2c313c;
  --text: #e7ebf0;
  --muted: #8b94a3;
  --primary: #3b82f6;
  --primary-press: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --gray: #5b6472;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

/* ---- 登入 ---- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 24px;
  text-align: center;
}
.login-card .logo { font-size: 44px; color: var(--primary); }
.login-card h1 { font-size: 20px; margin: 8px 0 24px; }
.login-card input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
}
.login-card input:focus { outline: none; border-color: var(--primary); }

/* ---- 主畫面 ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  background: rgba(15,17,21,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface); }

.machine-list {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px;
  max-width: 560px; margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 16px 14px;
}
.card-head { display: flex; align-items: center; gap: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--gray); }
.dot.running { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,.6); }
.dot.stopped { background: var(--gray); }
.dot.unknown { background: var(--amber); }
.card-title { flex: 1; min-width: 0; }
.card-title .name { font-size: 16px; font-weight: 600; }
.card-title .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.status-text { font-size: 12px; color: var(--muted); }

.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}

.card-actions {
  display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap;
}
.btn {
  flex: 1; min-width: 80px;
  padding: 12px 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:active { background: var(--primary-press); }
.btn-on { background: var(--green); border-color: var(--green); color: #06210f; }
.btn-off { background: transparent; color: var(--red); border-color: var(--red); }
.btn-connect { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }

.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.updated { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 24px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 12px 18px; border-radius: 12px;
  font-size: 14px; z-index: 50; max-width: 90%;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
