* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
  color: #1a1a2e;
}

/* ===== Сайдбар ===== */

#sidebar {
  width: 360px;
  min-width: 360px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s ease;
}

body.sidebar-hidden #sidebar {
  transform: translateX(-100%);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  padding: 10px 12px;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  transition: left 0.25s ease;
}

body.sidebar-hidden .sidebar-toggle {
  display: block;
}

.sidebar-auth {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.sidebar-auth .auth-user {
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
}

.sidebar-auth .auth-user-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sidebar-auth .auth-role {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-auth .auth-role.role-admin {
  background: #e8f0ff;
  color: #2f4bb6;
}

.sidebar-auth .auth-role.role-counterparty {
  background: #e8f8ef;
  color: #1d7a49;
}

.sidebar-auth .auth-role.role-readonly {
  background: #f2f3f5;
  color: #5c6573;
}

.sidebar-auth .auth-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: #4361ee;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
}

.filters {
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.filters select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fafafa;
  color: #333;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.filters select:focus {
  border-color: #4361ee;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 0;
}

.filter-checkbox input {
  accent-color: #e74c3c;
}

.driver-contacts {
  padding: 10px 20px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.85rem;
}

.driver-contacts a {
  display: block;
  margin-top: 5px;
  color: #4361ee;
  text-decoration: none;
}

#bunker-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

#bunker-list li {
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s;
  border-bottom: 1px solid #f5f5f5;
}

#bunker-list li:hover {
  background: #f0f4ff;
}

.bunker-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bunker-info {
  flex: 1;
  min-width: 0;
}

.bunker-number {
  font-weight: 600;
  font-size: 0.9rem;
}

.bunker-address {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 0.8rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
}

.bunker-location {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bunker-filled-at {
  flex-shrink: 0;
  color: #b04732;
  font-style: italic;
}

.bunker-fill-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ===== Кнопки ===== */

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #4361ee;
  color: #fff;
}

.btn-primary:hover {
  background: #3a56d4;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

.btn-danger {
  background: #e74c3c;
  color: #fff;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

.btn-icon:hover {
  color: #333;
}

/* ===== Карта ===== */

#map {
  flex: 1;
  height: 100vh;
}

/* ===== Модальное окно ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.hidden {
  display: none !important;
}


.login-error {
  padding: 8px 0;
  color: #e74c3c;
  font-size: 0.85rem;
}

.modal-login {
  width: 320px;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

#bunker-form {
  padding: 16px 20px 20px;
}

.form-row {
  margin-bottom: 12px;
}

.form-row label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

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

.form-row-header label {
  margin-bottom: 0;
}

.form-row .form-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-row .form-checkbox input {
  width: auto;
  padding: 0;
  border: 0;
  accent-color: #4361ee;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: #4361ee;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.form-actions .btn {
  flex: 1;
}

/* ===== Цвета заполненности ===== */

.fill-green {
  background: #12b76a;
  color: #fff;
}

.fill-blue {
  background: #0ba5ec;
  color: #fff;
}

.fill-orange {
  background: #f79009;
  color: #fff;
}

.fill-red {
  background: #f04438;
  color: #fff;
}

.indicator-green {
  background: #12b76a;
}

.indicator-blue {
  background: #0ba5ec;
}

.indicator-orange {
  background: #f79009;
}

.indicator-red {
  background: #f04438;
}

/* ===== Balloon (popup) на карте ===== */

.balloon-content {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  min-width: 220px;
}

.balloon-content h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #1a1a2e;
}

.balloon-content .balloon-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.balloon-content .balloon-label {
  color: #888;
}

.balloon-content .balloon-value {
  font-weight: 600;
}

.balloon-content .balloon-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
}

.balloon-content .balloon-actions button {
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.balloon-content .balloon-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Мобильные устройства ===== */

@media (max-width: 768px) {
  body,
  #map {
    height: 100dvh;
  }

  #sidebar {
    width: 85%;
    min-width: 280px;
    height: 100dvh;
    max-height: 100dvh;
    position: fixed;
    left: 0;
    top: 0;
  }

  #bunker-list {
    padding-bottom: 88px;
    scroll-padding-bottom: 88px;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(88px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-toggle {
    padding: 12px 14px;
    font-size: 0.85rem;
  }
}
