@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap");

:root {
  --bg: #f6f6f2;
  --panel: #ffffff;
  --ink: #1f2d3d;
  --accent: #146c94;
  --border: #d9e2ec;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", "Segoe UI", sans-serif;
  font-size: 15px;
  background: radial-gradient(circle at 20% 10%, #d9edf7 0%, var(--bg) 35%);
  color: var(--ink);
}

.topbar {
  background: #ffffff;
  color: #1c2632;
  border-bottom: 1px solid #dde5ee;
  box-shadow: 0 4px 16px rgba(9, 26, 42, 0.05);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 1%;
  margin: 0 auto;
}

.brand {
  color: #1c2632;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  width: 220px;
  max-width: 100%;
  height: auto;
}

.menu {
  display: flex;
  gap: 16px;
  align-items: center;
}

.menu a {
  color: #233142;
  text-decoration: none;
  font-weight: 600;
}

.menu a.active {
  color: #e5252a;
}

.menu-dropdown {
  position: relative;
}

.menu-dropdown summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: #233142;
  padding: 6px 0;
}

.menu-dropdown summary::-webkit-details-marker {
  display: none;
}

.menu-dropdown[open] summary,
.menu-dropdown summary:hover {
  color: #e5252a;
}

.menu-dropdown.active summary {
  color: #e5252a;
}

.menu-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 260px;
  z-index: 30;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(8, 28, 49, 0.1);
  padding: 8px;
  display: grid;
  gap: 2px;
}

.menu-dropdown-panel a {
  padding: 8px 10px;
  border-radius: 8px;
}

.menu-dropdown-panel a:hover {
  background: #f5f9ff;
}

.menu-dropdown-panel a.active {
  background: #f5f9ff;
  color: #e5252a;
}

.menu-subtitle {
  margin-top: 6px;
  padding: 7px 10px 4px;
  font-size: 0.8rem;
  color: #5a6a7c;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.menu a:hover {
  color: #e5252a;
}

.subsection-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.subsection-nav .button-secondary.active {
  border-color: #146c94;
  color: #146c94;
  background: #eef7fc;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
}

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

.topbar .container {
  margin: 0 auto;
}

.topbar .container.topbar-inner {
  padding: 1% !important;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.smarttrack-users-table {
  min-width: 860px;
}

.smarttrack-users-table th:nth-child(1),
.smarttrack-users-table td:nth-child(1) {
  min-width: 300px;
}

.smarttrack-users-table th:nth-child(2),
.smarttrack-users-table td:nth-child(2) {
  min-width: 230px;
}

.smarttrack-users-table th:nth-child(3),
.smarttrack-users-table td:nth-child(3) {
  min-width: 110px;
}

.smarttrack-users-table th:nth-child(4),
.smarttrack-users-table td:nth-child(4) {
  min-width: 180px;
}

.smarttrack-users-actions-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.smarttrack-users-actions-row form {
  margin: 0;
}

.smarttrack-users-actions-row .button-secondary {
  white-space: nowrap;
}

.users-live-filter-input {
  min-width: 280px;
}

.users-state-filter-select {
  min-width: 150px;
}

.status-pill-button {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  line-height: 1;
}

.status-pill-button.status-ok {
  border-color: #b7e4c2;
}

.status-pill-button.status-no {
  border-color: #f0c3c0;
  text-decoration: none;
}

.auth-wrap {
  max-width: 420px;
}

.auth-card {
  display: grid;
  gap: 10px;
}

.hidden-input {
  display: none;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.upload-summary {
  margin: 8px 0;
  font-weight: 600;
}

.upload-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.upload-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfdff;
}

.remove-file {
  border: 1px solid #f1b9b9;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--danger);
  padding: 6px 10px;
  cursor: pointer;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(10, 35, 66, 0.06);
}

h1 {
  margin-top: 0;
  font-size: 1.7rem;
}

.dashboard-head p {
  margin-top: 0;
  color: #4c5c70;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.dashboard-module-block {
  margin-bottom: 14px;
}

.dashboard-module-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.dashboard-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(10, 35, 66, 0.06);
}

.dashboard-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.dashboard-card p {
  margin: 0;
  color: #55667b;
}

.dashboard-go {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #146c94;
}

.placeholder-card {
  max-width: 760px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
}

.vehicle-detail-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.vehicle-detail-link:hover {
  color: #0f4f6b;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="file"],
input:not([type]),
textarea,
select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
}

