:root {
  color-scheme: light;
  font-family: 'Open Sans', sans-serif;
}

body {
  margin: 0;
  background: #f0f2f5;
  color: #999999;
  font-family: 'Open Sans', sans-serif;
  font-size: 13px;
  line-height: 1.42857143;
}

.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 16px 16px;
}

.v2-content {
  max-width: none;
  margin: 0;
  padding-top: 16px;
}

.page-content {
  padding: 0;
}

.login-card {
  max-width: 420px;
  margin: 40px auto;
  border-radius: 3px;
}

.card {
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 0;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: none;
}

.login-card h2 {
  font-family: 'Oswald', sans-serif;
  font-size: 26px;
  margin-top: 0;
  color: #555555;
}

.form,
.inline-form {
  display: grid;
  gap: 12px;
}

.inline-form {
  grid-template-columns: 1fr auto auto;
  align-items: end;
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
select,
button {
  padding: 8px 10px;
  border-radius: 0;
  border: 1px solid #d1d5db;
  font-size: 14px;
}

button {
  cursor: pointer;
  background: #472f91;
  color: white;
  border: none;
}

button:hover,
button:focus {
  background: #6049a6;
}

.toolbar {
  display: none;
}

.toolbar button {
  background: #36246f;
}

.toolbar button:hover,
.toolbar button:focus {
  background: #6049a6;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  padding: 12px;
}

.stat-card h4 {
  margin: 0;
  color: #7a7a7a;
  font-size: 12px;
  text-transform: uppercase;
}

.stat-card p {
  margin: 8px 0 0;
  font-size: 24px;
  color: #472f91;
  font-weight: 700;
}

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

.map-controls-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-check {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.section-spacer {
  margin-top: 14px;
}

.route-add-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.location-add-form {
  grid-template-columns: 1.2fr 1fr 2fr auto;
}

.reports-form {
  grid-template-columns: 1fr 1.2fr 1fr 1fr auto auto;
}

.notifications-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.notifications-tools-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.notifications-table-wrap {
  width: 100%;
  overflow: auto;
  max-height: 62vh;
  border: 1px solid #e5e5e5;
  background: #ffffff;
}

.notifications-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.notifications-table th,
.notifications-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #ececec;
  text-align: left;
  vertical-align: top;
}

.notifications-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f8fb;
  color: #4b5563;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.03em;
}

.notifications-table td {
  color: #374151;
}

.notifications-table td:nth-child(1) {
  width: 190px;
  white-space: nowrap;
  color: #6b7280;
}

.notifications-table td:nth-child(2) {
  width: 200px;
  color: #111827;
  font-weight: 600;
}

.notifications-table td:nth-child(3) {
  white-space: normal;
  word-break: break-word;
}

.notifications-table-empty td {
  text-align: center;
  color: #6b7280;
}

.full-width {
  grid-column: 1 / -1;
}

.split-view {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
}

.map {
  height: 460px;
  border: 1px solid #e5e5e5;
  border-radius: 0;
  overflow: hidden;
}

.devices-view {
  position: relative;
  min-height: calc(100vh - 140px);
}

.devices-map {
  height: calc(100vh - 140px);
}

.devices-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100vh - 164px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d9d9d9;
  padding: 10px;
  overflow: auto;
  z-index: 1000;
}

.devices-overlay.collapsed {
  display: none;
}

.devices-overlay-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1001;
}

.devices-view.overlay-collapsed .devices-overlay-toggle {
  right: 12px;
}

.devices-view:not(.overlay-collapsed) .devices-overlay-toggle {
  right: min(372px, calc(100% - 12px));
}

.devices-form {
  grid-template-columns: 1fr;
}

.devices-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.devices-tab {
  background: #e5e7eb;
  color: #374151;
  border: 1px solid #d1d5db;
}

.devices-tab.active {
  background: #472f91;
  color: #ffffff;
}

.devices-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.devices-controls {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.devices-route-form {
  margin-top: 10px;
}

.devices-route-form h4 {
  margin: 0;
  font-size: 13px;
  color: #555555;
}

.devices-route-form .inline-check {
  font-size: 13px;
}

.playback-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.device-history-list {
  max-height: 320px;
  margin-top: 10px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow: auto;
  border: 1px solid #f0f0f0;
  border-radius: 0;
}

.list li {
  padding: 10px;
  border-bottom: 1px solid #f3f4f6;
}

.list li:last-child {
  border-bottom: 0;
}

#chatMessagesList {
  display: grid;
  gap: 10px;
  padding: 12px;
  max-height: 420px;
  background: #f8fafc;
}

#chatMessagesList .chat-empty {
  text-align: center;
  color: #6b7280;
  border: 0;
  padding: 20px 10px;
}

#chatMessagesList .chat-unread-divider,
#ChatBoxBody .chat-unread-divider {
  text-align: center;
  font-size: 11px;
  color: #472f91;
  font-weight: 700;
  border: 0;
  margin: 2px 0;
}

#chatMessagesList .chat-msg-item,
#ChatBoxBody li {
  display: grid;
  gap: 4px;
  border: 0;
  padding: 0;
  margin: 0;
}

#chatMessagesList .chat-msg-meta,
#ChatBoxBody .chat-msg-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 11px;
  color: #6b7280;
}

