:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #f7efe0;
  --text: #1d2a33;
  --muted: #5c6b73;
  --accent: #0e7490;
  --accent-2: #d97706;
  --line: #dfd4bf;
  --danger: #b42318;
  --ok: #067647;
}

:root[data-theme="dark"] {
  --bg: #11161b;
  --surface: #182129;
  --surface-2: #22303b;
  --text: #eef4f7;
  --muted: #a8bac4;
  --accent: #5ec8e2;
  --accent-2: #f2ae49;
  --line: #31414d;
  --danger: #ff7a7a;
  --ok: #58c98b;
}

:root {
  --surface-strong: #ffffff;
  --surface-soft: rgba(255, 253, 248, 0.92);
  --surface-elevated: rgba(255, 253, 248, 0.96);
  --warning-text: #92400e;
}

:root[data-theme="dark"] {
  --surface-strong: #1d2831;
  --surface-soft: rgba(24, 33, 41, 0.92);
  --surface-elevated: rgba(24, 33, 41, 0.96);
  --warning-text: #ffd089;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(14, 116, 144, 0.10), transparent 28%),
    radial-gradient(circle at top right, rgba(217, 119, 6, 0.12), transparent 22%),
    var(--bg);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: nowrap;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 32px;
}

.topbar-brand {
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.topbar p {
  display: none;
}

nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  flex-wrap: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

nav a,
.button-link,
button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
}

.topbar-link,
.theme-toggle,
.logout-button {
  min-height: 42px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  box-shadow: 0 4px 14px rgba(29, 42, 51, 0.05);
}

.topbar-link.active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
  font-weight: 700;
}

.theme-toggle {
  font: inherit;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.icon-button .icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.icon-button.icon-only {
  padding: 8px;
  gap: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-button:hover {
  border-color: var(--accent);
}

.icon-button.danger {
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--danger);
}

.icon-button.danger:hover {
  border-color: var(--danger);
}

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

.row-actions form {
  display: inline-flex !important;
  margin: 0;
}

.row-actions .icon-button {
  flex: 0 0 auto;
}

.archived-row {
  opacity: 0.72;
}

.archived-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
}

.employee-name-inline {
  display: inline-block;
  white-space: nowrap;
}

.employees-table td,
.employees-table th {
  padding-top: 7px;
  padding-bottom: 7px;
  vertical-align: middle;
}

.employee-photo-cell {
  width: 34px;
  text-align: center;
}

.employees-table .inline-site-reassign {
  margin: 0;
}

.employees-table .inline-site-reassign select {
  min-height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.employees-table .badge {
  padding: 4px 8px;
  font-size: 12px;
}

.employees-table .icon-button.icon-only {
  padding: 6px;
}

.site-filter {
  position: relative;
  margin: 10px 0 12px;
}

.site-filter-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  list-style: none;
  max-width: min(720px, calc(100vw - 48px));
}

.site-filter-summary::-webkit-details-marker {
  display: none;
}

.site-filter-summary strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
  font-size: 0.86rem;
}

.site-filter-picked {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.site-filter-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.site-filter-form {
  position: absolute;
  z-index: 25;
  top: calc(100% + 8px);
  left: 0;
  width: min(520px, calc(100vw - 48px));
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.12);
}

.site-filter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.site-checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
}

.site-checkbox.selected {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}

.site-checkbox input[type="checkbox"] {
  margin: 0;
  width: 16px;
  height: 16px;
  min-height: unset;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  accent-color: var(--accent);
}

.site-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  color: var(--text) !important;
}

.site-checkbox-count {
  min-width: 24px;
  margin-left: auto;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .site-filter-summary {
    max-width: calc(100vw - 32px);
  }

  .site-filter-form {
    width: min(360px, calc(100vw - 32px));
  }

  .site-filter-list {
    grid-template-columns: 1fr;
  }
}

.site-filter-reset {
  justify-self: start;
  font-size: 0.9em;
}

.avatar {
  display: inline-block;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line);
  vertical-align: middle;
}

.avatar.empty {
  opacity: 0.72;
}

.avatar-hover {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  overflow: visible;
}

.avatar-compact {
  width: 21px;
  height: 21px;
  border-radius: 6px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  transform-origin: left center;
}

