* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: #f9fafb;
  color: #1f2933;
}

body.checkin-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.checkin-page .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.appbar {
  background: #111827;
}

.appbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.appbar-inner-center {
  justify-content: center;
}

.brand {
  color: #f9fafb;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.brand-dot {
  color: #eab308;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.page-head {
  margin-bottom: 28px;
}

.sound-toggle {
  width: auto;
  margin-top: 12px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #6b7280;
}

.sound-toggle.active {
  background: #fefce8;
  border-color: #fde68a;
  color: #92400e;
}

h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.subtitle {
  color: #6b7280;
  font-size: 0.9rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 6px;
  margin-top: 18px;
}

select, input, button {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #1f2933;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

select:disabled {
  cursor: not-allowed;
}

select:focus, input:focus {
  outline: none;
  border-color: #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.15);
}

button {
  margin-top: 28px;
  background: #eab308;
  border: 1px solid #eab308;
  color: #1f2933;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

button:active:not(:disabled) {
  background: #ca8a04;
  border-color: #ca8a04;
}

.link-button {
  width: auto;
  margin-top: 0;
  padding: 0;
  background: none;
  border: none;
  color: #ca8a04;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

.auto-guard {
  width: 100%;
  margin-top: 18px;
  padding: 16px;
  border-radius: 10px;
  background: #fefce8;
  border: 1px solid #fde68a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auto-guard span {
  font-weight: 600;
  color: #78350f;
}

.corner-logout {
  position: absolute;
  top: 20px;
  right: 20px;
  width: auto;
  white-space: nowrap;
  margin-top: 0;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #6b7280;
  border-radius: 999px;
}

.corner-logout:active {
  background: #f3f4f6;
}

.add-name-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 1rem;
}

.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.status {
  margin-top: 20px;
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  font-weight: 600;
  display: none;
}

.status.ok {
  background: #dcfce7;
  color: #166534;
  display: block;
}

.status.error {
  background: #fee2e2;
  color: #991b1b;
  display: block;
}

.status.pending {
  background: #fef9c3;
  color: #854d0e;
  display: block;
}

.checkin-card {
  position: relative;
  margin-bottom: 0;
  padding: 28px 24px;
}

.checkin-card h1 {
  margin-bottom: 16px;
}

.checkpoint-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fefce8;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 7px 14px 7px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.checkpoint-chip svg {
  flex-shrink: 0;
}

.container.wide {
  max-width: 1000px;
}

nav.topnav {
  display: flex;
  gap: 22px;
}

nav.topnav a {
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}

nav.topnav a.active {
  color: #f9fafb;
  border-bottom-color: #eab308;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.status-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.status-card.warning {
  border-color: #fde68a;
  background: #fffdf5;
}

.status-card.critical {
  border-color: #fecaca;
  background: #fef2f2;
}

.status-card .name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 14px;
}

.status-card .detail {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 12px;
}

.status-card .detail div + div {
  margin-top: 3px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}

/* Status palette — fixed, never reused for anything but state. */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0ca30c;
  flex-shrink: 0;
}

.dot.warning {
  background: #fab219;
}

.dot.critical {
  background: #d03b3b;
}

.status-text {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
}

.badge-new-device {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef9c3;
  color: #854d0e;
  vertical-align: middle;
}

.floor-map {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4 / 3;
  background: #f3f4f6;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  margin: 0 auto 32px;
}

.admin-floor-map {
  cursor: crosshair;
  margin-bottom: 12px;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 0.9rem;
  text-align: center;
  padding: 20px;
}

.map-pin-wrap {
  position: absolute;
  transform: translate(-50%, -50%);
}

.map-pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  padding: 0;
  background: #0ca30c;
}

.map-pin.warning {
  background: #fab219;
}

.map-pin.critical {
  background: #d03b3b;
}

.map-pin.unplaced {
  background: #9ca3af;
}

.map-pin.selected {
  outline: 3px solid #eab308;
  outline-offset: 2px;
}

.map-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 10;
}

/* Pins near the map's left/right edge would otherwise center a tooltip half off-screen. */
.map-pin-wrap.align-start .map-tooltip {
  left: 0;
  transform: none;
}

.map-pin-wrap.align-end .map-tooltip {
  left: auto;
  right: 0;
  transform: none;
}

.map-tooltip.active {
  display: block;
}

.map-pin-wrap:hover .map-tooltip {
  display: block;
}

.map-tooltip-name {
  font-weight: 700;
}

.map-tooltip-status {
  color: #d1d5db;
  margin-top: 2px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.15;
}

.stat-label {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 2px;
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: #f3f4f6;
  margin-top: 12px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: #0ca30c;
}

.meter-fill.warning {
  background: #fab219;
}

.meter-fill.critical {
  background: #d03b3b;
}

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

.filters label {
  margin-top: 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.pagination button {
  width: auto;
  margin-top: 0;
  padding: 8px 16px;
  font-size: 0.85rem;
  background: #ffffff;
  border-color: #e5e7eb;
  color: #1f2933;
}

.pagination button:disabled {
  color: #d1d5db;
}

.page-info {
  font-size: 0.85rem;
  color: #6b7280;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

th, td {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid #e5e7eb;
}

th {
  color: #6b7280;
  font-weight: 600;
  background: #fafaf9;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

tbody tr:hover {
  background: #fefce8;
}

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

td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: #374151;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  border-left: 3px solid #eab308;
  padding-left: 10px;
  margin: 36px 0 14px;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.inline-form input {
  width: auto;
  flex: 1;
  min-width: 140px;
}

.inline-form button {
  width: auto;
  margin-top: 0;
  padding: 10px 18px;
}

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

.row-actions button {
  width: auto;
  margin-top: 0;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: #f3f4f6;
  border-color: #e5e7eb;
  white-space: nowrap;
}

.row-actions button:disabled {
  opacity: 0.5;
}

.row-actions button.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

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