:root {
  --bg: #07111f;
  --panel-border: rgba(148, 163, 184, 0.14);
  --text: #e5eefb;
  --muted: #93a4bf;
  --muted-2: #6f839f;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html {
  width: 100%;
  color-scheme: dark;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y pinch-zoom;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(34, 211, 238, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(124, 58, 237, 0.20), transparent 30%),
    linear-gradient(180deg, #08111f 0%, #0b1220 45%, #07111b 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.35), rgba(0,0,0,0));
}

.app-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 32px 20px 56px;
  overflow-x: clip;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin-bottom: 18px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -80px -80px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.12), transparent 70%);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255,255,255,0.03);
  color: #c7d5e8;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 14px 0 8px;
  font-size: clamp(1.7rem, 2.5vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.hero h1:empty {
  display: none;
}

.laundry-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 9px;
  box-shadow: 0 8px 22px rgba(34, 211, 238, 0.18);
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: start;
}

@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.stack { display: grid; gap: 18px; }

.card {
  position: relative;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.title-wrap h2 {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.card-title-icon-wrap {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(103, 232, 249, 0.34);
  border-radius: 11px;
  background: rgba(34, 211, 238, 0.14);
  box-shadow: 0 8px 20px rgba(34, 211, 238, 0.13);
}

.card-title-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  filter: invert(84%) sepia(32%) saturate(813%) hue-rotate(151deg) brightness(105%) contrast(103%);
}

.surface {
  border: 1px solid rgba(148, 163, 184, 0.1);
  background: rgba(2, 6, 23, 0.22);
  border-radius: 16px;
  padding: 14px;
}

.machine-map { display: grid; gap: 12px; }

.field-label { color: #d6e2f3; font-size: 0.92rem; font-weight: 600; }
.field-subtext { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

.in-use-notice {
  margin-top: 12px;
  color: #fbbf24;
  font-size: 0.9rem;
  line-height: 1.45;
}

.in-use-notice.hidden {
  display: none;
}

.usage-notice {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: 12px;
  color: #cdeefa;
  background: rgba(34, 211, 238, 0.06);
  font-size: 0.84rem;
  line-height: 1.45;
}

.usage-notice.limit {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.08);
}

.referral-panel {
  margin-top: 10px;
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 14px;
  background: rgba(34, 197, 94, 0.07);
  overflow: hidden;
}

.referral-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  color: #dcfce7;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.referral-panel summary::-webkit-details-marker { display: none; }

.referral-panel summary::after {
  content: "+";
  color: #bbf7d0;
  font-size: 1rem;
  line-height: 1;
}

.referral-panel[open] summary::after { content: "-"; }

.referral-panel summary:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.referral-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.referral-copy {
  display: grid;
  gap: 3px;
  color: #dcfce7;
  font-size: 0.84rem;
  line-height: 1.45;
}

.referral-copy strong {
  color: #f0fdf4;
  font-size: 0.9rem;
}

.referral-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.referral-code-row code {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(187, 247, 208, 0.18);
  border-radius: 11px;
  background: rgba(2, 6, 23, 0.3);
  color: #bbf7d0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.referral-mini-btn {
  min-height: 38px;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 0.82rem;
}

.referral-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.referral-message {
  color: #a7f3d0;
  font-size: 0.8rem;
  line-height: 1.35;
}

select, input[type="password"], input[type="text"] {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(180deg, rgba(18, 27, 45, 0.95), rgba(9, 14, 25, 0.95));
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.98rem;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

select:focus, input[type="password"]:focus, input[type="text"]:focus {
  border-color: rgba(34, 211, 238, 0.44);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.12);
}

select:disabled, input:disabled, button:disabled { opacity: 0.56; cursor: not-allowed; }

.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

.connection-status { margin-top: 14px; }

button {
  appearance: none;
  position: relative;
  overflow: hidden;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  background: linear-gradient(180deg, rgba(26, 36, 58, 0.94), rgba(14, 21, 36, 0.96));
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 120ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    opacity 160ms ease,
    filter 140ms ease;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 10px 24px rgba(0,0,0,0.16);
}

button::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0));
  opacity: 0.8;
}

button::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.18), transparent 55%);
  transition: opacity 160ms ease;
}