.avatar-hover:hover .avatar-compact {
  position: relative;
  z-index: 20;
  transform: scale(4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.logout-form {
  margin: 0;
}

.logout-button {
  font: inherit;
}

button:hover,
nav a:hover,
.button-link:hover {
  border-color: var(--accent);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 36px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(29, 42, 51, 0.06);
}

.toolbar,
.employee-form,
.override-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.settings-field {
  display: grid;
  gap: 6px;
}

.settings-field small {
  color: var(--muted);
  font-size: 0.82rem;
}

.filter-picker {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.settings-section {
  margin-bottom: 22px;
}

.camera-list {
  display: grid;
  gap: 12px;
}

.camera-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(56px, 72px) minmax(110px, 0.7fr) minmax(110px, 0.7fr) minmax(260px, 1.55fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  transition: border-left-color 0.15s ease;
  overflow: visible;
}

.camera-row.existing-camera {
  grid-template-columns: 190px 70px minmax(260px, 1fr) auto;
}

.camera-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.camera-field > span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.camera-field input {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.camera-row .camera-field:nth-of-type(2) input {
  text-align: center;
}

.existing-camera .camera-field > span {
  font-size: 0.68rem;
}

.site-badges {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.site-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.camera-objects {
  min-width: 260px;
  position: relative;
  color: var(--muted);
}

.camera-objects-dropdown {
  width: 100%;
}

.camera-objects-dropdown summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}

.camera-objects-dropdown summary::-webkit-details-marker {
  display: none;
}

.camera-objects-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.camera-objects-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  width: 420px;
  max-width: calc(100vw - 80px);
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.12);
}

.objects-summary-empty[hidden] {
  display: none;
}

.object-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.object-chip {
  min-height: 34px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.object-chip:hover {
  border-color: var(--accent);
}

.object-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.object-chip:has(input:checked),
.object-chip.selected {
  border-color: var(--accent);
  background: rgba(14, 116, 144, 0.12);
  color: var(--accent);
  font-weight: 700;
}

.camera-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.camera-auth-note {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(14, 116, 144, 0.1);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.camera-edit-form {
  max-width: 960px;
}

.camera-edit-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(64px, 88px) minmax(220px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.camera-id-field input {
  text-align: center;
}

.camera-edit-auth-note {
  font-size: 0.92rem;
  color: var(--muted);
}

.camera-edit-objects {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.camera-edit-objects-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.camera-edit-object-strip {
  padding: 2px 0;
}

.camera-edit-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.button-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.org-dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: min(720px, calc(100% - 24px));
}

.org-dialog::backdrop {
  background: rgba(29, 42, 51, 0.55);
}

.org-dialog-inner {
  display: grid;
  gap: 18px;
  padding: 18px;
  background: var(--surface);
}

.org-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 52vh;
  overflow: auto;
  padding: 2px;
}

.org-dialog-actions {
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}

input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-strong);
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.12);
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-strong);
  color: var(--text);
}

textarea {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.12);
}

.checkbox {
  flex-direction: row;
  align-items: center;
  margin-top: 22px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}

.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.card-link:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 14px 28px rgba(29, 42, 51, 0.08);
}

.card-link.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 116, 144, 0.12);
}

.card strong {
  display: block;
  font-size: 34px;
  margin-bottom: 8px;
}

.site-overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.site-overview-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface-strong) 96%, transparent), color-mix(in srgb, var(--surface-2) 92%, transparent));
  box-shadow: 0 10px 24px rgba(29, 42, 51, 0.06);
}

.site-overview-card.accent {
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.18), color-mix(in srgb, var(--surface-strong) 98%, transparent));
}

.site-overview-card.warm {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.18), color-mix(in srgb, var(--surface-strong) 98%, transparent));
}

.site-overview-label {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-overview-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 8px;
}

.site-overview-card p {
  margin: 0;
  color: var(--muted);
}

.site-form-disclosure {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  overflow: hidden;
}

.site-form-disclosure summary {
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 700;
  color: var(--accent);
  list-style: none;
}

.site-form-disclosure summary::-webkit-details-marker {
  display: none;
}

.site-form-disclosure[open] summary {
  border-bottom: 1px solid var(--line);
}

.site-create-form {
  padding: 16px 18px 18px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.site-card {
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 98%, transparent), color-mix(in srgb, var(--surface-2) 82%, transparent));
  color: inherit;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(29, 42, 51, 0.07);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.site-card:hover {
  transform: translateY(-2px);
  border-color: rgba(14, 116, 144, 0.35);
  box-shadow: 0 16px 34px rgba(29, 42, 51, 0.11);
}

.site-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.site-card-top h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.site-card-top p {
  margin: 0;
  color: var(--muted);
}

.site-code-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(14, 116, 144, 0.12);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.site-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid rgba(223, 212, 191, 0.8);
}

.site-meta-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.site-card-meta strong {
  font-size: 1.35rem;
}

.site-card-link-text {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.site-empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.site-empty-state strong,
.site-empty-state p {
  margin: 0;
}

.site-empty-state p {
  margin-top: 6px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 12px 10px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text);
}

th.sortable[aria-sort="ascending"]::after {
  content: " ▲";
}

