:root {
  --blue: #5673dc;
  --ink: #1c264a;
  --muted: #676d83;
  --pale: #f3f4f7;
  --line: #dfe4f2;
  font:
    15px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--pale);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px max(24px, calc((100vw - 1160px) / 2));
  background: white;
  border-bottom: 1px solid var(--line);
}
header img {
  width: 135px;
  display: block;
}
header span {
  flex: 1;
  color: var(--muted);
}
main {
  max-width: 1160px;
  margin: auto;
  padding: 28px 24px;
}
h1 {
  font-size: clamp(29px, 4vw, 45px);
  line-height: 1.15;
  margin: 10px 0 18px;
  letter-spacing: -1px;
}
h2 {
  font-size: 22px;
  margin: 0 0 12px;
}
h3 {
  margin: 15px 0 10px;
}
p {
  margin: 10px 0;
}
.hero {
  display: flex;
  align-items: center;
  gap: 45px;
  background: linear-gradient(115deg, #dce3f7, #ecf0fa);
  border-radius: 26px;
  padding: 32px 38px;
  margin-bottom: 24px;
}
.hero p {
  max-width: 700px;
  color: #485478;
}
.hero .eyebrow {
  color: var(--blue);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
}
.hero-mark {
  width: 135px;
  height: 135px;
  object-fit: contain;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  margin: 20px 0;
  box-shadow: 0 5px 22px #1c264a06;
}
summary {
  cursor: pointer;
  font-weight: 700;
  padding: 3px 0;
}
details[open] > summary {
  margin-bottom: 18px;
}
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
.steps b {
  font-size: 17px;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #4e5876;
  margin: 12px 0;
}
input,
select {
  width: 100%;
  border: 1px solid #ccd4e9;
  border-radius: 11px;
  padding: 11px 12px;
  min-height: 43px;
  background: white;
  color: var(--ink);
  font: inherit;
  margin-top: 5px;
}
button,
.button {
  display: inline-block;
  font: 600 14px/1.4 system-ui;
  color: white;
  background: var(--blue);
  border: 0;
  border-radius: 11px;
  padding: 12px 17px;
  text-decoration: none;
  cursor: pointer;
  vertical-align: middle;
}
button:hover,
.button:hover {
  filter: brightness(0.96);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.secondary {
  background: #e9edfa;
  color: #3853ae;
}
.ghost {
  background: transparent;
  color: var(--blue);
}
:focus-visible {
  outline: 3px solid #4ba0dd;
  outline-offset: 3px;
}
.hint {
  font-size: 13px;
  color: var(--muted);
}
.toolbar,
.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}
.toolbar label {
  flex: 1;
  min-width: 160px;
}
.toolbar button {
  margin-bottom: 12px;
}
.auto-status {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 23px;
}
.crm-setup { grid-template-columns: 1fr 1fr; margin-top: 16px; }
.crm-schedule { display: grid; gap: 10px; }
.crm-visit {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: #f8f9ff;
}
.crm-visit strong { display: block; }
.crm-visit p { margin: 4px 0; font-size: 13px; color: var(--muted); }
.crm-passport {
  border-left: 3px solid #a9baf0;
  padding-left: 12px;
  margin-top: 10px;
  overflow-wrap: anywhere;
}
#crmConnectionSetup { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 18px; }
.inline-form label {
  flex: 1;
  min-width: 140px;
}
.inline-form button {
  margin-bottom: 12px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}
.tag {
  font-size: 12px;
  color: #405aba;
  background: #e9edfb;
  border-radius: 20px;
  padding: 6px 12px;
}
.analysis-progress {
  border-color: #bbc9f1;
  background: linear-gradient(125deg, #f8faff, white 60%);
}
.analysis-progress h2 { margin-bottom: 0; }
.analysis-current { display: flex; align-items: center; gap: 12px; margin: 22px 0; }
.analysis-current strong { display: block; font-size: 19px; }
.analysis-current .hint { display: block; margin-top: 4px; }
.analysis-activity { width: 12px; height: 12px; flex-shrink: 0; border-radius: 50%; background: var(--blue); }
.analysis-progress.running .analysis-activity { animation: analysis-pulse 1.8s ease-in-out infinite; }
.analysis-progress.paused .analysis-activity { background: #ad852d; }
.analysis-progress.failed .analysis-activity { background: #bc604a; }
.analysis-progress.failed { border-color: #edc6b8; }
.analysis-progress.failed .tag { background: #fff1ed; color: #984c32; }
.analysis-audio-head { display: flex; justify-content: space-between; gap: 14px; font-size: 14px; margin-bottom: 9px; }
.analysis-audio-head strong { white-space: nowrap; color: #3853ae; }
.analysis-bar { height: 10px; border-radius: 10px; background: #e2e8f8; overflow: hidden; }
.analysis-bar > div { height: 100%; width: 0; border-radius: inherit; background: var(--blue); transition: width 0.4s ease; }
.analysis-bar.indeterminate > div { width: 25%; opacity: 0.45; }
.analysis-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.analysis-counts > div { padding: 12px 15px; background: #f0f3fc; border-radius: 12px; }
.analysis-counts span { display: block; font-size: 12px; color: var(--muted); }
.analysis-counts strong { display: block; margin-top: 3px; font-size: 18px; }
.analysis-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 18px 0 12px; padding: 0; font-size: 13px; color: var(--muted); }
.analysis-steps li::before { content: ""; display: inline-block; width: 8px; height: 8px; border: 1px solid #9ba8cb; border-radius: 50%; margin-right: 8px; }
.analysis-steps .current { color: #3853ae; font-weight: 600; }
.analysis-steps .current::before { background: var(--blue); border-color: var(--blue); }
.analysis-steps .done { color: #2b796a; }
.analysis-steps .done::before { background: #2b967d; border-color: #2b967d; }
.analysis-updated { margin-bottom: 0; font-size: 12px; }
@keyframes analysis-pulse { 50% { box-shadow: 0 0 0 6px #5673dc18; } }
@media (prefers-reduced-motion: reduce) { .analysis-progress.running .analysis-activity { animation: none; } .analysis-bar > div { transition: none; } }
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}
.camera-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-width: 0;
}
.camera-card h3 {
  margin: 0 0 8px;
}
.camera-card p {
  font-size: 13px;
  color: var(--muted);
}
.camera-card.active {
  border-color: var(--blue);
  background: #f5f7fe;
}
fieldset { min-width: 0; }
#cameraSettingsFields { border: 0; margin: 0; padding: 0; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.settings-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 18px;
  margin: 0;
}
.settings-group > legend { font-weight: 700; padding: 0 6px; }
.settings-time { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-days { border: 0; margin: 16px 0 4px; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.settings-days legend { font-size: 13px; font-weight: 600; color: #4e5876; margin-bottom: 8px; }
.settings-days label {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 7px 9px;
  margin: 0;
  background: #f3f5fb;
  border-radius: 9px;
}
.settings-days input { min-height: 0; width: auto; margin: 0; accent-color: var(--blue); }
.settings-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.settings-pending { background: #fff8e8; color: #785a21; border: 1px solid #ecddba; border-radius: 12px; padding: 12px 16px; }
#cameraSettingsHint.error { color: #984c32; }
.analysis-rules { margin: 18px 0; padding-top: 14px; border-top: 1px solid var(--line); }
.camera-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
#liveDialog,
#hourlyDialog {
  width: min(1080px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  color: var(--ink);
}
#liveDialog::backdrop,
#hourlyDialog::backdrop {
  background: #121a39a8;
}
.live-screen {
  display: grid;
  place-items: center;
  min-height: 220px;
  background: #151d2b;
  border-radius: 14px;
  overflow: hidden;
}
#liveImage {
  display: block;
  width: 100%;
  max-height: 65dvh;
  object-fit: contain;
}
#liveStatus.error {
  color: #984c32;
}
#retryLive {
  margin-top: 14px;
}
.hourly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.hour-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9ff;
}
.hour-card h3 { margin: 0 0 8px; }
.hour-card p { font-size: 13px; color: var(--muted); }
.hour-card button { display: block; width: 100%; margin-top: 10px; }
.hour-card small { display: block; color: var(--muted); margin-top: 10px; }
.hour-card.recording { border-color: var(--blue); }
.hourly-gaps {
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff5ea;
  color: #855321;
  font-size: 13px;
  margin: 16px 0;
}
.hourly-gaps p { margin: 5px 0; }
#showMissingHours { margin-top: 16px; }
#hourlyPlayerStatus.error { color: #984c32; }
#hourlyVideo { max-height: 65dvh; margin-top: 0; }
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8790a8;
  margin-right: 7px;
}
.dot.ok {
  background: #2b967d;
}
.dot.bad {
  background: #c98146;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0;
}
.metric {
  background: #f6f7fc;
  border-radius: 14px;
  padding: 18px;
}
.metric strong {
  display: block;
  font-size: 27px;
}
.metric span {
  font-size: 12px;
  color: var(--muted);
}
.report-text {
  white-space: pre-wrap;
  line-height: 1.8;
  background: #f6f8ff;
  border-left: 4px solid var(--blue);
  padding: 20px;
  border-radius: 10px;
}
.moment {
  display: flex;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.moment p {
  flex: 1;
  margin: 0;
}
.moment small {
  display: block;
  color: var(--muted);
}
video {
  width: 100%;
  max-height: 520px;
  background: #17212c;
  border-radius: 15px;
  margin-top: 20px;
}
.zone-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 25px;
}
.canvas-wrap {
  position: relative;
  aspect-ratio: 16/9;
  border-radius: 14px;
  overflow: hidden;
  background: #17212c;
}
.canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
.canvas-wrap p {
  position: absolute;
  top: 40%;
  width: 100%;
  padding: 0 20px;
  text-align: center;
  color: #d5dcea;
  pointer-events: none;
}
.zone-controls {
  display: flex;
  gap: 12px;
}
.zone-controls label {
  flex: 1;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
}
.check input {
  width: auto;
  min-height: 0;
  margin: 0;
  accent-color: var(--blue);
}
#zoneList > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 8px;
}
#notice {
  position: sticky;
  top: 12px;
  z-index: 5;
  padding: 14px 18px;
  border-radius: 12px;
  background: #e6edff;
  color: #2e498f;
  border: 1px solid #c5d2f5;
}
#notice.error {
  background: #fff1ed;
  color: #984c32;
  border-color: #edc6b8;
}
#issuedKeys {
  padding: 16px;
  background: #f1f5fe;
  border-radius: 12px;
  margin-top: 14px;
  overflow-wrap: anywhere;
}
.secret {
  font-family: monospace;
  word-break: break-all;
  font-size: 12px;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}
#ownerEvidenceDialog { width: min(960px, calc(100vw - 28px)); max-height: 92vh; overflow: auto; }
#ownerEvidenceVideo { width: 100%; max-height: 62vh; border-radius: 12px; background: #171b29; }
#ownerEvidenceTitle { overflow-wrap: anywhere; }
.service-details > summary { padding: 20px 24px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.service-details[open] > summary { margin-bottom: 20px; }
.has-sources .hero { padding: 20px 24px; }
.has-sources .hero h1 { font-size: 24px; }
.has-sources .hero h1 br { display: none; }
.has-sources .hero p:not(.eyebrow) { display: none; }
.has-sources .hero-mark { width: 56px; height: 56px; }
footer {
  font-size: 12px;
  text-align: center;
  color: var(--muted);
  padding: 25px 0;
}
@media (max-width: 800px) {
  .steps,
  .zone-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .crm-visit { grid-template-columns: 1fr; gap: 5px; }
  .hero {
    padding: 25px;
    gap: 15px;
  }
  .hero-mark {
    width: 75px;
    height: 75px;
  }
  header {
    gap: 12px;
    padding: 16px;
  }
  header span {
    font-size: 12px;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
  }
  .analysis-counts { grid-template-columns: 1fr; }
  .analysis-progress .section-head { flex-wrap: wrap; }
  .analysis-current strong { font-size: 17px; }
  .card {
    padding: 20px;
  }
  main {
    padding: 20px 14px;
  }
  .section-head {
    align-items: flex-start;
  }
  .moment {
    flex-wrap: wrap;
  }
}
