:root {
  color-scheme: dark;
  --bg: #111a24;
  --panel: #192531;
  --panel-raised: #1e2c39;
  --line: #2b3a48;
  --text: #edf2f5;
  --muted: #91a0ad;
  --green: #67d5a5;
  --green-dark: #143f35;
  --blue: #a9c7ff;
  --red: #ff9a94;
  font-family: "Segoe UI", "Arial", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  height: 72px;
  padding: 0 max(28px, calc((100vw - 1280px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #263441;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-family: Manrope, sans-serif;
  font-weight: 800;
  letter-spacing: -.5px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #397f68;
  border-radius: 10px;
  color: var(--green);
  font-size: 11px;
  letter-spacing: -.2px;
}

.brand-light { color: #9cabb7; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-note { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px #67d5a577; }

.layout { max-width: 1280px; margin: 0 auto; padding: 45px 28px 25px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 29px; }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; margin: 0 0 10px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font: 700 clamp(28px, 3vw, 38px)/1.2 Manrope, sans-serif; letter-spacing: -1.5px; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.model-badge { border: 1px solid var(--line); background: #17222d; padding: 9px 13px; border-radius: 99px; color: #bac8d2; font-size: 11px; white-space: nowrap; }
.model-badge span { color: var(--green); margin-right: 5px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.metric-card, .panel { border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.login-panel { max-width: 440px; margin: 8vh auto; }
.login-panel h1 { margin-bottom: 10px; font-size: 25px; }
.login-form { display: grid; gap: 13px; margin-top: 21px; }
.login-form label > span { display: block; margin: 0 0 7px; color: #a7b4be; font-size: 11px; }
.login-form .button { width: 100%; }
.metric-card { min-height: 120px; padding: 18px 20px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 110px; height: 110px; border-radius: 50%; right: -40px; top: -50px; border: 1px solid #354d5d; opacity: .6; }
.metric-label, .metric-caption { display: block; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 9px 0 3px; font: 700 29px Manrope, sans-serif; letter-spacing: -1px; }
.metric-caption { font-size: 10px; color: #6f7f8d; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(270px, .85fr); gap: 18px; align-items: start; }
.main-column { display: grid; gap: 18px; min-width: 0; }
.panel { padding: 21px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
h2 { font: 700 17px Manrope, sans-serif; margin-bottom: 0; letter-spacing: -.25px; }
.heading-hint { color: #758592; font-size: 10px; }

.viewer-panel { min-width: 0; margin-bottom: 18px; }
.viewer-source-label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.viewer-source-label select { width: min(250px, 42vw); height: 35px; padding: 0 10px; border: 1px solid #354654; border-radius: 7px; background: #131e28; color: var(--text); font-size: 11px; }
.viewer-frame { position: relative; display: grid; place-items: center; min-height: 220px; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid #293844; border-radius: 9px; background: #0a1016; }
.viewer-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer-image.video-cover, .viewer-snapshot.video-cover { object-fit: cover; }
.viewer-snapshot { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer-placeholder { display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; color: #81919e; text-align: center; }
.viewer-placeholder strong { color: #bdc9d1; font-size: 13px; font-weight: 600; }
.viewer-placeholder span:last-child { font-size: 10px; }
.viewer-icon { color: #66cda0; font-size: 28px; }
.viewer-status { position: absolute; top: 11px; left: 11px; padding: 5px 8px; border: 1px solid #385347; border-radius: 99px; background: #14251fe8; color: #a3e4c1; font-size: 9px; }
.viewer-controls { position: absolute; right: 11px; bottom: 11px; display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.viewer-control { min-height: 32px; padding: 0 10px; border: 1px solid #71818d88; border-radius: 6px; background: #111a24e8; color: #edf2f5; font-size: 10px; font-weight: 600; }
.viewer-control:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.viewer-control:disabled { opacity: .45; cursor: not-allowed; }
.viewer-frame:fullscreen { width: 100vw; height: 100vh; min-height: 0; aspect-ratio: auto; border: 0; border-radius: 0; }
.viewer-frame:fullscreen .viewer-image, .viewer-frame:fullscreen .viewer-snapshot { max-width: 100vw; max-height: 100vh; }
.viewer-details { display: flex; align-items: start; gap: 18px; padding-top: 15px; }
.viewer-details > div:first-child { min-width: 105px; }
.detail-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.viewer-details > div:first-child strong { font: 700 20px Manrope, sans-serif; }
.object-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.count-chip { display: inline-flex; gap: 7px; align-items: center; padding: 5px 8px; border: 1px solid #315549; border-radius: 6px; background: #183229; color: #8de0b7; font-size: 10px; }
.count-chip span { color: #d3f3e2; font-weight: 700; }
.empty-counts { padding-top: 4px; color: #7d8c99; font-size: 10px; }

.camera-form { display: grid; grid-template-columns: .8fr 1.35fr auto; align-items: end; gap: 10px; }
.station-camera-form { grid-template-columns: .75fr 1.3fr 1fr auto; }
.station-webcam-form { grid-template-columns: .9fr .9fr 1fr auto; }
.camera-form label > span { display: block; margin: 0 0 7px; color: #a7b4be; font-size: 11px; }
input:not([type="file"]), .station-camera-form select, .station-webcam-form select { width: 100%; height: 39px; padding: 0 11px; border: 1px solid #354654; border-radius: 7px; outline: none; background: #131e28; color: var(--text); font-size: 12px; }
input:focus, select:focus { border-color: #58bb91 !important; box-shadow: 0 0 0 2px #58bb9122; }
input::placeholder { color: #647381; }
.button { height: 39px; border: 0; border-radius: 7px; padding: 0 15px; font-size: 11px; font-weight: 700; white-space: nowrap; transition: .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { background: var(--green); color: #10251e; }
.button-secondary { border: 1px solid #405161; background: #263745; color: #e6edf2; }

.or-divider { display: flex; align-items: center; gap: 11px; margin: 18px 0 15px; color: #758592; font-size: 10px; }
.or-divider::before, .or-divider::after { content: ""; height: 1px; flex: 1; background: #2d3b48; }
.upload-form { display: flex; gap: 10px; align-items: center; }
.file-picker { min-width: 0; flex: 1; display: flex; align-items: center; gap: 11px; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-icon { width: 34px; height: 34px; border: 1px dashed #516575; border-radius: 8px; display: grid; place-items: center; color: var(--blue); font-size: 18px; }
.file-picker strong, .file-picker small { display: block; }
.file-picker strong { color: #cdd7de; font-size: 11px; font-weight: 600; }
.file-picker small { margin-top: 3px; color: #748492; font-size: 9px; }
.notice { min-height: 16px; margin: 11px 0 -7px; color: var(--green); font-size: 11px; }
.notice.error, .source-error { color: var(--red); }

.events-panel { padding-bottom: 8px; }
.text-button { border: 0; background: transparent; color: var(--green); font-size: 11px; padding: 7px 0 7px 10px; }
.text-button span { font-size: 15px; vertical-align: -1px; }
.table-wrap { width: 100%; overflow-x: auto; }
.shop-panel { margin-bottom: 18px; }
.shop-settings-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: -4px 0 6px; }
.shop-settings-form label { width: min(250px, 100%); }
.shop-settings-form label > span { display: block; margin: 0 0 7px; color: #a7b4be; font-size: 11px; }
.shop-settings-form small { flex-basis: 100%; color: #788895; font-size: 10px; line-height: 1.5; }
.shop-subheading { margin: 22px 0 12px; color: #dce5eb; font: 600 13px Manrope, sans-serif; }
.shop-row-error { color: var(--red); white-space: normal; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { padding: 0 12px 11px; color: #778795; font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; }
td { padding: 12px; border-top: 1px solid #293844; color: #bdc8d0; font-size: 11px; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.object-tag { border: 1px solid #315549; border-radius: 5px; padding: 4px 7px; background: #183229; color: #8de0b7; font-size: 10px; }
.empty-state { padding: 23px 10px; color: #7d8c99; text-align: center; font-size: 11px; }

.sources-panel { min-height: 300px; }
.sources-list { display: grid; gap: 9px; }
.source-card { display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; align-items: center; padding: 12px; border: 1px solid #2c3b48; border-radius: 8px; background: #17232e; }
.source-info strong, .source-info span { display: block; }
.source-info strong { max-width: 175px; overflow: hidden; text-overflow: ellipsis; color: #dce5eb; font-size: 11px; font-weight: 600; }
.source-info span { margin-top: 4px; color: #788895; font-size: 9px; }
.source-object-summary { grid-column: 1 / -1; margin: 0; color: #91c9ac; font-size: 9px; line-height: 1.5; }
.state { border: 1px solid #3c4a56; border-radius: 99px; padding: 4px 7px; color: #aeb9c1; font-size: 9px; text-transform: capitalize; }
.state-running { border-color: #2f604e; background: #17352b; color: #83d6ae; }
.state-failed { border-color: #754541; background: #3a2424; color: #ffaaa3; }
.state-completed, .state-stopped { color: #9cabb6; }
.source-error { grid-column: 1 / -1; margin: 0; font-size: 10px; line-height: 1.5; }
.stop-button { grid-column: 1 / -1; width: fit-content; padding: 4px 0; border: 0; background: transparent; color: #f0a29b; font-size: 10px; }
.system-controls { margin-top: 20px; padding-top: 18px; border-top: 1px solid #2d3b48; }
.system-controls .eyebrow { margin-bottom: 5px; }
.system-controls h3 { margin: 0 0 12px; color: #dce5eb; font: 600 13px Manrope, sans-serif; }
.system-action { min-height: 36px; padding: 7px 9px; border: 1px solid #3b4b58; border-radius: 6px; background: #1a2834; color: #c5d0d8; font-size: 10px; text-align: left; }
.system-action:hover:not(:disabled) { border-color: #687a88; background: #21313e; }
.system-action:disabled { opacity: .5; cursor: wait; }
.system-action-primary { width: 100%; margin-bottom: 7px; border-color: #8a504d; background: #3a2526; color: #ffb0a9; font-weight: 700; }
.system-action-primary:hover:not(:disabled) { border-color: #d47c74; background: #492d2d; }
.system-action-stop { border-color: #594644; color: #e6aaa3; }
.system-action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.system-note { margin: 9px 0 0; color: #788895; font-size: 9px; line-height: 1.5; }
.info-card { display: flex; align-items: start; gap: 9px; margin-top: 20px; padding: 12px; border: 1px solid #344655; border-radius: 8px; background: #1b2a36; }
.info-icon { width: 16px; height: 16px; flex: 0 0 auto; border: 1px solid #86a4bd; border-radius: 50%; color: #a8c3d6; text-align: center; font: 600 10px/15px Manrope, sans-serif; }
.info-card p { margin: 0; color: #9baab5; font-size: 10px; line-height: 1.55; }
footer { padding: 25px 0 4px; color: #687885; text-align: center; font-size: 10px; }

@media (max-width: 850px) {
  .content-grid { grid-template-columns: 1fr; }
  .sources-panel { min-height: 0; }
}

@media (max-width: 600px) {
  .topbar { height: 62px; padding: 0 18px; }
  .layout { padding: 33px 16px 18px; }
  .intro { align-items: start; flex-direction: column; margin-bottom: 20px; }
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric-card { min-height: 102px; padding: 13px 10px; }
  .metric-label { min-height: 27px; font-size: 10px; }
  .metric-card strong { margin-top: 5px; font-size: 23px; }
  .metric-caption { font-size: 9px; }
  .panel { padding: 16px; }
  .camera-form { grid-template-columns: 1fr; }
  .camera-form .button { width: 100%; }
  .upload-form { align-items: stretch; flex-direction: column; }
  .upload-form .button { width: 100%; }
  .heading-hint { display: none; }
  .viewer-panel .panel-heading { align-items: start; }
  .viewer-source-label select { width: 145px; }
  .viewer-frame { min-height: 180px; }
  .viewer-details { flex-direction: column; gap: 10px; }
}
