:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #e5ebf3;
  --text: #172033;
  --muted: #70809a;
  --primary: #1f6feb;
  --primary-soft: rgba(31, 111, 235, 0.10);
  --success: #12b76a;
  --success-soft: rgba(18, 183, 106, 0.12);
  --warning: #f79009;
  --warning-soft: rgba(247, 144, 9, 0.12);
  --danger: #f04438;
  --danger-soft: rgba(240, 68, 56, 0.12);
  --purple: #7a5af8;
  --purple-soft: rgba(122, 90, 248, 0.12);
  --shadow: 0 10px 30px rgba(12, 28, 63, 0.08);
  --radius: 20px;
  --sidebar-width: 290px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  text-decoration: none;
}

button {
  font: inherit;
}

.layout {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #0d1b3d 0%, #132c62 45%, #143d73 100%);
  color: #fff;
  padding: 24px 18px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 1040;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 10px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 22px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #7a5af8, #1f6feb);
  font-size: 1.35rem;
  box-shadow: 0 12px 30px rgba(122, 90, 248, 0.35);
}

.brand h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.brand span {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.83rem;
}

.menu-title {
  padding: 0 10px;
  margin: 22px 0 10px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.52);
  text-transform: uppercase;
}

.nav-pills .nav-link {
  color: rgba(255, 255, 255, 0.82);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  transition: 0.25s ease;
}

.nav-pills .nav-link i {
  font-size: 1.08rem;
}

.nav-pills .nav-link:hover,
.nav-pills .nav-link.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transform: translateX(2px);
}

.sidebar-card {
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 18px;
}

.sidebar-card h6 {
  font-weight: 700;
  margin-bottom: 10px;
}

.sidebar-card p {
  font-size: 0.86rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
  margin-bottom: 14px;
}

.main {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  padding: 24px;
}

.topbar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(229, 235, 243, 0.9);
  border-radius: 24px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.page-title h2 {
  margin: 0;
  font-size: 1.72rem;
  font-weight: 800;
}

.page-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.search-box {
  position: relative;
}

.search-box i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #8c9ab0;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8fbff;
  outline: none;
}

.search-box input:focus {
  border-color: rgba(31, 111, 235, 0.35);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.10);
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  position: relative;
  padding: 0;
}

.notif-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  position: absolute;
  right: 10px;
  top: 10px;
  border: 2px solid #fff;
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 12px;
  min-width: 0;
}

.profile-pill small {
  color: var(--muted);
}

.profile-avatar,
.avatar-sm {
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7a5af8, #1f6feb);
}

.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f6feb, #7a5af8);
  font-size: 0.74rem;
}

