:root {
  --ink: #1a2a34;
  --muted: #5d7080;
  --line: #d5e0e6;
  --paper: #f3f6f8;
  --sea: #12344a;
  --teal: #0e6e68;
  --teal-dark: #0a5853;
  --ok: #0d7a45;
  --off: #b42318;
  --shadow: 0 10px 30px rgba(18, 52, 74, 0.08);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

body.page-auth {
  background: #e7eef2;
}

body.page-auth main.page {
  min-height: 100vh;
  padding: 0;
}

body.page-app main.page {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
}

.auth-aside {
  flex: 1.1;
  padding: 4rem 3rem;
  color: #f4f8fb;
  background-color: var(--sea);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
}

.aside-kicker {
  margin: 0 0 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: #9fd8cf;
}

.auth-aside h1 {
  max-width: 14ch;
  font-size: 2.4rem;
  line-height: 1.15;
  margin: 0 0 1rem;
}

.auth-aside p {
  max-width: 36ch;
  color: #d5e4ee;
}

.auth-panel {
  flex: 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.auth-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
}

.muted,
.page-head p,
.empty,
.next-step,
.app-footer {
  color: var(--muted);
}

.auth-form {
  margin-top: 1.25rem;
}

.btn-teal {
  width: 100%;
  margin-top: 0.25rem;
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 600;
}

.btn-teal:hover,
.btn-teal:focus {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  color: #fff;
}

.field-error {
  color: var(--off);
  font-size: 0.875rem;
  margin-top: 0.35rem;
}

.dev-hint {
  margin: 1rem 0 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.85rem;
}

.alert {
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  background: var(--sea);
  color: #fff;
}

.topbar-start {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.topnav {
  display: flex;
  gap: 0.15rem;
}

.topnav a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
}

.topnav a:hover,
.topnav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  display: inline-block;
  background: #3ddc97;
  box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.18);
}

.topbar-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.company-pill,
.role-pill {
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.82rem;
}

.company-pill {
  background: rgba(255, 255, 255, 0.12);
}

.role-pill {
  background: #0e6e68;
}

.who {
  font-size: 0.92rem;
}

.logout-form {
  margin: 0;
}

.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
}

.btn-ghost:hover,
.btn-ghost:focus {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.page-head h1,
.panel-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.page-head {
  margin-bottom: 1rem;
}

.page-head p {
  margin: 0.25rem 0 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.org-grid {
  margin-bottom: 1rem;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.95rem 1rem;
}

.stat b {
  display: block;
  font-size: 1.6rem;
  line-height: 1.2;
}

.stat span {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat.online b {
  color: var(--ok);
}

.stat.offline b {
  color: var(--off);
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

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

.panel .table {
  margin: 0;
}

.panel .table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

.empty {
  margin: 0;
  padding: 1.25rem 1.15rem;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-online {
  background: #e7f6ee;
  color: var(--ok);
}

.status-offline {
  background: #fdecea;
  color: var(--off);
}

.status-unknown {
  background: #eef2f4;
  color: #5f7280;
}

.next-step,
.app-footer {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

.page-head.with-action {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0.7rem 0 0;
}

.quick-links a {
  font-weight: 600;
}

.btn-teal.btn-inline,
.btn-quiet.btn-inline,
a.btn {
  width: auto;
  margin-top: 0;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.btn-small {
  width: auto;
  margin: 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-quiet {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-quiet:hover,
.btn-quiet:focus {
  background: var(--paper);
  color: var(--ink);
}

.btn-danger {
  background: #fff;
  color: var(--off);
  border: 1px solid #f0c2be;
}

.btn-danger:hover,
.btn-danger:focus {
  background: #fdecea;
  color: var(--off);
}

.form-card {
  max-width: 40rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.4rem;
}

.field-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.4rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.row-actions form {
  margin: 0;
}

.you {
  margin-left: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

tr.is-inactive td {
  color: var(--muted);
}

.exchange {
  padding: 1rem 1.15rem 1.15rem;
  margin: 0 0 1rem;
}

.exchange h2 {
  margin: 0;
  font-size: 1.05rem;
}

.exchange-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-top: 0.85rem;
}

.exchange-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin: 0;
}

.exchange-form .form-label {
  margin: 0;
}

.exchange-file {
  font: inherit;
  font-size: 0.88rem;
  max-width: 16rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 0 0 1rem;
}

.filter-field {
  min-width: 11rem;
  flex: 1 1 11rem;
}

.filter-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.location-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  align-items: center;
  margin: 0.55rem 0 0.75rem;
}

.location-status {
  margin: 0;
}

.location-status.is-error {
  color: var(--off);
}

button.btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.coord-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.55rem 0;
  font-size: 0.92rem;
}

.switch {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  font-weight: 600;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 1.4rem;
  border-radius: 999px;
  background: #c5d0d6;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--teal);
}

.switch input:checked + .switch-track::after {
  transform: translateX(1.1rem);
}

.switch input:focus + .switch-track {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.switch input:disabled + .switch-track {
  opacity: 0.45;
}

.device-detail {
  display: grid;
  grid-template-columns: 16rem 1fr;
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.25rem;
}

.photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.device-photo {
  display: block;
  width: 100%;
  max-height: 16rem;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 0.75rem;
  background: #fff;
}

.photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 10rem;
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: #fff;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1.25rem;
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
}

.detail-list div {
  min-width: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.detail-list dd {
  margin: 0;
}

.map-canvas {
  height: 32rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #d9e3ea;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.map-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.leaflet-div-icon.pin-wrap {
  background: transparent;
  border: 0;
}

.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(18, 52, 74, 0.35);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.pin-online { background: var(--ok); }
.pin-offline { background: var(--off); }
.pin-unknown { background: #6b7c85; }

.popup-photo {
  display: block;
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.35rem;
}

.popup-when {
  color: #5d7080;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .device-detail,
  .detail-list,
  .coord-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .auth-shell {
    flex-direction: column;
  }

  .auth-aside {
    padding: 2rem 1.25rem 1.5rem;
  }

  .auth-aside h1 {
    font-size: 1.8rem;
  }
}

