/**
 * Common styles for backend templates.
 * Matches Tailwind CSS design tokens used in the frontend.
 */

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, sans-serif;
  background: #f9fafb; /* gray-50 */
  color: #111827; /* gray-900 */
  line-height: 1.6;
}

:root {
  --color-primary-purple: #4b236a;
  --color-primary-purple-80: #6e4e87;
  --color-primary-purple-60: #9079a4;
  --color-primary-purple-40: #b3a3c0;
  --color-primary-purple-20: #d5cedd;
  --color-primary-purple-5: #efeef2;
  --color-primary-green: #f9f6fd;

  --color-status-success: #28a745;
  --color-status-danger: #dc3545;
  --color-status-warning: #ffc107;
  --color-status-info: #17a2b8;

  --color-white: #ffffff;
  --color-black: #000000;
  --color-secondary: #007dff;
  --color-secondary-dark: #54595e;
  --color-secondary-light: #abb5be;

  --color-gray-100: #f8f9fa;
  --color-gray-200: #e9ecef;
  --color-gray-300: #dee2e6;
  --color-gray-400: #ced4da;
  --color-gray-500: #adb5bd;
  --color-gray-600: #6c757d;
  --color-gray-700: #495057;
  --color-gray-800: #343a40;
  --color-gray-900: #212529;
}

/* ── App Navigation ──────────────────────────────────────────────────────── */
.app-nav {
  background: #4b236a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-brand { display: flex; align-items: center; }
.nav-logo { height: 32px; width: auto; filter: brightness(0) invert(1); }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 6px;
  color: rgba(255,255,255,0.75); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.2); color: #fff; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.nav-user-icon { font-size: 20px; opacity: 0.8; }
.nav-user-profile { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; border-radius: 6px; padding: 4px 8px; }
.nav-user-profile:hover { background: rgba(255,255,255,0.12); }
.nav-username { opacity: 0.9; }
.nav-logout {
  color: rgba(255,255,255,0.7); text-decoration: none;
  font-size: 20px; transition: color 0.15s;
}
.nav-logout:hover { color: #ff7675; }

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.header h1 {
  font-size: 24px; /* text-2xl */
  font-weight: 700; /* font-bold */
  color: #111827; /* text-gray-900 */
  margin-bottom: 10px;
}

/* Back Link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6b7280; /* gray-500 */
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 12px;
}

.back-link:hover {
  color: #2563eb; /* blue-600 */
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #6b7280; /* gray-500 */
}

.stat-value {
  font-weight: 600;
  color: #111827; /* gray-900 */
}

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-search {
  margin-left: auto;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-search input {
  width: 240px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 6px;
  font-size: 14px;
  color: #111827;
  background: var(--color-white);
}

.filter-search input:focus {
  outline: none;
  border-color: var(--color-primary-purple-60);
  box-shadow: 0 0 0 3px var(--color-primary-purple-10);
}

.filter-note {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb; /* gray-200 */
  font-size: 12px;
  color: #6b7280; /* gray-500 */
  text-align: right;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn,
.range-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 16px;
  border: 1px solid var(--color-primary-purple-40);
  background: var(--color-white);
  color: #111827;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover,
.range-btn:hover {
  background: var(--color-primary-purple-5);
  border-color: var(--color-primary-purple-60);
}

.filter-btn.active,
.range-btn.active {
  background: var(--color-primary-purple);
  color: var(--color-white);
  border-color: var(--color-primary-purple);
}

/* Display Mode Switch */
.display-mode-switch {
  position: relative;
}

.display-mode-btn {
  border: 1px solid var(--color-primary-purple-60);
  background: var(--color-primary-purple-5);
  color: #111827;
}

.display-mode-btn:hover {
  background: #e7e2ed;
}

.display-mode-caret {
  font-size: 11px;
  color: #374151;
}

.display-mode-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: white;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  z-index: 20;
  display: none;
  overflow: hidden;
}

.display-mode-menu.open {
  display: block;
}

.display-mode-option {
  width: 100%;
  border: none;
  background: white;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  text-align: left;
}

.display-mode-option:hover {
  background: #f3f4f6; /* gray-100 */
}

.display-mode-option.active {
  background: #ede9fe; /* purple-100 */
  color: #4c1d95; /* purple-900 */
}

.display-mode-check {
  width: 14px;
  color: #5b21b6; /* purple-800 */
  opacity: 0;
}

.display-mode-option.active .display-mode-check {
  opacity: 1;
}

.display-mode-option-icon {
  width: 14px;
}

/* Tags Grid */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* Tag Card */
.tag-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  padding-bottom: 44px; /* reserve space for telemetry icons */
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition:
    box-shadow 0.2s,
    transform 0.2s;
  cursor: pointer;
}

