html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #222;
  color: #fff;
  padding: 5px 15px;
  box-sizing: border-box;
  height: 40px;
  flex-shrink: 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topbar .title {
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  flex-grow: 1;
}

.topbar button,
.topbar-tab {
  padding: 4px 10px;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
}

.topbar-tab {
  background: #444;
  color: #fff;
}

.topbar-tab:hover {
  background: #555;
}

.topbar-tab.active {
  background: #3498db;
  color: #fff;
}

.topbar button {
  background: #555;
  color: #fff;
}

.topbar .logout {
  background: #e74c3c;
  color: #fff;
}

/* STRONA TABELI */
.page-table {
  background: #f0f2f5;
  min-height: 100vh;
}

.table-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 32px;
  box-sizing: border-box;
}

.table-desc {
  margin: 0 0 16px;
  color: #555;
  font-size: 14px;
}

.table-loading,
.table-empty {
  color: #666;
  text-align: center;
  padding: 40px 16px;
  font-size: 15px;
}

.data-table-wrap {
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

.data-table thead {
  background: #2c3e50;
  color: #fff;
}

.data-table th {
  padding: 12px 14px;
  font-weight: 600;
  white-space: nowrap;
  font-size: 13px;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #eef0f3;
  vertical-align: middle;
  color: #222;
}

.data-table tbody tr:hover {
  background: #f8fafb;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .col-name {
  font-weight: 600;
  min-width: 160px;
}

.data-table .col-num {
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.data-table .col-date {
  white-space: nowrap;
}

.data-table code {
  background: #f0f3f6;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.online {
  background: #d5f5e3;
  color: #1e8449;
}

.badge.offline {
  background: #f2f2f2;
  color: #7f8c8d;
}

.btn-camera {
  display: inline-block;
  padding: 6px 14px;
  background: #3498db;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.btn-camera.disabled {
  color: #aaa;
  background: transparent;
  padding: 0;
}

/* ADMIN FORM */
.admin-form-box {
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.admin-form-box h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.admin-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #444;
}

.admin-form-grid input,
.admin-form-grid select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.admin-form-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.btn-primary {
  background: #27ae60;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-secondary {
  background: #95a5a6;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: #3498db;
  color: #fff;
  margin-right: 4px;
}

.btn-small.btn-danger {
  background: #e74c3c;
}

.col-actions {
  white-space: nowrap;
}

/* LOGIN */
.login-page {
  background: #f0f2f5;
  min-height: 100vh;
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 48px;
  min-height: calc(100vh - 52px);
  box-sizing: border-box;
}

.login-box {
  background: #fff;
  padding: 28px 24px;
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.login-box h2 {
  margin: 0 0 8px;
}

.login-desc {
  margin: 0 0 18px;
  color: #555;
  font-size: 0.95rem;
}

.login-label {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: #333;
}

.login-box input,
.login-box button[type="submit"] {
  width: 100%;
  padding: 10px;
  margin-top: 0;
  box-sizing: border-box;
  font-size: 16px;
}

.login-box input {
  border: 1px solid #ccc;
  border-radius: 6px;
}

.login-box button[type="submit"] {
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 18px;
}

.login-box button[type="submit"]:hover {
  background: #219a52;
}

.login-err {
  color: #e74c3c;
  margin-top: 10px;
}

@media (max-width: 768px) {
  .table-wrap {
    padding: 12px 8px 24px;
  }

  .data-table th,
  .data-table td {
    padding: 9px 10px;
    font-size: 13px;
  }

  .portal-title {
    font-size: 28px;
  }

  .portal-nav {
    flex-direction: column;
    align-items: stretch;
  }
}

/* PORTAL – strona startowa inteligentnego miasta */
.page-portal {
  min-height: 100vh;
  overflow: hidden;
}

.portal-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.portal-nav-btn {
  display: inline-block;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
}

.portal-nav-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.portal-bg {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(10, 30, 60, 0.75), rgba(20, 80, 120, 0.55)),
    url("../img/miasto-tlo.jpg") center/cover no-repeat,
    linear-gradient(160deg, #0a2540 0%, #1a5276 45%, #2e86ab 100%);
  z-index: 0;
}

.portal-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.08), transparent 55%);
  z-index: 1;
  pointer-events: none;
}

