:root {
  --white:         #ffffff;
  --border:        #e5e7eb;
  --text:          #1a1d27;
  --text-2:        #475569;
  --text-3:        #9ca3af;
  --accent:        #2563eb;
  --accent-light:  #dbeafe;
  --sidebar-width: 220px;
  --sidebar-mini:  58px;
  --topbar-h:      64px;
  --radius:        12px;
  --font:          'Plus Jakarta Sans', sans-serif;
  --mono:          'DM Mono', monospace;
  --transition:    .3s cubic-bezier(.4, 0, .2, 1);
  --green:  #22c55e;
  --yellow: #f59e0b;
  --red:    #ef4444;
  --blue:   #3b82f6;
  --orange: #f59e0b;
  --purple: #8b5cf6;
  --cyan:   #06b6d4;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  overflow-x: hidden;
}

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

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width var(--transition), transform var(--transition);
}

.sidebar > div:first-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  cursor: pointer;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.logo-circle {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #22c55e, #3b82f6);
}
.logo-circle img { width: 100%; height: 100%; object-fit: cover; }

.logo-text { overflow: hidden; white-space: nowrap; }
.logo-text h2 { font-size: 16px; font-weight: 700; }
.logo-text p  { font-size: 10px; color: #64748b; }

.sidebar-toggle {
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: transparent; color: var(--accent);
  cursor: pointer; flex-shrink: 0;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: .2s;
}
.sidebar-toggle:hover { background: var(--accent); color: #fff; }

.nav {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  gap: 2px;
  flex-shrink: 0;
}

.nav a {
  display: flex; align-items: center;
  padding: 11px 10px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  transition: .2s;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}
.nav a i    { width: 18px; font-size: 14px; text-align: center; margin-right: 10px; flex-shrink: 0; }
.nav a span { overflow: hidden; }
.nav a:hover  { background: #eff6ff; color: var(--accent); }
.nav a.active { background: var(--accent-light); color: var(--accent); }

.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-contact {
  padding: 10px 10px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-contact-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  padding: 4px 10px 6px;
  white-space: nowrap;
}

.sidebar-contact a {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 14px;
  transition: .2s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-contact a:hover { background: #eff6ff; color: var(--accent); }
.sidebar-contact a i     { font-size: 13px; flex-shrink: 0; width: 18px; text-align: center; }
.sidebar-contact a span  { overflow: hidden; text-overflow: ellipsis; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}
.sidebar-brand i      { font-size: 14px; color: var(--accent); flex-shrink: 0; }
.sidebar-brand p      { font-size: 11px; font-weight: 600; color: var(--text-2); line-height: 1.5; overflow: hidden; }
.sidebar-brand strong { color: var(--text); font-weight: 700; }

.sidebar.close                  { width: var(--sidebar-mini); }
.sidebar.close .logo            { display: none; }
.sidebar.close .logo-row        { justify-content: center; }
.sidebar.close .nav             { padding: 6px 8px; }
.sidebar.close .nav a           { width: 42px; height: 42px; padding: 0; margin: 0 auto; justify-content: center; }
.sidebar.close .nav a i         { margin-right: 0; }
.sidebar.close .nav a span      { display: none; }
.sidebar.close .sidebar-toggle  { margin: 0 auto; }
.sidebar.close .sidebar-footer  { display: none; }

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  min-height: var(--topbar-h);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: left var(--transition);
}
.topbar.expand { left: var(--sidebar-mini); }

.topbar-left {
  display: flex; align-items: center;
  gap: 10px;
  flex: 1; min-width: 0;
}
.topbar-left h1 { font-size: 16px; font-weight: 900; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-left p  { font-size: 10px; color: #666; margin-top: 2px; }

.hamburger {
  display: none;
  width: 38px; height: 38px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--accent);
  font-size: 15px; cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: .2s;
}
.hamburger:hover { background: var(--accent); color: #fff; }

.topbar-bfright { margin-left: auto; flex-shrink: 0; }
.topbar-right   { display: flex; align-items: center; flex-shrink: 0; }
.topbar-left { min-width: 0;}

.topbar-right { margin-left: 8px; }

.time {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
  white-space: nowrap;
}

.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: calc(var(--topbar-h) + 16px) 16px 0 16px;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
  animation: pageFadeIn .32s ease forwards;
}
.main.expand { margin-left: var(--sidebar-mini); }

#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
}

.btn-primary {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: none; border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px; font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary i    { font-size: 14px; line-height: 1; }
.btn-primary span { line-height: 1; }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--border); color: #6b7280;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%; background: #6b7280;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.4; transform:scale(.8); }
}
.status.online-bg               { background: #dcfce7; color: #166534; }
.status.online-bg .status-dot  { background: #16a34a; }
.status.offline-bg              { background: var(--border); color: #6b7280; }
.status.offline-bg .status-dot { background: #6b7280; animation: none; }

.bottom {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  margin-top: auto;
  margin-left: -16px;
  margin-right: -16px;
}
.bottom p { padding: 14px 16px; }

@media (max-width: 900px) {
  .sidebar,
  .sidebar.close {
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
  }
  .sidebar.mobile-open { transform: translateX(0) !important; }

  .sidebar.close .logo           { display: flex; }
  .sidebar.close .logo-row       { justify-content: space-between; }
  .sidebar.close .nav            { padding: 8px 10px; }
  .sidebar.close .nav a          { width: auto; height: auto; padding: 11px 10px; margin: 0; justify-content: flex-start; }
  .sidebar.close .nav a i        { margin-right: 10px; }
  .sidebar.close .nav a span     { display: inline; }
  .sidebar.close .sidebar-toggle { margin: 0; }
  .sidebar.close .sidebar-footer { display: flex; }

  .hamburger { display: flex; }

  .topbar,
  .topbar.expand { left: 0 !important; }

  .main,
  .main.expand {
    margin-left: 0 !important;
    padding-top: calc(var(--topbar-h) + 16px);
  }

  .bottom { font-size: .75rem; }
}

@media (max-width: 600px) {
  .time {
    display: none;
  }

  .update-label {
    display: none;
  }

  .topbar-right {
    display: none;
  }
}

@media (max-width: 480px) {
  :root {
    --topbar-h: 56px;
  }

  .topbar {
    padding: 0 12px;
    gap: 8px;
    overflow: hidden;
  }

  .topbar-left h1 {
    font-size: 13px;
  }

  .topbar-left p,
  .topbar-bfright,
  .time,
  .topbar-right {
    display: none;
  }

  .btn-primary {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
  }

  .btn-primary span {
    display: none;
  }

  .main .btn-primary {
    width: auto;
    height: auto;
    padding: 9px 14px;
    border-radius: 10px;
  }

  .main .btn-primary span {
    display: inline;
  }

  .bottom {
    font-size: .65rem;
    margin-left: -12px;
    margin-right: -12px;
  }
}

.no-transition *,
.no-transition *::before,
.no-transition *::after {
  transition: none !important;
}

@media (max-width: 375px) {
  :root { --topbar-h: 52px; }

  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-left h1 { font-size: 11px; }
  .topbar-bfright { display: none; }
  .topbar-right .btn-primary { display: none; }
  .time { display: none; }

  .main {
    padding-left: 10px;
    padding-right: 10px;
  }

  .bottom {
    font-size: .6rem;
    margin-left: -10px;
    margin-right: -10px;
  }
  .bottom p { padding: 10px; }
}