.icon-btn {
  border: 1px solid #d1d5db; /* gray-300 */
  background: #ffffff;
  color: #374151; /* gray-700 */
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #f3f4f6; /* gray-100 */
  border-color: #9ca3af; /* gray-400 */
}

.tag-card .refresh-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

.actions-col {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.tag-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.tag-row {
  cursor: pointer;
}

.tag-row:hover {
  background: #f9fafb; /* gray-50 */
}

/* Tag Header */
.tag-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.equipment-name {
  font-size: 16px;
  font-weight: 600;
  color: #111827; /* gray-900 */
  margin-bottom: 4px;
}

.equipment-name.unassigned {
  color: #dc2626; /* red-600 */
}

.tag-mac {
  font-size: 13px;
  color: #6b7280; /* gray-500 */
}

.mac-address {
  font-family: monospace;
}

.equipment-id {
  font-size: 13px;
  color: #6b7280; /* gray-500 */
}

/* Badges */
.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
  line-height: 1;
}

.badge-small {
  min-height: 18px;
  padding: 2px 6px;
  font-size: 10px;
}

.badge-interested {
  background: #ede9fe; /* purple-100 */
  color: #5b21b6; /* purple-800 */
}

.badge-assigned {
  background: #d1fae5; /* green-100 */
  color: #065f46; /* green-800 */
}

.badge-unassigned {
  background: #fee2e2; /* red-100 */
  color: #991b1b; /* red-800 */
}

.badge-inactive {
  background: #e5e7eb; /* gray-200 */
  color: #374151; /* gray-700 */
}

/* Tag Info */
.tag-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb; /* gray-200 */
}

.info-item {
  font-size: 13px;
}

.info-label {
  color: #6b7280; /* gray-500 */
  margin-bottom: 2px;
}

.info-value {
  color: #111827; /* gray-900 */
  font-weight: 500;
}

/* Location */
.location {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: #f9fafb; /* gray-50 */
  border-radius: 4px;
  margin-top: 12px;
  font-size: 13px;
}

.location-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-icon {
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: #6b7280; /* gray-500 */
}

.location-subtext {
  color: #6b7280; /* gray-500 */
}

.gateway-subtext {
  font-size: 13px;
  color: #6b7280; /* gray-500 */
  margin-top: 2px;
}

/* Tags List View */
.tags-table-wrapper {
  margin-top: 12px;
  overflow-x: auto;
}

.tags-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.tags-table th,
.tags-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb; /* gray-200 */
  vertical-align: middle;
}

.tags-table th {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280; /* gray-500 */
  text-transform: uppercase;
}

.tags-table td {
  font-size: 14px;
  color: #111827; /* gray-900 */
}

/* Equipment Section */
.equipment-section {
  padding: 16px;
  background: #f9fafb; /* gray-50 */
  border-radius: 6px;
  margin-bottom: 16px;
}

/* Cards */
.current-location-card,
.heatmap-card,
.history-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

/* Section Title */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827; /* gray-900 */
  margin-bottom: 16px;
}

/* Location Info */
.location-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Status Badges */
.status-pill,
.status-active,
.status-inactive,
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
}

.status-active,
.status-badge.active {
  background: #d1fae5; /* green-100 */
  color: #065f46; /* green-800 */
}

.status-inactive {
  background: #fee2e2; /* red-100 */
  color: #991b1b; /* red-800 */
}

.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
}

.status-badge.past {
  background: #e5e7eb; /* gray-200 */
  color: #374151; /* gray-700 */
}

/* Telemetry Icons (signal, battery, power) */
.telemetry-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.telemetry-icons-kanban {
  position: absolute;
  left: 12px;
  bottom: 10px;
}

.telemetry-icons-list {
  margin-top: 8px;
}

.telemetry-icons-detail {
  margin-top: -6px;
  margin-bottom: 12px;
}

.telemetry-icon {
  font-size: 19px;
  line-height: 1;
  color: #6b7280; /* gray-500 */
}

.telemetry-signal-l0,
.telemetry-battery-l0 {
  color: #9ca3af; /* gray-400 */
}

.telemetry-signal-l1,
.telemetry-battery-l1 {
  color: #ef4444; /* red-500 */
}

.telemetry-signal-l2,
.telemetry-battery-l2 {
  color: #f59e0b; /* amber-500 */
}

.telemetry-signal-l3,
.telemetry-battery-l3 {
  color: #3b82f6; /* blue-500 */
}

.telemetry-signal-l4,
.telemetry-battery-l4 {
  color: #10b981; /* emerald-500 */
}