.portal-content {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 20px 32px;
  box-sizing: border-box;
  text-align: center;
  color: #fff;
}

.portal-title {
  margin: 0 0 10px;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.portal-subtitle {
  margin: 0 0 28px;
  font-size: 16px;
  max-width: 520px;
  opacity: 0.92;
  line-height: 1.5;
}

.portal-cta {
  display: inline-block;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  color: #0a2540;
  background: #fff;
  border: none;
  border-radius: 10px;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.portal-cta:hover {
  background: #f0f4f8;
}

.portal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  width: 100%;
  max-width: 720px;
}

.portal-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 240px;
  flex: 1 1 260px;
  max-width: 340px;
  padding: 20px 22px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  text-decoration: none;
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.portal-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.portal-card-icon {
  font-size: 28px;
}

.portal-card-label {
  font-size: 18px;
  font-weight: 700;
}

.portal-card-desc {
  font-size: 13px;
  opacity: 0.88;
  line-height: 1.4;
  text-align: left;
}

/* ZAKŁADKI sekcji aktywne */
.section-tabs {
  display: flex;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

.section-tab {
  display: inline-block;
  padding: 10px 20px;
  background: #e4e8ec;
  color: #444;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #cfd6dd;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  margin-right: 4px;
}

.section-tab.active {
  background: #f0f2f5;
  color: #2c3e50;
  border-color: #dde1e6;
}

.section-tab:hover:not(.active) {
  background: #eef1f4;
}

.data-table tbody tr.row-link {
  cursor: pointer;
}

/* MAPA */
.page-map {
  background: #f0f2f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-map #map {
  flex: 1;
  min-height: calc(100vh - 120px);
  width: 100%;
  z-index: 1;
}

.map-hint {
  margin: 0;
  padding: 8px 16px 14px;
  text-align: center;
  font-size: 13px;
  color: #666;
  background: #f0f2f5;
}

.map-popup {
  min-width: 200px;
  max-width: 260px;
}

.map-popup h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #222;
}

.map-popup-row {
  margin: 0 0 6px;
  font-size: 14px;
}

.map-popup-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.map-add-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: #444;
}

.map-add-form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.leaflet-popup-content {
  margin: 12px 14px;
}

.map-marker-wrap {
  background: transparent;
  border: none;
}

.map-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
}

.map-marker-lamp {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-bottom: 3px;
  border: 2px solid #fff;
  box-shadow: 0 0 8px rgba(255, 140, 0, 0.9);
}

.map-marker-lamp.on {
  background: #ff8c00;
}

.map-marker-lamp.off {
  background: #95a5a6;
  box-shadow: none;
}

.map-marker-sign {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.road-sign-img {
  width: 44px;
  height: 44px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

.map-popup-meta {
  margin: 0 0 8px;
  font-size: 12px;
  color: #666;
}

.sign-picker-fieldset {
  border: none;
  margin: 0 0 10px;
  padding: 0;
}

.sign-picker-fieldset legend {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.sign-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sign-picker-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 2px solid #dde1e6;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.sign-picker-opt:hover {
  border-color: #3498db;
}

.sign-picker-opt--selected {
  border-color: #3498db;
  background: #eef6fc;
}

.sign-picker-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sign-picker-graphic {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sign-picker-graphic .road-sign-img {
  width: 40px;
  height: 40px;
}

.sign-picker-label {
  font-size: 12px;
  line-height: 1.3;
  color: #333;
}

.admin-form-full {
  grid-column: 1 / -1;
}

/* SZCZEGÓŁY PRZEJŚCIA */
.detail-box {
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.detail-header {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.detail-marker-preview .map-marker {
  transform: scale(1.2);
}

.detail-title {
  margin: 0 0 6px;
  font-size: 24px;
  color: #222;
}

.detail-meta {
  margin: 0 0 10px;
  color: #666;
  font-size: 14px;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.detail-stat {
  background: #f7f9fb;
  border: 1px solid #e8ecf0;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.detail-stat-label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.detail-stat-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
  color: #2c3e50;
  font-variant-numeric: tabular-nums;
}

.detail-stat-small {
  font-size: 18px;
}

.detail-actions {
  padding-top: 8px;
}
