/* ==========================================================================
   SlimNOC2 — Base + App shell
   ========================================================================== */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: block; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ==========================================================================
   Layout
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  transition: grid-template-columns var(--transition);
}

.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  /*
   * SLIMNOC_V2_MOBILE_MAIN_GRID_FIX_V1
   * Trava o .main sempre na 2ª coluna do grid, sem depender de
   * auto-placement — evita que ele seja jogado na coluna errada (e
   * colapse pra largura 0) sempre que o .sidebar sai do fluxo normal
   * do grid (ex: position:fixed no modo "gaveta" do celular) ou quando
   * só existe UMA coluna explícita definida (ex: .app.is-collapsed
   * antes desse fix). Seguro em qualquer largura/estado.
   */
  grid-column: 2;
}

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 26px 16px;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
  cursor: pointer;
  user-select: none;
}

.brand__logo {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #1f3a63, #16233c);
  border: 1px solid #2c4a78;
  color: #6aa8ff;
}

.brand__text { min-width: 0; overflow: hidden; }

.brand__title {
  font-size: 18.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.15;
  white-space: nowrap;
}
.brand__title span { color: var(--primary); }

.brand__sub {
  font-size: 9.5px;
  letter-spacing: 1.1px;
  color: var(--text-dim);
  text-transform: uppercase;
  white-space: nowrap;
  font-weight: 600;
}

.nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px 10px;
}

.nav__label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 8px 10px;
  white-space: nowrap;
}

.nav__item { margin-bottom: 2px; }

.nav__link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-size: 15px;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background var(--transition), color var(--transition);
}

.nav__link:hover { background: var(--bg-surface-2); color: var(--text); }

.nav__link.is-active {
  background: var(--primary-soft);
  color: #7fb2ff;
  font-weight: 500;
}

.nav__link .icon { flex: none; width: 18px; height: 18px; opacity: 0.9; }
.nav__link span { flex: 1; white-space: nowrap; overflow: hidden; }

.nav__caret {
  flex: none;
  width: 14px;
  height: 14px;
  opacity: 0.6;
  transition: transform var(--transition);
}
.nav__item.is-open > .nav__link .nav__caret { transform: rotate(90deg); }

.nav__sub {
  display: none;
  margin: 2px 0 6px 0;
  padding-left: 27px;
  position: relative;
}
.nav__item.is-open > .nav__sub { display: block; }

.nav__sub::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--border);
}

.nav__sublink {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 14.5px;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}
.nav__sublink:hover { color: var(--text); background: var(--bg-surface-2); }

.nav__sublink.is-active {
  background: var(--primary-soft);
  color: #7fb2ff;
  font-weight: 500;
}
.nav__sublink.is-active::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--primary);
}

/* Plan card */
.plan {
  flex: none;
  margin: 10px 14px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
}
.plan__name { font-size: 14px; font-weight: 700; letter-spacing: 0.3px; }
.plan__row {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 5px;
  white-space: nowrap;
}
.plan__row b { color: var(--text-soft); font-weight: 600; }
.plan__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.plan__track {
  flex: 1;
  height: 5px;
  border-radius: 4px;
  background: var(--bg-surface-3);
  overflow: hidden;
}
.plan__fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #f5a623, #ef4444);
}
.plan__pct { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.sidebar__version {
  flex: none;
  padding: 4px 20px 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Collapsed sidebar */
.app.is-collapsed .brand { padding: 0 18px; }
.app.is-collapsed .brand__text,
.app.is-collapsed .nav__label,
.app.is-collapsed .nav__link span,
.app.is-collapsed .nav__caret,
.app.is-collapsed .nav__sub,
.app.is-collapsed .plan,
.app.is-collapsed .sidebar__version { display: none; }
.app.is-collapsed .nav__link { justify-content: center; padding: 11px 0; }

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
}

.topbar__toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.topbar__toggle:hover { background: var(--bg-surface-2); color: var(--text); }

.search {
  position: relative;
  width: min(440px, 40vw);
}
.search input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}
.search input::placeholder { color: var(--text-dim); }
.search input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.search__icon {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.topbar__spacer { flex: 1; }

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.company {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-surface);
  cursor: pointer;
  transition: var(--transition);
}
.company:hover { border-color: var(--border-strong); }
.company__icon { color: var(--text-muted); }
.company__label { font-size: 11.5px; color: var(--text-muted); line-height: 1.2; }
.company__name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.company__caret { color: var(--text-muted); }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-surface-2); color: var(--text); }

.badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg-topbar);
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 4px;
  border-radius: 9px;
  cursor: pointer;
  transition: var(--transition);
}
.user:hover { background: var(--bg-surface-2); }
.user__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-surface-3);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.user__name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.user__status {
  font-size: 12px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.25;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  flex: none;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  padding: 0 26px;
  border-top: 1px solid var(--border);
  background: var(--bg-topbar);
  font-size: 14px;
  color: var(--text-muted);
}
.footer__left { flex: 1; text-align: center; }
.footer__left b { color: var(--primary); font-weight: 600; }
.footer__right { display: flex; gap: 16px; }
.footer__right span b { color: var(--text-soft); font-weight: 500; }
.footer__sep { color: var(--border-strong); }

/* ==========================================================================
   Page header
   ========================================================================== */

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title { font-size: 28.5px; font-weight: 700; letter-spacing: -0.3px; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 14px;
  color: var(--text-muted);
}
.breadcrumb .sep { color: var(--text-dim); }
.breadcrumb .current { color: var(--text-soft); }
.page-head__actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.btn:hover { background: var(--bg-surface-2); color: var(--text); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(47, 124, 246, 0.28);
}
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

.btn--ghost { background: transparent; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 14px; border-radius: 7px; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--danger { color: #ff8f8f; }
.btn--danger:hover { background: var(--danger-soft); border-color: rgba(239,68,68,.4); color: #ff9d9d; }

/* ==========================================================================
   Card
   ========================================================================== */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.card__title { font-size: 16px; font-weight: 600; }
.card__body { padding: 16px; }

/* ==========================================================================
   Badges / chips
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--online { background: var(--success-soft); color: #4ade80; border-color: rgba(34,197,94,.25); }
.badge--alert  { background: var(--warning-soft); color: #fbbf24; border-color: rgba(245,166,35,.28); }
.badge--offline{ background: var(--danger-soft);  color: #f87171; border-color: rgba(239,68,68,.28); }
.badge--info   { background: var(--primary-soft); color: #7fb2ff; border-color: rgba(47,124,246,.28); }
.badge--muted  { background: var(--bg-surface-2); color: var(--text-muted); border-color: var(--border); }

/* ==========================================================================
   Dropdown
   ========================================================================== */

.dropdown { position: relative; }
.dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  padding: 6px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  display: none;
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
}
.dropdown__item:hover { background: var(--bg-surface-3); color: var(--text); }
.dropdown__sep { height: 1px; margin: 5px 4px; background: var(--border); }

/* ==========================================================================
   Toast
   ========================================================================== */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 62px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  padding: 12px 15px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14.5px;
  animation: toast-in 220ms ease;
}
.toast--success { border-left-color: var(--success); }
.toast--warn { border-left-color: var(--warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--font-mono); }
.row { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.ml-auto { margin-left: auto; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* ==========================================================================
   Responsivo — celular / tablet estreito
   SLIMNOC_V2_MOBILE_LAYOUT_V1
   ========================================================================== */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 18, 0.6);
  z-index: 90;
}

@media (max-width: 900px) {
  /* sem essa coluna reservada, o conteúdo fica espremido do lado do
     sidebar mesmo com ele escondido — no celular o sidebar vira um
     "drawer" que flutua por cima, não divide a tela. */
  .app,
  .app.is-collapsed {
    grid-template-columns: 0 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .app.is-mobile-nav-open .sidebar { transform: translateX(0); }
  .app.is-mobile-nav-open .sidebar-backdrop { display: block; }

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .search { display: none; }
  .company { display: none; }

  .content { padding: 16px 14px 12px; }

  .footer {
    height: auto;
    min-height: var(--footer-h);
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 4px 14px;
  }
  .footer__left { flex: 1 1 100%; text-align: left; }
}

@media (max-width: 560px) {
  .page-title { font-size: 23px; }
  .page-head { gap: 10px; margin-bottom: 16px; }

  .kpi-grid { gap: 10px; }
  .kpi { padding: 13px; gap: 10px; }
  .kpi__icon { width: 40px; height: 40px; }
  .kpi__value { font-size: 24px; }

  .details__foot { flex-wrap: wrap; }
  .details__foot .btn,
  .details__foot .btn--primary,
  .details__foot .dropdown { flex: 1 1 100%; }

  .toolbar > .btn,
  .toolbar > select.btn,
  .toolbar > .search { flex: 1 1 auto; }
}