.telemetry-power-inactive {
  color: #9ca3af; /* gray-400 */
}

.telemetry-power-standby {
  color: #3b82f6; /* blue-500 */
}

.telemetry-power-active {
  color: #f59e0b; /* amber-500 */
}

/* Heatmap */
.heatmap-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.period-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151; /* gray-700 */
  text-align: center;
}

.echarts-container {
  width: 100%;
  height: 400px;
  margin-top: 16px;
  background: #f9f9f9;
  border: 1px solid #e5e7eb; /* gray-200 */
  border-radius: 4px;
  overflow: hidden;
}

.movement-cloud-legend {
  margin-top: 10px;
  border: 1px solid #e5e7eb; /* gray-200 */
  border-radius: 6px;
  padding: 8px 10px;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}

.movement-cloud-legend-title {
  font-size: 12px;
  font-weight: 600;
  color: #374151; /* gray-700 */
  margin-bottom: 6px;
}

.movement-cloud-legend-subtitle {
  font-size: 11px;
  color: #92400e; /* amber-800 */
  margin-bottom: 6px;
}

.movement-cloud-legend-empty {
  font-size: 12px;
  color: #6b7280; /* gray-500 */
}

.movement-cloud-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  cursor: pointer;
}

.legend-item-swatch {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid #d1d5db; /* gray-300 */
}

.legend-item-label {
  font-size: 12px;
  color: #374151; /* gray-700 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* History Table */
.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.history-table th,
.history-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb; /* gray-200 */
}

.history-table th {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280; /* gray-500 */
  text-transform: uppercase;
}

.history-table td {
  font-size: 14px;
  color: #111827; /* gray-900 */
}

.history-table tr:hover {
  background: #f9fafb; /* gray-50 */
}

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

.duration-cell {
  font-family: monospace;
}

.gateway-name {
  font-size: 12px;
  color: #6b7280; /* gray-500 */
  margin-top: 2px;
}

/* Pagination Controls */
.pagination-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.pagination-controls label {
  font-size: 14px;
  color: #374151; /* gray-700 */
}

.pagination-controls select {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 6px;
  margin-left: 8px;
  font-size: 14px;
  line-height: 1.2;
  background-color: white;
  cursor: pointer;
}

.pagination-controls select:hover {
  border-color: #9ca3af; /* gray-400 */
}

.export-dropdown {
  position: relative;
}

.export-btn {
  border: 1px solid #d1d5db; /* gray-300 */
  background: #ffffff;
  color: #374151; /* gray-700 */
}

.export-btn:hover {
  background: #f3f4f6; /* gray-100 */
  border-color: #9ca3af; /* gray-400 */
}

.export-menu {
  position: absolute;
  top: calc(100% - 1px);
  right: 0;
  min-width: 170px;
  background: #ffffff;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  display: none;
  z-index: 30;
}

.export-dropdown:hover .export-menu,
.export-dropdown:focus-within .export-menu {
  display: block;
}

.export-menu-item {
  display: block;
  padding: 9px 12px;
  color: #374151; /* gray-700 */
  text-decoration: none;
  font-size: 14px;
}

.export-menu-item:hover {
  background: #f3f4f6; /* gray-100 */
}

.pagination-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid #e5e7eb; /* gray-200 */
  margin-top: 12px;
}

.pagination-link {
  color: #2563eb; /* blue-600 */
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 4px;
  background: white;
  font-size: 14px;
  transition: background-color 0.2s;
}

.pagination-link:hover {
  background: #f3f4f6; /* gray-100 */
  border-color: #9ca3af; /* gray-400 */
}

.pagination-info {
  font-size: 14px;
  color: #6b7280; /* gray-500 */
}

/* Tooltip */
.tooltip {
  position: absolute;
  background: #111827; /* gray-900 */
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 16px;
  color: #6b7280; /* gray-500 */
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .header {
    padding: 16px;
  }

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

  .tag-info {
    grid-template-columns: 1fr;
  }

  .location-info {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    width: 100%;
    justify-content: space-between;
  }

  .filter-search input {
    width: 100%;
  }

  .display-mode-btn {
    padding: 8px 10px;
  }

  .history-table {
    font-size: 12px;
  }

  .history-table th,
  .history-table td {
    padding: 8px;
  }

  .echarts-container {
    height: 320px;
  }

  .stats-grid { grid-template-columns: 1fr; }
  .nav-links  { display: none; }
}

