:root {
  --bg-app: #f4f6fa;
  --bg-panel: #ffffff;
  --sidebar: #0c0f14;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-text: #c8d0dc;
  --sidebar-muted: #7a8494;
  --accent: #3b6cff;
  --accent-hover: #2957e6;
  --text: #12151c;
  --muted: #5c6370;
  --border: #e4e8f0;
  --danger: #dc2626;
  --success: #059669;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 28px rgba(16, 24, 40, 0.08);
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.admin-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.login-root {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59, 108, 255, 0.18), transparent),
    radial-gradient(900px 500px at 90% 110%, rgba(20, 184, 166, 0.12), transparent),
    var(--bg-app);
}

.login-card {
  width: min(420px, 100%);
  background: var(--bg-panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2rem 1.75rem;
  border: 1px solid var(--border);
  animation: loginIn 0.45s ease;
}

@keyframes loginIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.login-card p.lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.form-field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-field input:focus {
  outline: none;
  border-color: rgba(59, 108, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(59, 108, 255, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  margin-top: 0.25rem;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: #f8fafc;
}

.login-msg {
  margin-top: 1rem;
  font-size: 0.875rem;
  min-height: 1.25rem;
}

.login-msg.err {
  color: var(--danger);
}

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

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem !important;
  }
  .sidebar-brand {
    flex: 1;
    min-width: 140px;
  }
  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    width: 100%;
    padding-top: 0.5rem;
    border-top: 1px solid var(--sidebar-border);
  }
  .sidebar-footer {
    width: 100%;
    border-top: none !important;
    padding-top: 0.5rem !important;
  }
}

.sidebar {
  background: linear-gradient(180deg, #0c0f14 0%, #121722 100%);
  color: var(--sidebar-text);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  padding: 0.35rem 0.65rem;
  margin-bottom: 1.25rem;
}

.sidebar-brand span.tag {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(59, 108, 255, 0.2);
  color: #b8ccff;
  vertical-align: middle;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #fff;
  background: rgba(59, 108, 255, 0.18);
}

.nav-icon {
  opacity: 0.85;
  font-size: 1rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.8rem;
  color: var(--sidebar-muted);
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.top-bar-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.content-scroll {
  padding: 1.25rem 1.5rem 2rem;
  flex: 1;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-card .label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-card .value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.panel {
  background: var(--bg-panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.input-search {
  padding: 0.45rem 0.65rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  font: inherit;
  min-width: 200px;
}

.select-filter {
  padding: 0.45rem 0.55rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  font: inherit;
  background: #fff;
}

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

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  background: #fafbfd;
}

.data-table tbody tr:hover td {
  background: #f8fafc;
}

.data-table td.muted {
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.pagination-btns {
  display: flex;
  gap: 0.35rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-ok {
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
}

.badge-off {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.skeleton {
  animation: pulse 1.2s ease-in-out infinite;
  background: linear-gradient(90deg, #f1f5f9 0%, #e8ecf4 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  border-radius: 8px;
  height: 1rem;
}

@keyframes pulse {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.chart-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
  padding: 0.5rem 0;
}

.chart-bar {
  flex: 1;
  min-width: 6px;
  background: linear-gradient(180deg, rgba(59, 108, 255, 0.85), rgba(59, 108, 255, 0.18));
  border-radius: 6px 6px 2px 2px;
  transition: opacity 0.15s;
}

.chart-bar:hover {
  opacity: 0.85;
}

.note-card {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: #fafbfd;
  color: var(--muted);
  font-size: 0.9rem;
}

.integr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