th.sortable[aria-sort="descending"]::after {
  content: " ▼";
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0 0 4px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.calendar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.calendar-month {
  font-weight: 700;
  color: var(--text);
}

.calendar-table {
  table-layout: fixed;
}

.calendar-table th,
.calendar-table td {
  width: 14.285%;
}

.calendar-day {
  min-height: 130px;
  background: var(--surface-strong);
}

.calendar-day.out-month {
  opacity: 0.4;
  background: color-mix(in srgb, var(--surface-strong) 55%, transparent);
}

.calendar-day.weekend {
  background: rgba(217, 119, 6, 0.04);
}

.calendar-day.holiday {
  background: rgba(6, 118, 71, 0.08);
  border-bottom-color: rgba(6, 118, 71, 0.25);
}

.calendar-day-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.calendar-day-title {
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 10px;
}

.holiday-pill,
.weekend-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.holiday-pill {
  background: rgba(6, 118, 71, 0.14);
  color: var(--ok);
}

.weekend-pill {
  background: rgba(217, 119, 6, 0.16);
  color: var(--accent-2);
}

.calendar-action {
  width: 100%;
  justify-content: center;
}

.holiday-form {
  margin-top: 16px;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge.ok {
  background: rgba(6, 118, 71, 0.12);
  color: var(--ok);
}

.badge.warn {
  background: rgba(217, 119, 6, 0.14);
  color: var(--accent-2);
}

.badge.danger {
  background: rgba(180, 35, 24, 0.10);
  color: var(--danger);
}

.status {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.status.ok {
  background: rgba(6, 118, 71, 0.08);
  color: var(--ok);
}

.status.error {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.status.warning {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning-text);
}

.dismissible-status {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dismissible-status > span {
  min-width: 0;
}

.status-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  opacity: 0.75;
}

.status-close:hover {
  opacity: 1;
}

@media (max-width: 980px) {
  .camera-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .camera-row.existing-camera {
    grid-template-columns: 1fr 90px;
  }

  .camera-objects,
  .camera-auth-note,
  .camera-actions {
    grid-column: 1 / -1;
  }

  .camera-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .camera-edit-card {
    grid-template-columns: 1fr 120px;
  }

  .camera-edit-auth-note {
    grid-column: 1 / -1;
  }
}

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

  .camera-remove {
    width: max-content;
  }

  .camera-edit-card {
    grid-template-columns: 1fr;
  }
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(29, 42, 51, 0.12);
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.alert.error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(180, 35, 24, 0.24);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.muted-inline {
  color: var(--muted);
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.period-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.period-details-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.period-detail-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

:root[data-theme="dark"] .topbar-link,
:root[data-theme="dark"] .theme-toggle,
:root[data-theme="dark"] .logout-button {
  box-shadow: none;
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .site-card,
:root[data-theme="dark"] .site-overview-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .camera-objects-panel,
:root[data-theme="dark"] .camera-row,
:root[data-theme="dark"] .camera-edit-card {
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

:root[data-theme="dark"] .calendar-day.weekend {
  background: rgba(217, 119, 6, 0.08);
}

:root[data-theme="dark"] .calendar-day.holiday {
  background: rgba(6, 118, 71, 0.12);
}

:root[data-theme="dark"] .site-card-meta {
  border-top-color: rgba(168, 186, 196, 0.22);
}

:root[data-theme="dark"] .alert.error {
  background: rgba(180, 35, 24, 0.16);
  border-color: rgba(255, 122, 122, 0.34);
}

@media (max-width: 720px) {
  .topbar {
    position: static;
  }

  .topbar-inner {
    padding: 18px;
    align-items: start;
    flex-direction: column;
  }

  .topbar-nav,
  .topbar-actions {
    justify-content: flex-start;
  }

  .page {
    padding: 16px;
  }

  table {
    font-size: 14px;
  }

  .override-form {
    min-width: 220px;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .calendar-day {
    min-height: 100px;
  }
}

.group-dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: min(980px, calc(100% - 24px));
}

.group-dialog::backdrop {
  background: rgba(29, 42, 51, 0.55);
}

.group-dialog-inner {
  padding: 18px;
}

.dialog-table {
  max-height: 70vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

/* Overlay для синхронизации */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(29, 42, 51, 0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.overlay.show {
  display: flex;
}

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px 40px;
  min-width: 360px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(29, 42, 51, 0.2);
}

.overlay-card h3 {
  margin: 16px 0 8px;
}

.overlay-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #0ea5e9);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.button-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
}

.button-primary:hover {
  background: #0c7a96;
}

.button-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sync-hint {
  font-size: 13px;
}

.new-site-form {
  background: var(--surface-2);
  border: 1px dashed var(--line);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
  font-weight: 500;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-ok {
  background: rgba(6, 118, 71, 0.08);
  border-color: rgba(6, 118, 71, 0.25);
  color: var(--ok);
}

.toast-error {
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.toast-warning {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.25);
  color: var(--warning-text);
}

.toast-duplicate {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.25);
  color: var(--warning-text);
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.5;
  line-height: 1;
}
.toast-close:hover { opacity: 1; }
