:root {
  --bg: #f5f7fb;
  --bg-secondary: #eef2f7;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --border: #e5e7eb;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

body.fullscreen-open {
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(18px);
  background: #1f2a36;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar .brand {
  max-width: 1880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 24px;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 10px 20px rgba(18, 20, 22, 0.12);
}

.brand-title {
  display: block;
  font-family: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f5f7fb;
  font-size: 1.05rem;
}

.brand-subtitle {
  display: block;
  font-size: 0.85rem;
  color: rgba(245, 247, 251, 0.7);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user-name {
  font-size: 0.82rem;
  color: rgba(245, 247, 251, 0.92);
  font-weight: 600;
}

.topbar-logout {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.07);
  color: #f8fafc;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}

h1, h2, h3 {
  font-family: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  margin: 0 0 0.5rem 0;
}

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

.app-shell {
  max-width: 1880px;
  margin: 0 auto;
  padding: 32px 24px 40px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.hero h1 {
  font-size: clamp(2rem, 3.6vw, 2.8rem);
}

.subtitle {
  max-width: 480px;
  font-size: 0.95rem;
}

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

.meta-item {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.meta-item .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
}

.meta-item .value {
  font-weight: 600;
}

.meta-compact {
  padding: 8px 12px;
  box-shadow: none;
  border: 1px solid rgba(28, 28, 28, 0.08);
}

.meta-compact .label {
  font-size: 0.64rem;
  margin-bottom: 4px;
}

.meta-compact .value {
  font-size: 0.9rem;
}

.hospital-stack {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  display: grid;
  gap: 28px;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 620px;
}

.hospital-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: fadeUp 420ms ease both;
  animation-delay: var(--delay, 0ms);
}

.hospital-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hospital-header p {
  font-size: 0.82rem;
}

.pill {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

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

@media (min-width: 1200px) {
  .camera-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.camera-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 10px;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(28, 28, 28, 0.05);
  animation: fadeUp 420ms ease both;
  animation-delay: var(--delay, 0ms);
}

.camera-card--interactive {
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.camera-card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
}

.camera-card--interactive:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.camera-frame {
  background: #1f1f1f;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  position: relative;
}

.camera-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-expand {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(17, 24, 39, 0.7);
  color: #fff;
  border-radius: 10px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.camera-expand-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 8, 23, 0.92);
  padding: 24px;
  display: grid;
}

.fullscreen-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #0f172a;
}

.fullscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.fullscreen-header h2 {
  color: #f8fafc;
  margin: 0;
  font-size: 1rem;
}

.fullscreen-header p {
  color: rgba(248, 250, 252, 0.78);
  margin-top: 2px;
  font-size: 0.78rem;
}

.fullscreen-close {
  border: 1px solid rgba(248, 250, 252, 0.4);
  background: rgba(248, 250, 252, 0.08);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.fullscreen-frame {
  min-height: 0;
  background: #000;
}

.fullscreen-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.camera-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.camera-meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #3bb273;
  box-shadow: 0 0 0 4px rgba(59, 178, 115, 0.2);
}

.status-dot.faded {
  background: rgba(59, 178, 115, 0.22);
  box-shadow: 0 0 0 4px rgba(59, 178, 115, 0.04);
}

.events-panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 620px;
  width: 100%;
}

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

.events-actions .ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.events-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-select {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 160px;
}

.event-table {
  display: grid;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.event-row {
  display: grid;
  grid-template-columns: 0.9fr 1.6fr 1.2fr 1fr;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.event-row:last-child {
  border-bottom: none;
}

.event-row.event-head {
  background: #f8fafc;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.event-cell {
  display: grid;
  gap: 4px;
}

.event-title,
.event-location,
.event-person {
  font-weight: 600;
}

.event-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

.event-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  width: fit-content;
}

.event-badge.zkteco {
  background: #205072;
}

.events-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.events-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.page-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-info {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-sep {
  opacity: 0.6;
}

.login-page {
  background: #e6e8ed;
  color: #13253d;
}

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

.login-brand {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.login-brand-logo {
  width: 250px;
  max-width: 70vw;
  height: auto;
}

.login-brand-title {
  margin: 0;
  font-family: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 36px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #0f2740;
}

.login-card {
  width: min(540px, 90vw);
  border-radius: 4px;
  background: #f5f6f8;
  border: 1px solid #d6dbe2;
  box-shadow: none;
  padding: 36px 34px 32px;
}

.login-card-title {
  margin: 0 0 20px;
  font-family: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: #0f2740;
  text-align: center;
}

.login-sso-btn {
  width: 100%;
  border: none;
  background: #2fb14a;
  color: #fff;
  border-radius: 5px;
  height: 42px;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 18px;
}

.login-error {
  border: 1px solid rgba(185, 28, 28, 0.25);
  background: rgba(239, 68, 68, 0.1);
  color: #991b1b;
  border-radius: 5px;
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 14px;
}

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

.login-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.login-label {
  font-size: 21px;
  font-weight: 500;
  color: #0f2740;
}

.login-forgot-link {
  font-size: 17px;
  color: #7586a2;
  text-decoration: none;
}

.login-form input {
  width: 100%;
  border: 1px solid #c8cfd8;
  border-radius: 5px;
  height: 44px;
  font-size: 19px;
  padding: 0 14px;
  background: #fbfcfe;
  color: #1a2f49;
  margin-bottom: 8px;
}

.login-form input::placeholder {
  color: #9aa8be;
}

.login-submit-btn {
  width: 100%;
  border: none;
  background: #99bfe2;
  color: #f7fbff;
  border-radius: 3px;
  height: 40px;
  font-size: 23px;
  font-weight: 400;
  cursor: pointer;
  margin-top: 10px;
  transition: background-color 180ms ease;
}

.login-submit-btn.is-ready {
  background: #0b38ff;
}

.login-submit-btn.is-ready:hover {
  background: #2b52ff;
}

.login-footer-brand {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  color: #7f98b5;
}

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

@media (max-width: 900px) {
  .login-brand-logo {
    width: 185px;
  }

  .login-brand-title {
    font-size: 28px;
  }

  .login-card {
    width: min(520px, 94vw);
    padding: 26px 18px;
  }

  .login-card-title {
    font-size: 24px;
  }

  .login-sso-btn,
  .login-submit-btn {
    font-size: 18px;
  }

  .login-label {
    font-size: 17px;
  }

  .login-forgot-link {
    font-size: 14px;
  }

  .login-form input {
    font-size: 16px;
    height: 42px;
  }

  .login-footer-brand {
    font-size: 18px;
  }

  .topbar .brand {
    flex-wrap: wrap;
  }

  .topbar-user {
    width: 100%;
    justify-content: space-between;
  }

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

  .events-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .events-actions {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-select {
    width: 100%;
  }

  .event-row {
    grid-template-columns: 1fr;
  }

  .fullscreen-overlay {
    padding: 0;
  }

  .fullscreen-shell {
    border-radius: 0;
    border: none;
  }

  .fullscreen-header {
    padding: 12px;
  }
}

@media (min-width: 900px) {
  .events-panel {
    position: sticky;
    top: 32px;
    max-height: calc(100vh - 120px);
    overflow: auto;
  }
}

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

  .events-panel {
    margin-top: 24px;
  }
}
