:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #eef4fa;
  --line: #d7e1ec;
  --text: #102542;
  --muted: #58708a;
  --primary: #0d6e6e;
  --primary-dark: #084f50;
  --danger: #b73b4c;
  --warning: #c6841a;
  --shadow: 0 24px 60px rgba(16, 37, 66, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Bahnschrift", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(13, 110, 110, 0.12), transparent 35%),
    linear-gradient(180deg, #f9fbfe 0%, var(--bg) 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0c2134 0%, #102542 100%);
  color: #f7fbff;
  padding: 28px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 18px 18px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.brand-kicker,
.eyebrow {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: #8fb3d6;
  margin-bottom: 8px;
}

.menu {
  display: grid;
  gap: 8px;
}

.menu-link {
  display: block;
  padding: 13px 16px;
  border-radius: 16px;
  color: #d8e7f6;
  transition: 0.2s ease;
}

.menu-link:hover,
.menu-link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateX(4px);
}

.page {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1,
.card h2 {
  margin: 0;
}

.topbar-actions,
.stack-inline,
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
  display: grid;
  box-shadow: var(--shadow);
}

.user-chip span,
.muted,
small {
  color: var(--muted);
}

.button {
  border: 0;
  background: linear-gradient(135deg, var(--primary) 0%, #1d8d8d 100%);
  color: #fff;
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(13, 110, 110, 0.18);
}

.button:hover {
  transform: translateY(-1px);
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.button-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #d74c60 100%);
}

.sidebar-toggle {
  display: none;
}

.card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(215, 225, 236, 0.9);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card-centered {
  text-align: center;
  max-width: 640px;
  margin: 40px auto;
}

.content-grid {
  display: grid;
  gap: 22px;
}

.content-grid.cols-2 {
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stats-grid.compact {
  margin: 16px 0 24px;
}

.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  color: var(--muted);
  margin-bottom: 12px;
}

.stat-value {
  font-size: 2rem;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 12px 14px;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(13, 110, 110, 0.18);
  border-color: var(--primary);
}

.field-full {
  grid-column: 1 / -1;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-inline input {
  width: auto;
}

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

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

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

.table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.text-right {
  text-align: right;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.list-item.stretch {
  align-items: flex-start;
}

.stack {
  display: grid;
  gap: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge-online {
  background: rgba(15, 140, 108, 0.14);
  color: #0f8c6c;
}

.badge-offline {
  background: rgba(183, 59, 76, 0.12);
  color: var(--danger);
}

.badge-pending,
.badge-pendente {
  background: rgba(198, 132, 26, 0.12);
  color: var(--warning);
}

.alert {
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.alert-success {
  background: rgba(15, 140, 108, 0.12);
  color: #0d735b;
}

.alert-error {
  background: rgba(183, 59, 76, 0.12);
  color: #903241;
}

.json-block {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.82rem;
}

.realtime-divider {
  height: 1px;
  background: var(--line);
  margin: 24px 0;
}

.table-live tbody tr {
  transition: background 0.2s ease;
}

.table-live tbody tr:hover {
  background: rgba(13, 110, 110, 0.04);
}

.table-row-alert td {
  background: rgba(198, 132, 26, 0.08);
}

.realtime-clock-card,
.realtime-activity-item {
  align-items: center;
}

.empty-state {
  padding: 18px 8px;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 20;
    transition: left 0.25s ease;
    width: min(310px, 90vw);
  }

  .sidebar.is-open {
    left: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 14px;
    padding: 10px 14px;
  }

  .content-grid.cols-2,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page {
    padding: 18px;
  }

  .topbar,
  .card-header,
  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

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