:root {
  --bg0: #07111f;
  --bg1: #0b1a2e;
  --panel: #10233a;
  --line: rgba(56, 220, 210, 0.28);
  --teal: #2fe0d4;
  --teal2: #1aabb8;
  --text: #eef7ff;
  --muted: #8fa6bf;
  --danger: #ff6b7a;
  --radius: 18px;
  --font: "Segoe UI", "Manrope", "Trebuchet MS", sans-serif;
  --titlebar: #081526;
  --scroll: rgba(47, 224, 212, 0.45);
  --scroll-hover: rgba(47, 224, 212, 0.75);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: radial-gradient(1200px 700px at 70% -10%, #143552 0%, transparent 55%),
              linear-gradient(160deg, #06101c, #0a1c31 45%, #071520);
}

.titlebar {
  height: 36px;
  flex: 0 0 36px;
  display: flex;
  align-items: stretch;
  background: var(--titlebar);
  border-bottom: 1px solid rgba(47, 224, 212, 0.18);
  user-select: none;
}
.titlebar-drag {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  cursor: default;
}
.titlebar-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  pointer-events: none;
}
.titlebar-title {
  color: rgba(238, 247, 255, 0.82);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.titlebar-controls {
  display: flex;
}
.win-btn {
  width: 46px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.win-btn:hover { background: rgba(47, 224, 212, 0.14); }
.win-close:hover { background: #c42b2b; color: #fff; }

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  flex: 1;
}

.sidebar {
  background: linear-gradient(180deg, #081526, #0a1626);
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.nav { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  position: relative;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active {
  color: var(--text);
  background: rgba(47, 224, 212, 0.08);
}
.ico {
  width: 18px;
  height: 18px;
  opacity: 0.9;
  display: inline-block;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}
.ico-cal {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
}
.ico-user {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c1.5-4 4.5-6 8-6s6.5 2 8 6'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c1.5-4 4.5-6 8-6s6.5 2 8 6'/%3E%3C/svg%3E");
}
.ico-gear {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M2 12h3M19 12h3M4.9 19.1L7 17M17 7l2.1-2.1'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M2 12h3M19 12h3M4.9 19.1L7 17M17 7l2.1-2.1'/%3E%3C/svg%3E");
}

.main {
  padding: 28px 48px 28px;
  overflow: auto;
  min-height: 0;
}

.main::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.main::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: rgba(8, 21, 38, 0.85);
}
.main::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.main::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 24px;
  min-height: 88px;
}
.hero h1,
.brand-thin {
  margin: 0;
  font-size: 32px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #ffffff;
  justify-self: start;
  align-self: center;
}
.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  align-self: center;
}
.hero-btn {
  appearance: none;
  border: 2px solid rgba(47, 224, 212, 0.55);
  background: rgba(8, 21, 38, 0.55);
  border-radius: 16px;
  padding: 20px 36px;
  margin: 0;
  color: var(--muted);
  font-family: var(--font);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.hero-btn:hover {
  color: #eef7ff;
  border-color: rgba(47, 224, 212, 0.9);
  background: rgba(47, 224, 212, 0.08);
}
.hero-btn[data-quiet="1"] {
  color: #04333a;
  border-color: #2fe0d4;
  background: linear-gradient(90deg, #1ec4c0, #2fe0d4 55%, #57ebe0);
  font-weight: 650;
}
.hero-btn[data-quiet="1"]:hover {
  color: #021c20;
  border-color: #57ebe0;
  background: linear-gradient(90deg, #2fe0d4, #57ebe0 55%, #7af0e8);
}
.live-indicators {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 22px;
  justify-self: end;
  align-self: center;
  margin-left: 0;
  min-height: 0;
  height: 100%;
}
.ind {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  font-weight: 500;
}
.ind .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.55);
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.12);
}
body.web .titlebar { display: none; }
body.web .shell { height: 100vh; }
body.web .main { padding-top: 24px; }
.ind[data-state="ok"] { color: rgba(190, 245, 236, 0.95); }
.ind[data-state="ok"] .dot {
  background: #2fe0d4;
  box-shadow: 0 0 0 6px rgba(47, 224, 212, 0.22);
}
.ind[data-state="bad"] { color: rgba(255, 180, 180, 0.9); }
.ind[data-state="bad"] .dot {
  background: #f07178;
  box-shadow: 0 0 0 6px rgba(240, 113, 120, 0.2);
}
.ind[data-state="unknown"] .dot {
  background: rgba(148, 163, 184, 0.45);
}

.view { display: none; margin-top: 24px; }
.view.active { display: block; }

.card {
  background: linear-gradient(180deg, rgba(20,48,72,0.9), rgba(12,28,46,0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.schedule-card { padding: 8px 20px 16px; }
.schedule-row { padding: 12px 0; }
.schedule-divider {
  height: 1px;
  margin: 4px 0;
  background: rgba(47, 224, 212, 0.12);
}
.schedule-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.card-title { font-size: 18px; font-weight: 650; }
.card-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }

.times {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  color: var(--teal);
}
.time-field {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  position: relative;
}
.times input[type="date"] {
  width: 174px;
  height: 46px;
  background: linear-gradient(180deg, rgba(11, 31, 51, 0.98), rgba(7, 22, 38, 0.98));
  border: 1px solid rgba(47, 224, 212, 0.42);
  color: var(--text);
  border-radius: 12px;
  padding: 0 12px;
  color-scheme: dark;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  outline: none;
  cursor: pointer;
}
.times input[type="date"]:hover {
  border-color: rgba(47, 224, 212, 0.75);
}
.times input[type="date"]:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 224, 212, 0.14);
}
.times input[type="date"]::-webkit-calendar-picker-indicator {
  width: 20px;
  height: 20px;
  opacity: 0.8;
  cursor: pointer;
}
.time-btn {
  min-width: 132px;
  height: 46px;
  background: linear-gradient(180deg, rgba(11, 31, 51, 0.98), rgba(7, 22, 38, 0.98));
  border: 1px solid rgba(47, 224, 212, 0.42);
  color: var(--text);
  border-radius: 12px;
  padding: 0 14px;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.time-btn:hover {
  border-color: rgba(47, 224, 212, 0.75);
  background: linear-gradient(180deg, rgba(14, 41, 65, 0.98), rgba(8, 27, 45, 0.98));
}
.time-btn.open,
.time-btn:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 224, 212, 0.14);
}
.time-popover {
  position: fixed;
  z-index: 80;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: linear-gradient(180deg, #10263d, #0a1828);
  border: 1px solid rgba(120, 160, 190, 0.28);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  min-width: 148px;
}
.time-col {
  flex: 1;
  max-height: 180px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 160, 190, 0.4) transparent;
}
.time-col::-webkit-scrollbar { width: 6px; }
.time-col::-webkit-scrollbar-thumb {
  background: rgba(120, 160, 190, 0.35);
  border-radius: 999px;
}
.time-opt {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}
.time-opt:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #eef7ff;
}
.time-opt.active {
  background: rgba(70, 120, 160, 0.55);
  color: #eef7ff;
}
.dash {
  color: rgba(143, 166, 191, 0.65);
  font-size: 22px;
}

.switch {
  position: relative;
  width: 52px;
  height: 30px;
  display: inline-block;
}
.switch input { display: none; }
.slider {
  position: absolute;
  inset: 0;
  background: #31465d;
  border-radius: 999px;
  cursor: pointer;
  transition: .2s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .slider { background: linear-gradient(90deg, var(--teal2), var(--teal)); }
.switch input:checked + .slider::before { transform: translateX(22px); }

.checkline {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.round-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.round-box {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid rgba(140, 175, 205, 0.7);
  background: rgba(12, 24, 40, 0.95);
  box-shadow: none;
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: border-color .18s, background .18s;
}
.round-box svg {
  width: 10px;
  height: 10px;
  display: block;
  flex: 0 0 auto;
  opacity: 0;
  overflow: visible;
  pointer-events: none;
  transition: opacity .14s ease;
}
.round-box svg path {
  fill: none;
  stroke: var(--teal);
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.round-check:hover .round-box {
  border-color: rgba(47, 224, 212, 0.55);
}
.round-check input:checked + .round-box {
  border-color: var(--teal);
  background: rgba(12, 24, 40, 0.95);
  box-shadow: none;
}
.round-check input:checked + .round-box svg {
  opacity: 1;
}
#weekend-times.disabled,
#vacation-dates.disabled { opacity: 0.35; pointer-events: none; }

.status {
  margin-top: 16px;
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 650;
}
.status.quiet {
  background: linear-gradient(90deg, #1ec4c0, #2fe0d4 55%, #57ebe0);
  color: #04333a;
}
.status.loud {
  background: linear-gradient(90deg, #24384f, #314b66);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}
.status-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.35);
  font-size: 16px;
}

.block { margin-top: 22px; }
.block h2 { margin: 0 0 10px; font-size: 18px; }
.hint { color: var(--muted); margin: 0 0 14px; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.list .meta { color: var(--muted); font-size: 12px; }
.list button.linkish {
  background: transparent;
  border: 0;
  color: var(--teal);
  cursor: pointer;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 15px;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(90deg, var(--teal2), var(--teal));
  color: #04333a;
  border: 0;
  font-weight: 700;
  margin-top: 22px;
  width: 100%;
  padding: 16px;
  font-size: 16px;
}
.btn.ghost { background: transparent; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.row input[type="text"],
.row input[type="password"],
#exc-query {
  flex: 1;
  min-width: 180px;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}

.connect {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  align-items: start;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.15);
}
.qr-wrap {
  width: 180px;
  height: 180px;
  background: white;
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.qr-wrap img { width: 100%; height: 100%; object-fit: contain; }
.qr-placeholder {
  color: #5a6b7c;
  font-size: 13px;
  text-align: center;
  padding: 12px;
}
.conn { margin-bottom: 8px; color: var(--teal); font-weight: 600; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #10263b;
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 360px;
  z-index: 20;
}
.hidden { display: none !important; }

@media (max-width: 980px) {
  .app { grid-template-columns: 72px 1fr; }
  .nav-item span:last-child { display: none; }
  .main { padding: 20px; }
  .connect { grid-template-columns: 1fr; }
}