.avatar-sm.green {
  background: linear-gradient(135deg, #12b76a, #34d399);
}

.avatar-sm.orange {
  background: linear-gradient(135deg, #f79009, #ffb84d);
}

.avatar-sm.purple {
  background: linear-gradient(135deg, #7a5af8, #9b7bff);
}

.dash-card,
.status-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
  height: 100%;
}

.metric-card {
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  right: -35px;
  top: -35px;
  background: rgba(255, 255, 255, 0.22);
}

.metric-card.primary {
  background: linear-gradient(135deg, #1f6feb, #4c8df5);
  color: #fff;
  border: none;
}

.metric-card.success {
  background: linear-gradient(135deg, #12b76a, #2fd184);
  color: #fff;
  border: none;
}

.metric-card.warning {
  background: linear-gradient(135deg, #f79009, #ffad33);
  color: #fff;
  border: none;
}

.metric-card.purple {
  background: linear-gradient(135deg, #7a5af8, #9b7bff);
  color: #fff;
  border: none;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.metric-label {
  font-size: 0.92rem;
  opacity: 0.95;
  margin-bottom: 10px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 10px;
}

.metric-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
  font-size: 0.88rem;
  opacity: 0.96;
  gap: 12px;
  flex-wrap: wrap;
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1.35rem;
  flex-shrink: 0;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title h5,
.section-title h6 {
  margin: 0;
  font-weight: 800;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.83rem;
  font-weight: 700;
  white-space: nowrap;
}

.chip.success {
  background: var(--success-soft);
  color: var(--success);
}

.chip.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.chip.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip.primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.chip.purple {
  background: var(--purple-soft);
  color: var(--purple);
}

.status-panel {
  background: linear-gradient(135deg, #132c62, #1c3f83);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.status-panel::before,
.status-panel::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.status-panel::before {
  width: 210px;
  height: 210px;
  top: -70px;
  right: -70px;
}

.status-panel::after {
  width: 150px;
  height: 150px;
  bottom: -45px;
  left: -45px;
}

.status-panel .section-title p,
.status-item span,
.mini-stat span {
  color: rgba(255, 255, 255, 0.78);
}

.status-stack {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.status-item strong {
  display: block;
  margin-bottom: 4px;
}

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  position: relative;
  z-index: 1;
}

.mini-stat {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 14px;
}

.mini-stat span {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.mini-stat strong {
  font-size: 1rem;
  font-weight: 800;
}

.chart-box {
  position: relative;
  width: 100%;
}

.line-chart {
  height: 330px;
}

.doughnut-chart {
  height: 300px;
}

.table-wrap {
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.custom-table thead th {
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0 14px 4px;
  white-space: nowrap;
}

.custom-table tbody tr {
  background: #fbfdff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.custom-table tbody td {
  padding: 14px;
  border: none;
  vertical-align: middle;
  font-size: 0.92rem;
  white-space: nowrap;
}

.custom-table tbody tr td:first-child {
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
}

.custom-table tbody tr td:last-child {
  border-top-right-radius: 16px;
  border-bottom-right-radius: 16px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.table-link {
  color: var(--primary);
  font-weight: 700;
}

.alert-list,
.reco-list,
.log-list,
.security-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alert-item,
.reco-item,
.log-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.alert-icon,
.reco-icon,
.log-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.alert-icon.danger,
.log-icon.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-icon.warning,
.log-icon.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.alert-icon.primary,
.reco-icon.primary,
.log-icon.primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.reco-icon.success,
.log-icon.success {
  background: var(--success-soft);
  color: var(--success);
}

.item-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.item-text {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.device-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fbfdff;
}

.device-card.warning {
  background: linear-gradient(180deg, #fff9ef 0%, #fff7eb 100%);
  border-color: #f8d39b;
}

.device-card.danger {
  background: linear-gradient(180deg, #fff6f5 0%, #fff1ef 100%);
  border-color: #f3c2bf;
}

.device-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.device-card > span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.device-meta {
  color: var(--text);
  font-size: 0.88rem;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.legend-list {
  list-style: none;
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

.legend-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.94rem;
  padding-bottom: 10px;
  border-bottom: 1px dashed #dce8e3;
}

.legend-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.legend-dot.blue { background: #1f6feb; }
.legend-dot.green { background: #12b76a; }
.legend-dot.orange { background: #f79009; }
.legend-dot.purple { background: #7a5af8; }

.security-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfdff;
  padding: 16px;
}

.security-card strong {
  display: block;
  margin-bottom: 10px;
}

.security-card span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.progress.slim {
  height: 10px;
  background: #e8edf5;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress.slim i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f6feb, #4c8df5);
}

.progress.slim.green i {
  background: linear-gradient(90deg, #12b76a, #2fd184);
}

.progress.slim.purple i {
  background: linear-gradient(90deg, #7a5af8, #9b7bff);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.action-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 16px;
  padding: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: 0.25s ease;
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--primary), #4c8df5);
  color: #fff;
  border: none;
}

.action-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.footer-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}

@media (max-width: 1199px) {
  .device-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 991px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .layout {
    flex-direction: column;
  }
}

@media (max-width: 767px) {
  .main {
    padding: 14px;
  }

  .topbar {
    padding: 14px;
  }

  .page-title h2 {
    font-size: 1.4rem;
  }

  .quick-actions,
  .mini-stat-grid {
    grid-template-columns: 1fr;
  }

  .line-chart {
    height: 260px;
  }

  .doughnut-chart {
    height: 240px;
  }
}