/* ── Monitor Screen ──────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-card-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-card-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-card-icon.purple { background: #f3e8ff; color: #7c3aed; }

.stat-card-label { font-size: 13px; color: #6b7280; margin-bottom: 4px; }
.stat-card-value { font-size: 28px; font-weight: 700; color: #111827; line-height: 1; }

.section {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 24px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
}

.section-header .section-title { font-size: 15px; margin-bottom: 0; }
.section-header-actions { display: flex; gap: 10px; align-items: center; }

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }

.data-table thead th {
  padding: 10px 16px;
  background: #f9fafb;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.data-table tbody tr {
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}

.data-table tbody tr:hover    { background: #fafafa; }
.data-table tbody tr.clickable { cursor: pointer; }

.data-table td {
  padding: 10px 16px;
  font-size: 14px;
  color: #374151;
  vertical-align: middle;
}

.data-table td.mono  { font-family: monospace; color: #6b7280; font-size: 13px; }
.data-table td.muted { color: #9ca3af; }

.empty-row td { text-align: center; color: #9ca3af; padding: 32px; }

.inline-edit {
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  font-family: inherit;
  color: #111827;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
}

.inline-edit:hover { border-color: #d1d5db; background: #f9fafb; }
.inline-edit:focus { outline: none; border-color: #4b236a; background: #fff; }
.inline-edit.text-right { text-align: right; }

.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary         { background: #4b236a; color: #fff; }
.btn-primary:hover   { background: #6e4e87; }
.btn-secondary       { background: #f3f4f6; color: #374151; }
.btn-secondary:hover { background: #e5e7eb; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 4px;
  font-size: 18px;
  border-radius: 4px;
  transition: color 0.15s;
}

.btn-icon:hover    { color: #4b236a; }
.btn-icon.spinning { animation: spin 0.8s linear infinite; }

.refresh-status { font-size: 12px; color: #9ca3af; display: flex; align-items: center; gap: 6px; }
.refresh-dot    { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; animation: pulse 2s infinite; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-title { font-size: 16px; font-weight: 600; color: #111827; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: #9ca3af;
  padding: 2px;
}

.modal-close:hover { color: #374151; }
.modal-body { padding: 20px 24px; }

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.detail-row:last-child { border-bottom: none; }
.detail-label          { font-weight: 500; color: #6b7280; }
.detail-value          { color: #111827; text-align: right; }
.detail-value.mono     { font-family: monospace; font-size: 13px; }
.detail-value code     { font-family: monospace; font-size: 11px; word-break: break-all; }

.filter-row {
  padding: 12px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-input {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.filter-input:focus { border-color: #4b236a; }
.filter-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #374151; cursor: pointer; }

.device-model-subtext { font-size: 11px; color: #9ca3af; margin-top: 2px; padding-left: 8px; }

.usage-icon          { font-size: 18px; }
.usage-icon-active   { color: #f59e0b; }
.usage-icon-standby  { color: #3b82f6; }
.usage-icon-inactive { color: #9ca3af; }

@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Login Screen ────────────────────────────────────────────────────────── */

body.login {
  background: #f0edf5;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  display: block;
  margin: 0 auto 16px;
  height: 128px;
  width: auto;
}

.login-header .subtitle {
  font-size: 14px;
  color: #6c757d;
  margin-top: 4px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(75, 35, 106, 0.12);
  padding: 36px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: #111827;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-group input:focus {
  border-color: #4b236a;
  box-shadow: 0 0 0 3px rgba(75, 35, 106, 0.1);
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: #4b236a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.btn-login:hover    { background: #6e4e87; }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

.error-box {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #b91c1c;
  font-size: 14px;
}

.error-box.hidden { display: none; }

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: #9ca3af;
}

.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* ── Profile page ─────────────────────────────────────────────────────────── */
.profile-wrapper { max-width: 640px; margin: 40px auto; padding: 0 20px; }
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; }
.profile-avatar-icon { font-size: 64px; color: #4b236a; line-height: 1; }
.profile-title { font-size: 24px; font-weight: 700; color: #1a1a2e; margin: 0; }
.profile-username { font-size: 14px; color: #6c757d; margin-top: 4px; }
.profile-card { background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(75,35,106,0.12); padding: 36px; }
.profile-section-title { font-size: 16px; font-weight: 600; color: #1a1a2e; margin: 0 0 20px; }
.profile-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.profile-divider { border: none; border-top: 1px solid #e9ecef; margin: 28px 0; }
.profile-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 28px; }
.btn-secondary-action { color: #6c757d; text-decoration: none; font-size: 14px; }
.btn-secondary-action:hover { color: #4b236a; }
.input-disabled { background: #f8f9fa; color: #6c757d; cursor: not-allowed; }
.field-hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.profile-alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 20px; }
.profile-alert.hidden { display: none; }
.profile-alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.profile-alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

@media (max-width: 480px) {
  .profile-field-row { grid-template-columns: 1fr; }
}