#chatMessagesList .chat-msg-who,
#ChatBoxBody .chat-msg-who {
  font-weight: 700;
  color: #475569;
}

#chatMessagesList .chat-msg-time,
#ChatBoxBody .chat-msg-time {
  opacity: 0.9;
}

#chatMessagesList .chat-msg-bubble,
#ChatBoxBody .chat-msg-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}

#chatMessagesList .chat-msg-in,
#ChatBoxBody .chat-msg-in {
  justify-items: start;
}

#chatMessagesList .chat-msg-in .chat-msg-bubble,
#ChatBoxBody .chat-msg-in .chat-msg-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #111827;
}

#chatMessagesList .chat-msg-out,
#ChatBoxBody .chat-msg-out {
  justify-items: end;
}

#chatMessagesList .chat-msg-out .chat-msg-bubble,
#ChatBoxBody .chat-msg-out .chat-msg-bubble {
  background: #472f91;
  border: 1px solid #3f2787;
  color: #ffffff;
}

.chat-send-form {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.chat-send-form textarea,
#NewMessageInput {
  resize: vertical;
  min-height: 44px;
  line-height: 1.35;
}

.messages {
  min-height: 24px;
  font-size: 14px;
}

#viewNotifications,
#viewBodega,
#viewNayax,
#viewChat {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

#viewZones,
#viewUsers {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

#viewDevices {
  display: block;
}

#viewBodega,
#viewNayax {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#viewBodega.hidden,
#viewNayax.hidden,
#viewChat.hidden,
#viewNotifications.hidden {
  display: none !important;
}

#viewZones.hidden,
#viewUsers.hidden {
  display: none !important;
}

#viewDevices.hidden {
  display: none !important;
}

.msg-error {
  color: #b91c1c;
}

.msg-success {
  color: #166534;
}

.hidden {
  display: none;
}

.session-info {
  font-size: 13px;
  color: #ffffff;
}

#topbar .topbar-main ul.nav.navbar-top-links li > a {
  color: #ffffff;
}

#topbar .topbar-main ul.nav.navbar-top-links li > a:hover {
  color: #ffffff;
  background: #6049a6;
}

#topbar .topbar-main ul.nav.navbar-top-links li > a {
  min-width: 42px;
  text-align: center;
}

#topbar .topbar-main .news-update-box {
  float: left;
  color: #ffffff;
  font-size: 12px;
  line-height: 50px;
  opacity: 0.9;
  margin-left: 8px;
}

#topbar .badge {
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  padding: 0 4px;
}

#wrapper #sidebar {
  transition: none;
}

#side-menu > li > a {
  cursor: pointer;
}

#side-menu > li.active > a,
#side-menu > li > a:hover {
  background: #6049a6 !important;
  color: #ffffff !important;
}

#side-menu > li.active > a i .icon-bg,
#side-menu > li > a:hover i .icon-bg {
  opacity: 0.65;
}

#side-menu > li > a i {
  width: 16px;
}

#footer {
  text-align: center;
  color: #999999;
  font-size: 11px;
  margin: 10px 0 20px;
}

#chat-form {
  position: fixed;
  right: 0;
  top: 50px;
  width: 280px;
  height: calc(100vh - 50px);
  background: #f7f7f8;
  border-left: 1px solid #d7d8da;
  z-index: 2100;
  display: none;
}

#chat-form.open {
  display: block;
}

#chat-form .chat-inner {
  height: 100%;
  overflow: auto;
}

#chat-form .chat-group {
  padding: 10px 12px;
  border-bottom: 1px solid #ebedef;
}

#chat-form .chat-group-item {
  display: block;
  padding: 6px 0;
  color: #4b5d67;
  text-decoration: none;
}

#chat-form .chat-group-item:hover {
  color: #472f91;
}

#chat-box {
  position: fixed;
  right: 280px;
  top: 90px !important;
  width: 360px;
  height: 420px;
  background: #ffffff;
  border: 1px solid #d7d8da;
  z-index: 2200;
  display: none;
}

#chat-box.open {
  display: block;
}

#ChatBoxBody {
  margin: 0;
  padding: 10px;
  height: 320px;
  overflow: auto;
  list-style: none;
  background: #f8fafc;
}

#ChatBoxBody li {
  margin-bottom: 10px;
}

#NewMessageInput {
  width: 100%;
}

#page-wrapper h3 {
  color: #555555;
  margin-top: 0;
}

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

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }
}

.bodega-form {
  grid-template-columns: 2fr 1fr 1fr auto;
  margin-bottom: 10px;
}

@media (max-width: 980px) {
  .split-view,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .devices-map {
    height: calc(100vh - 190px);
  }

  .devices-overlay {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 10px;
    background: #ffffff;
    transform: none !important;
  }

  .devices-overlay-toggle {
    position: static;
    margin-top: 10px;
  }

  .devices-view:not(.overlay-collapsed) .devices-overlay-toggle {
    right: auto;
  }

  #viewBodega,
  #viewNayax {
    grid-template-columns: 1fr;
  }

  .route-add-form {
    grid-template-columns: 1fr;
  }

  .location-add-form,
  .reports-form {
    grid-template-columns: 1fr;
  }

  .map {
    height: 360px;
  }

  #chat-form {
    width: 100%;
  }

  #chat-box {
    right: 0;
    width: 100%;
  }
}