button,
.link-button {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.button-secondary {
  display: inline-block;
  border: 1px solid #d1dbe6;
  border-radius: 10px;
  padding: 10px 16px;
  background: #f8fafc;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.alert {
  border: 1px solid #f5c2c7;
  border-radius: 10px;
  padding: 12px;
  background: #fff5f5;
  color: var(--danger);
  margin-bottom: 16px;
}

.alert.success {
  border-color: #b8e7c6;
  background: #effcf3;
  color: #1d7a3b;
}

.alert-text {
  color: var(--danger);
  font-size: 0.92rem;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.inline-form input {
  width: 140px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.filter-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.admin-search-form input[type="search"] {
  width: min(420px, 100%);
}

.permissions-box {
  grid-column: 1 / -1;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.permission-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafcff;
}

.permission-item span {
  line-height: 1.3;
}

.pagination-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.users-footer-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.users-per-page-form {
  margin: 12px 0 0;
}

.users-per-page-form label {
  font-weight: 600;
}

.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.status-ok {
  background: #e9f8ef;
  color: #1f7a3a;
}

.status-no {
  background: #fff1f1;
  color: #b42318;
  border: 1px solid #f0c3c0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.smarttrack-form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  align-items: center;
}

.smarttrack-form-actions button,
.smarttrack-form-actions .button-secondary {
  min-height: 44px;
  white-space: nowrap;
}

.actions-row form {
  margin: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.equipment-step3-form {
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.equipment-devices-box,
.equipment-users-box,
.equipment-new-user-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fcfdff;
}

.equipment-devices-box {
  grid-column: 1 / -1;
}

.equipment-users-box {
  display: grid;
  gap: 8px;
}

.equipment-users-stats {
  font-size: 0.86rem;
  color: #526377;
}

.equipment-users-checklist {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.equipment-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.equipment-user-item:hover {
  background: #f5f9ff;
  border-color: #dfe9f6;
}

.equipment-user-item span {
  word-break: break-all;
  line-height: 1.25;
}

.equipment-devices-table {
  width: 100%;
  table-layout: fixed;
}

.equipment-step3-devices-table .col-imei,
.equipment-step3-devices-table .col-sim {
  width: 50%;
}

.equipment-step2-table {
  width: 100%;
  table-layout: fixed;
}

.equipment-step2-table .col-index {
  width: 72px;
}

.equipment-step2-table .col-imei {
  width: 42%;
}

.equipment-step2-table .col-sim {
  width: 50%;
}

.equipment-step2-table input[type="text"] {
  width: 100%;
  min-width: 0;
}

.equipment-step2-form .equipment-step2-wrap {
  grid-column: 1 / -1;
}

.equipment-users-box,
.equipment-new-user-box {
  grid-column: auto;
}

.equipment-step2-table td,
.equipment-step2-table th,
.equipment-devices-table td,
.equipment-devices-table th {
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.detail-grid > div {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.equipment-assigned-users {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.log-box {
  max-height: 65vh;
  overflow: auto;
}

.log-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 0.84rem;
  padding: 2px 0;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(18, 27, 39, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
}

.busy-overlay.hidden {
  display: none;
}

.busy-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(7, 19, 33, 0.2);
}

.busy-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.busy-message {
  margin-bottom: 12px;
  color: #3c4d63;
}

.busy-progress {
  height: 9px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
}

.busy-progress-bar {
  display: block;
  height: 100%;
  width: 45%;
  border-radius: inherit;
  background: linear-gradient(90deg, #146c94, #23a7d8);
  animation: busy-loading 1.1s ease-in-out infinite;
}

@keyframes busy-loading {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(260%);
  }
}

@media (max-width: 860px) {
  .container {
    margin: 18px auto;
    padding: 0 12px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .topbar-inner {
    min-height: auto;
    padding: 10px 0;
    align-items: flex-start;
    flex-direction: column;
  }

  .menu {
    width: 100%;
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }

  .menu > a,
  .menu-dropdown summary {
    display: block;
    width: 100%;
    padding: 8px 0;
  }

  .menu-dropdown-panel {
    position: static;
    min-width: 0;
    box-shadow: none;
    border-radius: 10px;
    margin-top: 6px;
  }

  .brand-logo {
    width: 184px;
  }

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

  .upload-actions {
    flex-direction: column;
  }

  .upload-actions .button-secondary,
  .upload-actions button,
  .actions-row .button-secondary,
  .actions-row button,
  .actions-row .link-button {
    width: 100%;
    text-align: center;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form input {
    width: 100%;
  }

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

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

  .filter-actions {
    align-items: stretch;
  }

  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-search-form {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .admin-search-form input[type="search"],
  .admin-search-form .button-secondary,
  .admin-toolbar .link-button {
    width: 100%;
    text-align: center;
  }

  .filter-actions button,
  .filter-actions .button-secondary {
    width: 100%;
    text-align: center;
  }

  .records-table {
    min-width: 720px;
  }

  .equipment-step2-table {
    table-layout: auto;
  }

  .records-table .hide-mobile {
    display: none;
  }

  .pagination-row {
    justify-content: stretch;
  }

  .users-footer-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-row .button-secondary {
    flex: 1;
    text-align: center;
  }

  .equipment-step3-form .smarttrack-form-actions {
    align-items: stretch;
  }

  .equipment-step3-form .smarttrack-form-actions button,
  .equipment-step3-form .smarttrack-form-actions .button-secondary {
    width: 100%;
    text-align: center;
  }

  .stack-table thead {
    display: none;
  }

  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
    width: 100%;
  }

  .stack-table tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 10px;
    background: #fff;
  }

  .stack-table td {
    border: none;
    padding: 6px 0;
  }

  .stack-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.8rem;
    color: #5a6a7c;
    margin-bottom: 2px;
    font-weight: 600;
  }
}
