/* ============================================================
   TAK Server – Web View Styles
   Dark theme with accent colors
   ============================================================ */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --accent: #0f3460;
  --highlight: #16213e;
  --border: #2a2a4a;
  --blue: #4a90d9;
  --red: #e74c3c;
  --green: #27ae60;
  --yellow: #f1c40f;
  --orange: #e67e22;
  --white: #ffffff;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-primary);
  color: var(--text-primary);
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- #app root ---- */
#app {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Navigation Bar
   ============================================================ */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  min-height: 48px;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-bar .nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-bar .nav-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
}

.nav-bar .nav-info {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.nav-bar .nav-info .connection-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-bar .nav-info .connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.nav-bar .nav-info .connection-dot.disconnected {
  background: var(--red);
}

.nav-bar .nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-bar .nav-user .user-name {
  font-size: 13px;
  color: var(--text-secondary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links .nav-link {
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  background: none;
  border: none;
  font-family: inherit;
}

.nav-links .nav-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-links .nav-link.active {
  background: var(--accent);
  color: var(--white);
}

/* ============================================================
   Main Content – flex row: sidebar + map
   ============================================================ */
.main-content {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: 350px;
  min-width: 350px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--blue);
  font-size: 14px;
}

.sidebar-header .title {
  font-size: 15px;
  font-weight: 600;
}

/* Tabs inside sidebar */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.sidebar-tabs .tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.sidebar-tabs .tab:hover {
  color: var(--text-secondary);
}

.sidebar-tabs .tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.sidebar-tab-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ============================================================
   Panels (collapsible sections)
   ============================================================ */
.panel {
  border-bottom: 1px solid var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.panel-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.panel-header .panel-chevron {
  font-size: 10px;
  transition: transform 0.2s;
}

.panel-header .panel-chevron.collapsed {
  transform: rotate(-90deg);
}

.panel-content {
  padding: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.panel-content.collapsed {
  max-height: 0 !important;
  padding: 0;
}

/* ============================================================
   Contacts List
   ============================================================ */
.contacts-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.contacts-list .contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.contacts-list .contact-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.contacts-list .contact-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.contacts-list .contact-item .status-dot.online {
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
}

.contacts-list .contact-item .status-dot.offline {
  background: var(--text-muted);
}

.contacts-list .contact-item .contact-info {
  flex: 1;
  min-width: 0;
}

.contacts-list .contact-item .contact-callsign {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contacts-list .contact-item .contact-type {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contacts-list .contact-item .contact-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.contacts-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   Chat Panel
   ============================================================ */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---- Room / Channel Selector ---- */
.chat-rooms {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
  scrollbar-width: thin;
}

.chat-room-tab {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.chat-room-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.chat-room-tab.active {
  background: var(--accent);
  color: var(--white);
  border-color: var(--blue);
}

.new-channel-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--blue);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.new-channel-btn:hover {
  background: rgba(74, 144, 217, 0.1);
  border-color: var(--blue);
}

/* ---- Messages Area ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* ---- Individual Message ---- */
.chat-message {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: 8px;
  max-width: 90%;
}

.chat-message.own {
  align-self: flex-end;
  background: var(--accent);
}

.chat-message .chat-message-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-message .chat-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
}

.chat-message.own .chat-sender {
  color: var(--green);
}

.chat-message .chat-time {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-message .chat-text {
  font-size: 13px;
  color: var(--text-primary);
  word-wrap: break-word;
  line-height: 1.4;
}

/* ---- Input Row ---- */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chat-input-row .chat-input-field {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input-row .chat-input-field:focus {
  border-color: var(--blue);
}

.chat-input-row .chat-input-field::placeholder {
  color: var(--text-muted);
}

.chat-input-row .chat-send-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.chat-input-row .chat-send-btn:hover {
  background: var(--blue);
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   Missions Panel
   ============================================================ */
.missions-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.missions-list .mission-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.12s;
}

.missions-list .mission-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mission-item .mission-name {
  font-size: 14px;
  font-weight: 500;
}

.mission-item .mission-meta {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.missions-toolbar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.missions-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.missions-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---- Missions Toolbar ---- */
.missions-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.missions-toolbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Mission Card (list item) ---- */
.mission-card {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.12s;
  list-style: none;
}

.mission-card:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mission-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mission-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mission-card-name:hover {
  color: var(--blue);
}

.mission-card-desc {
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-sub-btn {
  flex-shrink: 0;
}

/* ---- Mission Detail View ---- */
.mission-detail {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mission-detail-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.mission-detail-desc {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

/* ---- Mission Sections (subscribers, contents, changes) ---- */
.mission-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.mission-section-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.mission-section-body {
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
}

/* ---- Subscriber items ---- */
.mission-subscriber-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.mission-subscriber-item:last-child {
  border-bottom: none;
}

.subscriber-uid {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.subscriber-role {
  font-size: 11px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* ---- Content items ---- */
.mission-content-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.mission-content-item:last-child {
  border-bottom: none;
}

.content-filename {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-meta {
  font-size: 11px;
}

/* ---- Change log items ---- */
.mission-change-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.mission-change-item:last-child {
  border-bottom: none;
}

.change-type {
  font-weight: 600;
  font-size: 12px;
  color: var(--blue);
  text-transform: uppercase;
  flex-shrink: 0;
}

.change-creator {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.change-time {
  font-size: 11px;
  flex-shrink: 0;
}

/* ---- Create Mission Modal ---- */
.create-mission-modal .form-group {
  margin-bottom: 16px;
}

.create-mission-modal .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.create-mission-modal .form-group input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.create-mission-modal .form-group input:focus {
  border-color: var(--blue);
}

/* ============================================================
   Map Container
   ============================================================ */
.map-container {
  flex: 1;
  position: relative;
  min-width: 0;
}

.map-container .ol-map {
  width: 100%;
  height: 100%;
}

/* Map popup overlay */
.map-popup {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  z-index: 10;
}

.map-popup::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--bg-secondary);
}

.map-popup .popup-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.map-popup .popup-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
}

.map-popup .popup-close:hover {
  color: var(--text-primary);
}

.map-popup .popup-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
}

.map-popup .popup-row .popup-label {
  color: var(--text-muted);
}

.map-popup .popup-row .popup-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Marker label on the map */
.marker-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 6px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================================
   Login Form
   ============================================================ */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: var(--bg-primary);
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-card .login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.login-card .login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-card .form-group {
  margin-bottom: 18px;
}

.login-card .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-card .form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.login-card .form-group input:focus {
  border-color: var(--blue);
}

.login-card .form-group input::placeholder {
  color: var(--text-muted);
}

.login-card .login-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  margin-bottom: 14px;
  min-height: 20px;
}

.login-card .login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--white);
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.login-card .login-btn:hover {
  background: var(--blue);
}

.login-card .login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-primary);
}

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

.dashboard-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.dashboard-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.dashboard-tabs .tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.dashboard-tabs .tab:hover {
  color: var(--text-secondary);
}

.dashboard-tabs .tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* Dashboard tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.data-table tbody tr {
  transition: background 0.12s;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.data-table .actions {
  display: flex;
  gap: 6px;
}

.table-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue);
  border-color: var(--blue);
}

.btn-danger {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: #c0392b;
  border-color: #c0392b;
}

.btn-success {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

.btn-success:hover:not(:disabled) {
  background: #219a52;
  border-color: #219a52;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* ============================================================
   Modal Overlay
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-header .modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-header .modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body .form-group {
  margin-bottom: 16px;
}

.modal-body .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.modal-body .form-group input,
.modal-body .form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus {
  border-color: var(--blue);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  min-width: 260px;
  max-width: 400px;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.25s ease;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.removing {
  opacity: 0;
  transform: translateX(100%);
}

.toast.success {
  background: var(--green);
  color: var(--white);
}

.toast.error {
  background: var(--red);
  color: var(--white);
}

.toast.info {
  background: var(--accent);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

.toast .toast-message {
  flex: 1;
}

/* ============================================================
   Status Bar
   ============================================================ */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  min-height: 28px;
  padding: 0 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.status-bar .status-left,
.status-bar .status-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-bar .status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-bar .status-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-bar .status-indicator .dot.connected {
  background: var(--green);
}

.status-bar .status-indicator .dot.disconnected {
  background: var(--red);
}

.status-bar .status-indicator .dot.connecting {
  background: var(--yellow);
  animation: pulse 1s infinite;
}

/* ============================================================
   Utility & Animations
   ============================================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

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

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-2 {
  margin-bottom: 8px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ============================================================
   Scrollbar Styling
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   Responsive – sidebar collapses on mobile
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 28px;
    width: 300px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex !important;
  }

  .nav-links {
    display: none;
  }
}

@media (min-width: 769px) {
  .sidebar-toggle {
    display: none !important;
  }
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  display: none;
}

/* ============================================================
   Role Badges
   ============================================================ */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.role-badge.role-admin {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

.role-badge.role-manager {
  background: rgba(230, 126, 34, 0.2);
  color: #e67e22;
}

.role-badge.role-dispatcher {
  background: rgba(74, 144, 217, 0.2);
  color: #4a90d9;
}

.role-badge.role-device {
  background: rgba(39, 174, 96, 0.2);
  color: #27ae60;
}

/* ============================================================
   Checkbox Group (for group assignment in modals)
   ============================================================ */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.12s;
}

.checkbox-label:hover {
  background: rgba(255, 255, 255, 0.05);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ============================================================
   Member List (for groups modal)
   ============================================================ */
.member-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-primary);
  transition: background 0.12s;
}

.member-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.member-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

/* ============================================================
   Map Controls (top-right button group)
   ============================================================ */
.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.map-control-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.map-control-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--blue);
}

/* ============================================================
   Overlay Panel (floating, positioned on the map)
   ============================================================ */
.overlay-panel {
  position: absolute;
  top: 12px;
  right: 56px;
  width: 260px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.overlay-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.overlay-panel-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.overlay-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}

.overlay-panel-close:hover {
  color: var(--text-primary);
}

.overlay-panel-body {
  padding: 10px 14px;
  overflow-y: auto;
  flex: 1;
}

.overlay-list {
  margin-bottom: 10px;
}

.overlay-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.12s;
}

.overlay-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.overlay-item-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.overlay-item-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.overlay-item-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overlay-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.overlay-item-remove:hover {
  color: var(--red);
  background: rgba(231, 76, 60, 0.1);
}

.overlay-import-btn {
  width: 100%;
  margin-top: 4px;
}

/* ============================================================
   Draw Toolbar (floating toolbar on the map)
   ============================================================ */
.draw-toolbar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.draw-tool-group {
  display: flex;
  gap: 2px;
}

.draw-tool-btn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.draw-tool-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.draw-tool-btn.active {
  background: var(--accent);
  color: var(--white);
  border-color: var(--blue);
}

.draw-color-wrap {
  display: flex;
  align-items: center;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.draw-color-label {
  cursor: pointer;
  display: flex;
  align-items: center;
}

.draw-color-input {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  background: none;
}

.draw-color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.draw-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* ============================================================
   Certificate Status Badges
   ============================================================ */
.cert-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cert-status.valid {
  background: rgba(39, 174, 96, 0.2);
  color: #27ae60;
}

.cert-status.revoked {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

/* Revoked certificate row styling */
.data-table tbody tr.cert-revoked td {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(231, 76, 60, 0.4);
}

.data-table tbody tr.cert-revoked td .cert-status,
.data-table tbody tr.cert-revoked td .actions,
.data-table tbody tr.cert-revoked td code {
  text-decoration: none;
}

/* ============================================================
   Federation Status Badges
   ============================================================ */
.fed-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.fed-status.enabled {
  background: rgba(39, 174, 96, 0.2);
  color: #27ae60;
}

.fed-status.disabled {
  background: rgba(108, 108, 128, 0.2);
  color: var(--text-muted);
}

/* ============================================================
   Code/Hash Styling in Tables
   ============================================================ */
.data-table code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Monaco, monospace;
  font-size: 11px;
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text-secondary);
}
