.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.2;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition),
    transform var(--transition);
}

.btn:hover {
  background: var(--bg-page);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-gradient);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow), 0 0 0 0 rgba(33, 121, 199, 0);
}

.btn-primary:hover {
  box-shadow: var(--shadow-md), 0 0 0 3px rgba(33, 121, 199, 0.15);
  transform: translateY(-1px);
}

.btn-danger {
  background: #fff;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

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

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

input.input,
select.input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--bg-surface);
  color: var(--text);
  transition: box-shadow var(--transition), border-color var(--transition);
}

input.input:focus,
select.input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light), 0 0 0 1px var(--accent) inset;
  border-color: var(--accent);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 13px;
}

table.data-table th {
  text-align: left;
  padding: 11px 14px;
  background: #f8fafc;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

table.data-table th.sortable:hover {
  color: var(--accent);
}

table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

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

table.data-table tbody tr {
  transition: background var(--transition);
}

table.data-table tbody tr:hover {
  background: var(--accent-light);
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 14px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.online {
  background: var(--online);
  box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.15);
  animation: status-pulse 2.4s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--offline);
}

@keyframes status-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.15);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(12, 163, 12, 0.08);
  }
}

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

.device-name-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.device-name-link:hover {
  text-decoration: underline;
}

.modal.modal-wide {
  width: 600px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  row-gap: 10px;
  column-gap: 12px;
}

.detail-row {
  /* Makes this wrapper generate no box of its own, so its two <span> children
     become direct grid items of .detail-grid — without this, .detail-row
     itself is what the grid places into alternating columns, zigzagging
     label/value pairs across rows instead of aligning them as a table. */
  display: contents;
}

.detail-label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-top: 2px;
}

.detail-value {
  font-size: 14px;
  word-break: break-all;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 28, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: backdrop-in 120ms ease-out;
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: 420px;
  max-width: 90vw;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 160ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

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

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

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

.error-banner {
  background: #fdecec;
  border: 1px solid #f3b7b7;
  color: var(--danger-dark);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

#toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 180ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.error {
  background: var(--danger-dark);
}