@media (hover: hover) {
  button:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.06),
      0 14px 28px rgba(0,0,0,0.2);
  }
}

button:active:not(:disabled) {
  transform: scale(0.985);
  filter: brightness(1.04);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 6px 14px rgba(0,0,0,0.18);
}

button:active:not(:disabled)::after { opacity: 1; }

button.is-pressed {
  transform: scale(0.985);
  filter: brightness(1.04);
}
button.is-pressed::after { opacity: 1; }

.btn-primary {
  color: #f3f7ff;
  border-color: rgba(148, 163, 184, 0.18);
  background: linear-gradient(180deg, rgba(67, 86, 122, 0.88), rgba(39, 52, 78, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 12px 28px rgba(10, 16, 28, 0.28);
}

.btn-secondary {
  color: #dde7f7;
  border-color: rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(24, 33, 52, 0.94), rgba(13, 20, 33, 0.98));
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255,255,255,0.03);
  color: #dbe7f7;
  font-size: 0.9rem;
  line-height: 1.3;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.03);
  flex: 0 0 auto;
}

.status-pill.ok .status-dot { background: var(--ok); }
.status-pill.warn .status-dot { background: var(--warn); }
.status-pill.bad .status-dot { background: var(--bad); }

.machine-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.machine-actions button {
  min-height: 56px;
  justify-content: center;
  text-align: center;
}

.log-card { min-height: unset; padding: 14px; }

#log.activity-strip {
  min-height: unset;
  height: 56px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,0.12);
  background: linear-gradient(180deg, rgba(8,15,28,0.92), rgba(6,11,20,0.96));
  display: flex;
  align-items: center;
  gap: 12px;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(148,163,184,0.65);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.03);
  flex: 0 0 auto;
}

.activity-text {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

#log.activity-strip.ok .activity-dot { background: var(--ok); }
#log.activity-strip.warn .activity-dot { background: var(--warn); }
#log.activity-strip.bad .activity-dot { background: var(--bad); }

#appRoot.locked {
  filter: blur(4px) saturate(0.9);
  pointer-events: none;
  user-select: none;
}

#pinOverlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#pinOverlay.hidden { display: none; }

.pin-card {
  width: min(92vw, 420px);
  padding: 22px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(17, 24, 39, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

.pin-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.pin-sub { margin: 0 0 16px; color: var(--muted); line-height: 1.55; font-size: 0.95rem; }

.pin-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.86rem;
}

.pin-links a,
.hero-home {
  color: #a5f3fc;
  text-decoration: none;
  font-weight: 650;
}

.pin-links a:hover,
.hero-home:hover { text-decoration: underline; }

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-logout {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: #dbeafe;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
  font-size: 0.84rem;
  font-weight: 700;
}

.hero-logout:hover { background: rgba(255, 255, 255, 0.085); }

.bluefy-note {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 14px;
  background: rgba(34, 211, 238, 0.08);
}

.bluefy-note strong {
  display: block;
  margin-bottom: 3px;
  color: #e6eefb;
  font-size: 0.9rem;
}

.bluefy-note p {
  margin: 0;
  color: #a9bdd5;
  font-size: 0.82rem;
  line-height: 1.45;
}

.bluefy-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 11px;
  color: #04111b;
  background: #22d3ee;
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.bluefy-link:hover { background: #67e8f9; text-decoration: none; }

.app-bluefy-note { margin: 0 0 18px; }

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.pin-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }

#pinError { margin-top: 10px; min-height: 1.3em; color: var(--bad); font-size: 0.92rem; }

.hidden { display: none !important; }

.support-note {
  margin: 20px 2px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
  text-align: center;
}
.support-note a { color: #cdeefa; font-weight: 750; text-decoration: none; }
.support-note a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .app-shell { padding: 20px 14px 40px; }
  .hero, .card, .pin-card { padding: 18px; }
  .pin-row { grid-template-columns: 1fr; }
  .status-pill { width: 100%; border-radius: 16px; }
  .button-row { flex-direction: column; }
  .button-row > button { width: 100%; }
  #log.activity-strip { height: 54px; }
  .bluefy-note { grid-template-columns: 1fr; }
  .bluefy-link { width: 100%; }
}
