:root{
  --bg:#0b0c10;
  --card:#1f2833;
  --text:#c5c6c7;
  --accent:#66fcf1;
  --accent-2:#45a29e;
  --green:#2ecc71;
  --red:#e74c3c;
  --yellow:#f1c40f;
  --blue:#3498db;
  --purple:#9b59b6;
}
*{box-sizing:border-box}
html,body{width:100%;min-height:100%;overflow-x:hidden}
body{
  background:var(--bg);color:var(--text);font-family:system-ui,Segoe UI,Roboto,Ubuntu,Arial,sans-serif;margin:0;
}

body.has-sidebar {
  display: flex;
}

nav{background:#11161d;border-bottom:1px solid #223;position:sticky;top:0;z-index:2}
.container{max-width:1100px;margin:0 auto;padding:1rem}
a{color:var(--accent)}
.card{background:var(--card);border:1px solid #2b3540;border-radius:14px;padding:1rem;margin:.75rem 0;box-shadow:0 2px 8px rgba(0,0,0,.25);overflow-wrap:anywhere}
.btn{display:inline-block;padding:.6rem 1rem;border-radius:10px;border:1px solid #2b3540;text-decoration:none;color:white;background:linear-gradient(180deg,var(--accent),var(--accent-2));font-weight:600}
.btn.secondary{background:transparent;color:var(--accent);border-color:var(--accent)}
.grid{display:grid;gap:1rem}
.grid-3{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}
.table-responsive{width:100%;overflow-x:auto}
table{width:100%;border-collapse:collapse;min-width:640px}
th,td{padding:.5rem;border-bottom:1px solid #2b3540;vertical-align:top}
.badge{padding:.2rem .5rem;border-radius:999px;font-size:.8rem;font-weight:700;display:inline-block}
.badge.base{background:var(--blue)}
.badge.upgrade{background:var(--purple)}
.badge.retention{background:var(--yellow);color:#333}
.badge.bonus{background:var(--green);color:#111}
.green-dot{display:inline-block;width:10px;height:10px;background:#4cd137;border-radius:50%;margin-right:.25rem;border:1px solid #2b3540}
.progress{height:10px;background:#222;border-radius:999px;overflow:hidden}
.progress>span{display:block;height:100%;background:var(--green);width:0%;transition:width .6s ease}
input,select,textarea{width:100%;padding:.6rem;border-radius:10px;border:1px solid #2b3540;background:#0f141a;color:#eee}
label{display:block;margin:.3rem 0 .2rem}
form .row{display:grid;grid-template-columns:repeat(12,1fr);gap:1rem}
.col-6{grid-column:span 6}
.col-4{grid-column:span 4}
.col-12{grid-column:span 12}
@media(max-width:720px){
  .col-6,.col-4{grid-column:span 12}
  .container{padding:.8rem}
  table{min-width:520px}
}
.notice{padding:.6rem;border-left:4px solid var(--accent);background:#0e151b;margin:.5rem 0;border-radius:8px}
footer{opacity:.7;text-align:center;padding:2rem}
canvas,img{max-width:100%;height:auto}
.code{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; background:#0e151b; padding:.3rem .5rem; border-radius:8px}

/* Accesibilidad: enlace de salto */
.skip-link{
  position:absolute; left:-9999px; top:auto; width:1px; height:1px; overflow:hidden;
}
.skip-link:focus{
  position:fixed; left:1rem; top:1rem; background:var(--accent); color:#000;
  padding:.5rem .75rem; border-radius:8px; z-index:9999;
}

/* === Responsive Form Grid === */
.form-grid {
  display: grid;
  gap: 1rem;
  /* Crea columnas automáticas de al menos 280px */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Para elementos que deben ocupar todo el ancho de la grilla */
.form-grid-full-width {
  grid-column: 1 / -1;
}

/* NEW: Wrapper for top bar elements */
.nav__top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.nav__user-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Barra de navegación mobile-first */
.nav__bar{
  display:flex; flex-direction:column; gap:.5rem; padding:0;
}

/* NEW: Special case for simple navbar (e.g. admin_reset) */
.nav__bar.no-toggle .nav__toggle {
  display: none;
}
.nav__bar.no-toggle .nav__links {
  display: none;
}
.nav__bar.no-toggle .nav__top-row {
  justify-content: flex-end;
}
.nav__brand{
  display:flex; align-items:center; justify-content:space-between;
}
.nav__logo{
  text-decoration:none; color:var(--text); font-weight:700;
}

/* Botón hamburguesa */
.nav__toggle{
  display:inline-grid; place-items:center;
  width:44px; height:44px; border-radius:10px;
  background:#0e151b; color:var(--text); border:1px solid #2b3540;
}
.nav__burger{
  width:22px; height:2px; background:currentColor; position:relative; display:block;
}
.nav__burger::before, .nav__burger::after{
  content:""; position:absolute; left:0; width:22px; height:2px; background:currentColor;
}
.nav__burger::before{ top:-6px; }
.nav__burger::after{ top:6px; }

/* Lista de links */
.nav__links{ display:none; }
.nav__links.is-open{ display:block; }

.nav__links ul{
  list-style:none; margin:0; padding:0;
  display:flex; flex-direction:column; gap:.25rem;
}
.nav__links a{
  display:block; text-decoration:none; color:var(--text);
  padding:.6rem .7rem; border-radius:10px;
}
.nav__links a:hover, .nav__links a:focus-visible{
  background:#0e151b; outline:none;
}

.nav__hello{ color:#aab; padding:.4rem .7rem; }

/* Desktop: nav horizontal */
@media(min-width: 800px){
  .nav__bar{
    flex-direction:row;
    align-items:center;
  }
  .nav__top-row { display: contents;} /* Desenvuelve el wrapper */
  .nav__toggle{ display:none; }

  /* Reordenamiento para desktop */
  .nav__brand { order: 1; }
  .nav__links { order: 2; flex-grow: 1; display: block; }
  .nav__user-actions { order: 3; }

  .nav__links ul{ flex-direction:row; align-items:center; flex-wrap:wrap; gap:.35rem; }
  .nav__links a{ padding:.5rem .6rem; }
}
/* KPIs */
.kpi h3{ margin-top:0; }
.kpi__number{ font-size:2rem; margin:.25rem 0 .5rem; }

/* Tabla limpia + control de cortes */
.table-clean th,
.table-clean td{
  vertical-align:top;
  border-bottom:1px solid #2b3540;
}
.nowrap{ white-space:nowrap; }
.cell-notes{ max-width:0; } /* deja que truncate gobierne */
.truncate{
  display:inline-block;
  max-width: 220px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

/* Evita “palabras partidas” raras en cabeceras */
.table-clean th{ word-break:keep-all; hyphens:none; }

/* Hacer la tabla un poco más ancha para scroll decente */
.table-responsive table{ min-width: 760px; }

/* Chart responsive */
.chart-box{
  position:relative;
  height: 240px;
}
@media (min-width: 900px){
  .chart-box{ height: 300px; }
}

/* Ocultar algunas columnas en pantallas muy pequeñas */
@media (max-width: 480px){
  .truncate{ max-width: 140px; }
  .hide-sm{ display:none; }
}

/* === TABLE STACKED: una línea por campo "Título: valor" === */
@media (max-width: 720px){
  /* sin scroll horizontal */
  .table-responsive table{ min-width: 0; }

  .table-stacked thead{ display:none; }

  .table-stacked tbody tr{
    display:block;
    padding:.75rem;
    margin-bottom:.6rem;
    border:1px solid #2b3540;
    border-radius:12px;
    background:#0f141a; /* coherente con tu tema */
  }

  .table-stacked tbody td{
    display:block;              /* un bloque por campo */
    padding:.35rem 0;
    border:0;
    min-width:0;
    overflow-wrap:anywhere;     /* permite romper palabras largas */
    word-break:break-word;
  }

  /* "Título: " antes del valor */
  .table-stacked tbody td::before{
    content: attr(data-label) ": ";
    font-weight:700;
    color:#aab;
    margin-right:.35rem;
  }

  /* el valor va a continuación del "Título: " en la misma línea */
  .table-stacked .cell-val{
    display:inline;
    margin:0;
    text-align:left;
  }

  /* Notas puede ocupar varias líneas completas */
  .table-stacked tbody td.notes{
    white-space: normal;
  }

  /* Acciones: muestra "Acciones: " y luego los botones en línea / wraps si hace falta */
  .table-stacked tbody td.actions .actions__wrap{
    display:flex;
    gap:.45rem;
    flex-wrap:wrap;
    margin-top:.15rem;
  }

  /* Botón compacto ya definido; por claridad: */
  .btn.small{ padding:.35rem .6rem; font-size:.85rem; border-radius:8px; }
}

/* Ventana con scroll vertical para listas largas */
.scroll-window{
  /* altura acotada: usa el menor entre 60% del viewport y 420px */
  max-height: min(60vh, 420px);
  overflow: auto;           /* vertical + horizontal si hiciera falta */
  padding-bottom: .25rem;
  scroll-behavior: smooth;
}

/* Cabecera sticky (solo relevante en vista de tabla) */
.table-clean thead th{
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);  /* combina con tu card */
}

/* Ajustes de stacked ya aplicados antes — coexistencia con scroll */
@media (max-width: 720px){
  /* Ya tenías: .table-stacked oculta thead y arma grid por fila */
  /* La ventana con scroll sigue limitando la altura del card */
}

/* Scrollbar sutil (opcional) */
.scroll-window::-webkit-scrollbar{ width:8px; height:8px; }
.scroll-window::-webkit-scrollbar-thumb{ background:#2b3540; border-radius:8px; }
.scroll-window::-webkit-scrollbar-track{ background:#11161d; }

/* Grupo de acciones: compacto y flexible */
.actions__wrap{
  display: inline-flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.actions__wrap form{ display: inline; margin: 0; }

/* Botón compacto (ya lo usamos en el dashboard) */
.btn.small{ padding:.35rem .6rem; font-size:.85rem; border-radius:8px; }

/* Versión stacked en móvil: el cell de Acciones ocupa todo el ancho y alinea a la izquierda */
@media (max-width: 720px){
  .table-stacked tbody td.actions{
    grid-column: 1 / -1; /* fila completa */
  }
  .table-stacked tbody td.actions .cell-val{
    margin-left: 0;       /* anula alineación a la derecha del patrón base */
    text-align: left;
    width: 100%;
    display: block;
  }
  .actions__wrap{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .5rem;
  }
}

/* Soporte de columnas faltantes y helper móvil */
.col-3{ grid-column: span 3; }
.col-12-sm{ grid-column: span 12; } /* úsalo para forzar 1 por línea en móvil */

/* Ya tienes el colapso a 1 columna en <=720px para .col-6/.col-4.
   Extendemos a .col-3 y aplicamos el helper .col-12-sm */
@media (max-width:720px){
  .col-3{ grid-column: span 12; }
  .col-4{ grid-column: span 12; } /* por si aparece en fieldsets */
  .col-6{ grid-column: span 12; }
}

/* Fieldsets más compactos en móvil */
fieldset.card > legend{
  padding: .2rem .5rem;
  font-weight: 700;
  color: var(--accent);
}

/* === Pares clave-valor: "Título: valor" una línea === */
.kv-list{ margin:.5rem 0; }
.kv{ padding:.25rem 0; }
.kv dt{ display:inline; font-weight:700; color:#aab; }
.kv dt::after{ content: ": "; }
.kv dd{ display:inline; margin:0; }
.kv-multi dd{ display:inline; white-space:normal; }

/* Imagen/documento */
.media{ max-width:520px; margin: .75rem 0; }
.media img{ width:100%; height:auto; border-radius:8px; display:block; }

/* Cuotas financiadas */
.installments{ display:grid; gap:.6rem; }
.inst-card{
  background:#0f141a; border:1px solid #2b3540; border-radius:12px; padding:.6rem .8rem;
}
.inst-card h4{ margin:.2rem 0 .3rem; font-size:1rem; color:var(--accent); }

/* Opcional: en pantallas grandes, dos columnas de cuotas */
@media (min-width: 900px){
  .installments{ grid-template-columns: repeat(2, minmax(260px, 1fr)); }
}

/* Grupo de acciones compacto y flexible */
.actions__wrap{
  display:inline-flex;
  gap:.5rem;
  flex-wrap:wrap;
  align-items:center;
}
.actions__wrap form{ display:inline; margin:0; }
.btn.small{ padding:.35rem .6rem; font-size:.85rem; border-radius:8px; }

/* Versión stacked móvil: "Título: valor" en UNA línea por campo */
@media (max-width: 720px){
  .table-responsive table{ min-width:0; } /* sin scroll horizontal */

  .table-stacked thead{ display:none; }
  .table-stacked tbody tr{
    display:block;
    padding:.75rem;
    margin-bottom:.6rem;
    border:1px solid #2b3540;
    border-radius:12px;
    background:#0f141a;
  }
  .table-stacked tbody td{
    display:block;
    padding:.35rem 0;
    border:0;
    min-width:0;
    overflow-wrap:anywhere;
    word-break:break-word;
  }
  .table-stacked tbody td::before{
    content: attr(data-label) ": ";
    font-weight:700; color:#aab; margin-right:.35rem;
  }
  .table-stacked .cell-val{ display:inline; margin:0; text-align:left; }
  .table-stacked tbody td.actions{ grid-column:1/-1; }
  .table-stacked tbody td.actions .cell-val{
    display:block; margin-left:0; text-align:left;
  }
  .table-stacked tbody td.actions .actions__wrap{
    display:flex; gap:.45rem; flex-wrap:wrap; margin-top:.15rem;
  }
}

/* Badge de estado */
.badge.success{ background: var(--green); color:#111; }
.badge.warning{ background: var(--yellow); color:#333; }

/* Ventana con scroll para listados largos */
.scroll-window{
  max-height: min(65vh, 520px);
  overflow: auto;
  padding-bottom: .25rem;
}
.table-clean thead th{
  position: sticky; top: 0; z-index: 1; background: var(--card);
}

/* Variantes de botón */
.btn.secondary.danger{
  color: var(--red);
  border-color: #a83224;
}

/* Checkbox/label en línea y centrados verticalmente */
.check-inline{
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  user-select:none;
}
.check-inline input[type="checkbox"]{
  width:18px; height:18px;
  accent-color: var(--accent); /* usa tu color de marca */
}

/* Fieldset suave */
.fs > legend{
  padding:.2rem .5rem;
  font-weight:700;
  color:var(--accent);
}

/* Grilla de checkboxes */
.checks-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap:.5rem;
}
.check-inline{
  display:inline-flex;
  align-items:center;
  gap:.45rem;
  user-select:none;
}
.check-inline input[type="checkbox"]{
  width:18px; height:18px;
  accent-color: var(--accent);
}


/* === Installs list: vista de escritorio en tarjetas 2 columnas === */
@media (min-width: 721px){
  /* Oculta cabecera y usa grid en el cuerpo */
  .cardgrid-2 thead{ display:none; }
  .cardgrid-2 tbody{
    display:grid;
    grid-template-columns: repeat(2, minmax(360px, 1fr));
    gap: 1rem;
  }
  /* Cada fila como tarjeta */
  .cardgrid-2 tbody tr{
    display:block;
    padding:.9rem;
    border:1px solid #2b3540;
    border-radius:12px;
    background:#0f141a;
  }
  /* Una línea por campo: "Título: valor" */
  .cardgrid-2 tbody td{
    display:block;
    padding:.35rem 0;
    border:0;
    min-width:0;
    overflow-wrap:anywhere;
    word-break:break-word;
  }
  .cardgrid-2 tbody td::before{
    content: attr(data-label) ": ";
    font-weight:700; color:#aab; margin-right:.35rem;
  }
  .cardgrid-2 .cell-val{ display:inline; }

  /* Acciones al final, en bloque y con wrap cómodo */
  .cardgrid-2 tbody td.actions .cell-val{ display:block; margin-left:0; text-align:left; }
  .cardgrid-2 tbody td.actions .actions__wrap{
    display:flex; gap:.45rem; flex-wrap:wrap; margin-top:.15rem;
  }
}

/* Evita que esta tabla fuerce scroll horizontal en cualquier viewport */
.cardgrid-2{ width:100%; }
.table-responsive .cardgrid-2{ min-width:0; }

/* Grid extra para 1/4 de fila */
.col-3{ grid-column: span 3; }
@media(max-width:720px){
  .col-3{ grid-column: span 12; }
}

  .inst-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
  }

  .inst-header h2 {
    margin: 0;
    line-height: 1.3;
  }

  .btn-back {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    text-decoration: none;
  }

  .btn-back .arrow {
    font-size: 1.1rem;
    line-height: 1;
  }

/* === Paginación Avanzada === */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.page-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid #2b3540;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.page-btn.active {
  background: var(--accent);
  color: #0b0c10;
  border-color: var(--accent);
  font-weight: bold;
}
.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.page-ellipsis {
  padding: 0.4rem;
  color: #889;
}

/* === Modals === */
dialog {
    /* Make the dialog wrapper transparent to avoid default white background */
    background: transparent;
    border: none;
    padding: 0;
    max-width: 820px;
    width: 90%;
    color: var(--text);
}
dialog form {
    /* Apply the glassmorphism style to the form inside */
    background: rgba(31, 40, 51, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid #2b3540;
    border-radius: 14px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    overflow: hidden; /* Ensures children respect the border-radius */
}
dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}
.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #2b3540;
}
.modal__header h3 {
    margin: 0;
}
.modal__close {
    background: transparent;
    border: 0;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    padding: 0 .5rem;
}
.modal__close:hover { opacity: 1; }
dialog form .row { padding: 1rem 1.5rem 0; }
.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #2b3540;
}

/* === Gallery Modal === */
.gallery-thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}
.gallery-thumbnails img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.gallery-thumbnails img:hover {
  transform: scale(1.05);
}

.gallery-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.9);
  align-items: center;
  justify-content: center;
}
.gallery-modal.active {
  display: flex;
}

.gallery-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 90vh;
}

.gallery-modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.gallery-close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
}
.gallery-close:hover,
.gallery-close:focus {
  color: #bbb;
  text-decoration: none;
}

.gallery-prev, .gallery-next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 16px;
  color: white;
  font-weight: bold;
  font-size: 20px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
  background-color: rgba(0,0,0,0.3);
}
.gallery-prev {
  left: 0;
  border-radius: 3px 0 0 3px;
}
.gallery-next {
  right: 0;
  border-radius: 3px 0 0 3px;
}
.gallery-prev:hover, .gallery-next:hover {
  background-color: rgba(0,0,0,0.8);
}

.gallery-caption {
  text-align: center;
  color: #ccc;
  padding: 10px 0;
  position: absolute;
  bottom: 15px;
  width: 100%;
}

/* === IP Management === */
.ip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}
.ip-card {
    background: #0f141a;
    border: 1px solid #2b3540;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-family: ui-monospace, monospace;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s ease-in-out;
}
.ip-card.is-manageable {
    cursor: pointer;
}
.ip-card.is-manageable:hover {
    border-color: var(--accent);
}
.ip-card .status {
    padding: .1rem .4rem; border-radius: 99px; font-size: .75rem; font-weight: 700;
}
.ip-card .status.available { background: var(--green); color: #111; }
.ip-card .status.used { background: var(--yellow); color: #333; }
.ip-card .status.unusable { background: var(--red); color: white; }
.ip-customer { font-size: 0.8rem; color: #aab; margin-top: .1rem; }
.ip-customer-details { font-size: 0.75rem; color: #889; line-height: 1.3; }

/* === Reports Page === */
.report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.report-filters .form-group {
  display: flex;
  flex-direction: column;
}
.report-filters label {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.report-filters input,
.report-filters select {
  padding: 0.5rem;
  min-width: 180px;
}
.report-filters .btn-group {
  display: flex;
  gap: 0.5rem;
  align-self: flex-end;
  margin-top: 1.2rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.kpi-card .sub-value {
  font-size: 0.85rem;
  color: #889;
}

/* === Reports Page Tables === */
.table-centered th {
  text-align: center;
}
.table-centered td {
  text-align: center;
}
.table-centered th:first-child,
.table-centered td:first-child {
  text-align: left;
}

/* === Global Search in Sidebar === */
.sidebar-search {
  padding: 0.75rem 1rem;
  border-top: 1px solid #2b3540;
  border-bottom: 1px solid #2b3540;
  flex-shrink: 0; /* Prevent it from shrinking */
}

.sidebar-search input {
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid #2b3540;
  background: #0e151b;
  color: var(--text);
  font-size: 0.9rem;
}

/* Adjust for collapsed state */
.sidebar.collapsed .sidebar-search {
  padding: 0.75rem 0.5rem; /* Smaller padding */
}

.sidebar.collapsed .sidebar-search input {
  text-align: center;
  padding: 0.5rem 0; /* Remove horizontal padding */
}

.sidebar.collapsed .sidebar-search input::placeholder {
  color: transparent; /* Hide placeholder text */
}

/* Show placeholder on hover in collapsed state */
.sidebar.collapsed .sidebar-search input:hover::placeholder {
  color: var(--text);
}

/* For mobile, when sidebar is open, ensure search is visible */
@media (max-width: 800px) {
  .sidebar.open .sidebar-search input::placeholder {
    color: var(--text);
  }
}

/* === New Sidebar Layout === */
.sidebar {
  width: 250px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  background: rgba(31, 40, 51, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid #2b3540;
  transition: width 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

.main-content-wrapper {
  margin-left: 250px;
  width: calc(100% - 250px);
  transition: margin-left 0.3s ease-in-out, width 0.3s ease-in-out;
  flex-grow: 1;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #2b3540;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.3s;
  display: none; /* Hidden by default, shown in topbar */
}
.sidebar-toggle:hover {
  opacity: 1;
}

.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  transition: background 0.2s;
}
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-item.has-submenu > .sidebar-link::after {
  content: '›';
  margin-left: auto;
  font-size: 1.2em;
  transition: transform 0.3s;
  transform: rotate(90deg);
}
.sidebar-item.has-submenu.open > .sidebar-link::after {
  transform: rotate(-90deg);
}

.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(0,0,0,0.2);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}
.sidebar-item.has-submenu.open .sidebar-submenu {
  max-height: 500px; /* Adjust as needed */
}
.sidebar-submenu a {
  display: block;
  padding: 0.6rem 1.25rem 0.6rem 3.5rem;
  color: var(--text);
  text-decoration: none;
  opacity: 0.8;
  font-size: 0.9rem;
  position: relative;
}
.sidebar-submenu a:hover {
  opacity: 1;
  color: var(--accent);
}
.sidebar-submenu a.active {
  color: var(--accent);
  font-weight: 600;
}
.sidebar-submenu a.active::before {
  content: '';
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Collapsed State */
.sidebar.collapsed {
  width: 70px;
}
.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .profile-info,
.sidebar.collapsed .sidebar-item.has-submenu > .sidebar-link::after {
  opacity: 0;
  visibility: hidden;
  width: 0;
}
.sidebar.collapsed .sidebar-toggle .arrow {
  transform: rotate(180deg);
}
.sidebar.collapsed + .main-content-wrapper {
  margin-left: 70px;
  width: calc(100% - 70px);
}

/* Profile Section */
.sidebar-profile {
  padding: 0.75rem;
  border-top: 1px solid #2b3540;
  position: relative;
  flex-shrink: 0;
}
.profile-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s;
  overflow: hidden;
}
.profile-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}
.profile-avatar { font-size: 1.5rem; }
.profile-info { overflow: hidden; white-space: nowrap; }
.profile-name { display: block; font-weight: 600; color: var(--text); }
.profile-role { display: block; font-size: 0.8rem; color: #aab; }

.profile-menu {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0.75rem;
  right: 0.75rem;
  background: var(--card);
  border: 1px solid #2b3540;
  border-radius: 8px;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.2);
  padding: 0.5rem;
  display: none;
  z-index: 110;
}
.profile-menu.open { display: block; }
.profile-menu-item {
  display: block;
  padding: 0.6rem 0.8rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
}
.profile-menu-item:hover {
  background: var(--accent-2);
  color: white;
}

/* Topbar for mobile */
.topbar {
  display: none;
}

@media (max-width: 800px) {
  body.has-sidebar { display: block; } /* Revert flex layout */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar.collapsed { /* No collapse on mobile */
    width: 250px;
  }
  .sidebar.collapsed .sidebar-text,
  .sidebar.collapsed .profile-info,
  .sidebar.collapsed .sidebar-item.has-submenu > .sidebar-link::after {
    opacity: 1; visibility: visible; width: auto;
  }

  .main-content-wrapper {
    margin-left: 0;
    width: 100%;
  }
  .topbar {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #11161d;
    border-bottom: 1px solid #223;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .topbar .sidebar-toggle { display: none; } /* Hide desktop toggle in topbar */
  .mobile-sidebar-toggle {
    display: inline-grid; place-items:center;
    width:44px; height:44px; border-radius:10px;
    background:#0e151b; color:var(--text); border:1px solid #2b3540;
  }
}

@media (min-width: 801px) {
  .mobile-sidebar-toggle { display: none; }
  .topbar .sidebar-toggle { display: block; }
}

/* === IP Management === */
.ip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}
.ip-card {
    background: #0f141a;
    border: 1px solid #2b3540;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-family: ui-monospace, monospace;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s ease-in-out;
}
.ip-card.is-manageable {
    cursor: pointer;
}
.ip-card.is-manageable:hover {
    border-color: var(--accent);
}
.ip-card .status {
    padding: .1rem .4rem; border-radius: 99px; font-size: .75rem; font-weight: 700;
}
.ip-card .status.available { background: var(--green); color: #111; }
.ip-card .status.used { background: var(--yellow); color: #333; }
.ip-card .status.unusable { background: var(--red); color: white; }
.ip-customer { font-size: 0.8rem; color: #aab; margin-top: .1rem; }
.ip-customer-details { font-size: 0.75rem; color: #889; line-height: 1.3; }