@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --theme-accent: #33aaee;
  --theme-accent-hover: #268ecb;
  --theme-accent-soft: rgba(51, 170, 238, 0.06);
  --theme-bg: #f8fafc;
  --theme-surface: #ffffff;
  --theme-surface-hover: #f1f5f9;
  --theme-text: #0f172a;
  --theme-muted: #64748b;
  --theme-border: #e2e8f0;
  --theme-danger: #ef4444;
  --theme-danger-bg: #fef2f2;
  --theme-ok: #10b981;
  --theme-ok-bg: #ecfdf5;
  --shadow-sm: 0 1.8px 3.6px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 7.2px 21.6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 36px rgba(15, 23, 42, 0.06);
  --radius-xl: 14.4px;
  --radius-lg: 10.8px;
  --radius-md: 7.2px;
  --radius-sm: 5.4px;
  --page-max: 100%;
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

html,
body {
  min-height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background: var(--theme-bg);
}

html {
  font-size: 90%;
  overflow-x: clip;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background-color: var(--theme-bg) !important;
  color: var(--theme-text) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

body[data-page="admin"] {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   TIPOGRAFÍA Y BÁSICOS
   ========================================================================== */
h1, h2, h3, h4, p { margin: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 3vw, 2.1rem); font-weight: 600; line-height: 1.2; }
h2 { margin-bottom: 10px; font-size: clamp(1.4rem, 3vw, 1.95rem); font-weight: 600; line-height: 1.2; }
h3 { margin-bottom: 0; font-size: 1rem; font-weight: 600; line-height: 1.2; }

.eyebrow,
.login-modal__eyebrow {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--theme-muted);
  margin-bottom: 6px;
}

.muted {
  color: var(--theme-muted) !important;
}

.small-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--theme-muted);
}

.hidden {
  display: none !important;
}

.stack {
  display: flex;
  flex-direction: column;
}

.gap-l {
  gap: 21.6px;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.glass-card {
  background: var(--theme-surface) !important;
  border: 0.9px solid var(--theme-border) !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--radius-lg);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ==========================================================================
   BOTONES
   ========================================================================== */
.btn,
.session-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7.2px;
  border: 0.9px solid transparent;
  border-radius: var(--radius-md);
  padding: 10.8px 21.6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:active,
.session-button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(0.9px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary,
.primary-button {
  background: var(--theme-accent);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
.primary-button:hover {
  background: var(--theme-accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-soft,
.btn-secondary,
.session-button {
  background: var(--theme-surface);
  color: var(--theme-text);
  border-color: var(--theme-border);
}

.btn-soft:hover,
.btn-secondary:hover,
.session-button:hover {
  background: var(--theme-accent) !important;
  color: #ffffff !important;
  border-color: var(--theme-accent) !important;
  box-shadow: 0 4px 12px rgba(51, 170, 238, 0.35) !important;
  opacity: 1 !important;
}

.btn-block {
  width: 100%;
}

.dialog-actions {
  display: flex;
  gap: 14.4px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 21.6px;
  border-top: 0.9px solid var(--theme-border);
}

.dialog-actions--inline {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ==========================================================================
   FORMULARIOS
   ========================================================================== */
input,
textarea,
select {
  width: 100%;
  background: var(--theme-surface);
  color: var(--theme-text);
  border: 0.9px solid var(--theme-border);
  border-radius: var(--radius-md);
  padding: 10.8px 14.4px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-size: 0.95rem;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 2.7px var(--theme-accent-soft);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

.field {
  display: grid;
  gap: 5.4px;
}

.field span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--theme-text);
}

.form-error,
.form-message {
  min-height: 20px;
  margin: 0;
  font-size: 0.92rem;
}

.form-error { color: var(--theme-danger); }
.form-message { color: var(--theme-muted); }

/* ==========================================================================
   INDEX.HTML (SUITE HOME)
   ========================================================================== */
.shell {
  width: min(1100px, calc(100% - 64px));
  min-height: calc(100vh - 88px);
  margin: 0 auto;
  padding: 24px 0 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.session-floating {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1200;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  min-height: 68px;
}

.company-logo {
  width: auto;
  max-width: min(290px, 42vw);
  max-height: 74px;
  object-fit: contain;
  display: block;
}

.topbar-right {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.datetime {
  padding-top: 4px;
  text-align: right;
}

.datetime__time {
  font-size: clamp(1.55rem, 2vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.datetime__date {
  margin-top: 8px;
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--theme-muted);
  text-transform: capitalize;
}

.search-section {
  margin-bottom: 44px;
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 14px 12px 20px;
  background: var(--theme-surface);
  border: 0.9px solid var(--theme-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.searchbar:focus-within {
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 2.7px var(--theme-accent-soft), var(--shadow-md);
}

.searchbar__icon {
  width: 22px;
  height: 22px;
  fill: var(--theme-muted);
  flex: 0 0 auto;
}

.searchbar__input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  font-size: 1.08rem;
  color: var(--theme-text);
}

.searchbar__input:focus {
  border: none;
  box-shadow: none;
}

.searchbar__button {
  border: 0;
  min-width: 68px;
  height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  background: var(--theme-surface-hover);
  color: var(--theme-text);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  border: 0.9px solid var(--theme-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.searchbar__button:hover {
  background: var(--theme-accent);
  color: #ffffff;
  border-color: var(--theme-accent);
  box-shadow: 0 4px 12px rgba(51, 170, 238, 0.35);
}

.apps-panel { width: 100%; }

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 22px;
}

.app-link {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-height: auto;
  padding: 14px 8px;
  color: var(--theme-text);
  cursor: pointer;
  text-align: center;
}

.app-icon {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--theme-surface);
  box-shadow: var(--shadow-sm);
  border: 0.9px solid var(--theme-border);
  transition: all 0.2s ease;
}

.app-icon svg {
  width: 34px;
  height: 34px;
  fill: var(--theme-text);
  transition: fill 0.2s ease;
}

.app-name { font-size: 0.95rem; font-weight: 500; }
.is-ghost { opacity: 0.42; cursor: default; }

.is-live:hover .app-icon,
.is-live:focus-visible .app-icon {
  transform: translateY(-3px);
  border-color: rgba(51, 170, 238, 0.4);
  box-shadow: var(--shadow-md);
}

.is-live:hover .app-icon svg { fill: var(--theme-accent); }

/* Modal Login */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
}

.login-modal {
  position: relative;
  width: min(460px, 100%);
  padding: 43.2px 36px;
  border-radius: var(--radius-xl);
  background: var(--theme-surface);
  border: 0.9px solid var(--theme-border);
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0.9px solid var(--theme-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--theme-surface);
  color: var(--theme-text);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 9px 21.6px rgba(15, 23, 42, 0.12);
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--theme-accent);
  color: #ffffff;
  border-color: var(--theme-accent);
  box-shadow: 0 12.6px 28.8px rgba(51, 170, 238, 0.22);
}

.login-modal__brand {
  display: flex;
  align-items: center;
  gap: 14.4px;
  margin-bottom: 14.4px;
}

.login-modal__logo {
  width: 57.6px;
  height: 57.6px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.login-modal__copy {
  margin-bottom: 21.6px;
  color: var(--theme-muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.login-form { display: grid; gap: 18px; }


/* ==========================================================================
   USERS.HTML (ADMIN SHELL - MAILDESK STYLE)
   ========================================================================== */

body[data-page="admin"] .admin-shell {
  --admin-page-pad-x: 43.2px;
  --admin-sidebar-width: 234px;
  --admin-shell-gap: 36px;
  width: var(--page-max);
  height: 100vh;
  padding: 95px var(--admin-page-pad-x) 12px var(--admin-page-pad-x);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--admin-sidebar-width) minmax(0, 1fr);
  gap: var(--admin-shell-gap);
  align-items: stretch;
  overflow: hidden;
}

body[data-page="admin"] .sidebar {
  position: relative;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 7.2px 0 0;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  overflow-x: clip;
}

.sidebar-nav {
  display: grid;
  gap: 5.4px;
  margin: 0 0 36px;
}

.nav-chip,
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 7.2px;
  text-align: left;
  border: none;
  padding: 10.8px 14.4px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--theme-muted);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-chip:hover,
.nav-item:hover {
  background: var(--theme-surface-hover);
  color: var(--theme-text);
}

.nav-chip.is-active,
.nav-item.is-active {
  background: var(--theme-accent-soft);
  color: var(--theme-accent);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 21.6px;
  border-top: 0.9px solid var(--theme-border);
  display: flex;
  flex-direction: column;
  gap: 14.4px;
}

.sidebar-credit {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--theme-muted);
  text-align: center;
}

.user-pill {
  margin-top: 10.8px;
  padding: 7.2px 12.6px;
  background: var(--theme-surface);
  border: 0.9px solid var(--theme-border);
  border-radius: 899.1px;
  display: inline-flex;
  align-items: center;
  gap: 7.2px;
  font-size: 0.85rem;
  font-weight: 500;
}

.user-email {
  margin-top: 8px;
  line-height: 1.45;
  word-break: break-word;
}

body[data-page="admin"] .main-content {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.main-scroll-area {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: clip;
  padding-right: 7.2px;
  display: grid;
  align-content: start;
  gap: 28.8px;
}

body[data-page="admin"] .topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  width: 100%;
  min-height: 84px;
  padding: 10px var(--admin-page-pad-x) 10px calc(var(--admin-page-pad-x) + var(--admin-sidebar-width) + var(--admin-shell-gap));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 21.6px;
  margin-bottom: 0;
  background: #ffffff !important;
  border: none !important;
  border-bottom: 0.9px solid var(--theme-border) !important;
  box-shadow: var(--shadow-sm) !important;
  border-radius: 0;
}

body[data-page="admin"] .topbar__brand {
  display: flex;
  align-items: center;
  gap: 21.6px;
  min-width: 0;
}

body[data-page="admin"] .topbar__brand-copy {
  min-width: 0;
}

.brand__logo--sidebar {
  width: 150px;
  height: 90px;
  margin: 0;
  position: absolute;
  left: calc(var(--admin-page-pad-x) + (var(--admin-sidebar-width) / 2) - 75px);
  top: 50%;
  transform: translateY(-50%);
  object-fit: contain;
}

body[data-page="admin"] .topbar h2 {
  font-size: 2.2rem;
  letter-spacing: -0.03em;
}

body[data-page="admin"] .topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10.8px;
  margin-left: auto;
  position: relative;
  flex: 0 0 auto;
}

.topbar-icon-btn {
  position: relative;
  width: 43.2px;
  height: 43.2px;
  border: 0.9px solid var(--theme-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--theme-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.topbar-icon-btn:hover {
  background: var(--theme-accent-soft);
  color: var(--theme-accent);
  border-color: rgba(51, 170, 238, 0.35);
  transform: translateY(-0.9px);
}

.content-section {
  display: grid;
  gap: 28.8px;
  min-height: 0;
}

.users-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 28.8px;
  margin: 15px 0px 0px 0px;
}

.panel {
  padding: 36px;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14.4px;
  margin-bottom: 28.8px;
  padding-bottom: 14.4px;
  border-bottom: 0.9px solid var(--theme-border);
}

.panel__header--with-actions {
  align-items: center;
}

.mail-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10.8px;
}

.empty-state {
  padding: 72px 28.8px;
  text-align: center;
  background: var(--theme-surface);
  border: 0.9px dashed #cbd5e1;
  border-radius: var(--radius-lg);
}

/* Tablas, Pills y Listas de Sesiones */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.users-table th,
.users-table td {
  padding: 14.4px 10px;
  border-bottom: 0.9px solid var(--theme-border);
  text-align: left;
  vertical-align: middle;
}

.users-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--theme-muted);
  font-weight: 600;
}

.users-table tr:hover td {
  background: var(--theme-surface-hover);
}

.table-actions {
  display: flex;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5.4px;
  border-radius: 999px;
  padding: 5.4px 12.6px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--theme-ok-bg);
  color: var(--theme-ok);
  border: 0.9px solid rgba(16, 185, 129, 0.2);
}

.status-pill.is-off {
  background: var(--theme-danger-bg);
  color: var(--theme-danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.sessions-list {
  display: grid;
  gap: 14.4px;
}

.session-card {
  border-radius: var(--radius-md);
  padding: 18px;
  background: var(--theme-surface);
  border: 0.9px solid var(--theme-border);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.session-card:hover {
  transform: translateY(-0.9px);
  box-shadow: var(--shadow-sm);
  border-color: #cbd5e1;
}

.session-card strong {
  font-size: 1rem;
  color: var(--theme-text);
  display: block;
  margin-bottom: 8px;
}

.session-meta {
  color: rgba(15, 23, 42, 0.72);
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}

/* ==========================================================================
   MEDIA QUERIES
   ========================================================================== */
@media (max-width: 1366px) {
  body[data-page="admin"] .admin-shell {
    --admin-page-pad-x: 28.8px;
    --admin-sidebar-width: 198px;
    --admin-shell-gap: 36px;
    grid-template-columns: var(--admin-sidebar-width) 1fr;
    padding: 115px var(--admin-page-pad-x) 12px;
  }
}

@media (max-width: 1024px) {
  body[data-page="admin"] {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: clip;
  }

  body[data-page="admin"] .admin-shell {
    --admin-page-pad-x: 28.8px;
    --admin-sidebar-width: 0px;
    --admin-shell-gap: 0px;
    grid-template-columns: 1fr;
    width: 100%;
    height: auto;
    min-height: 100vh;
    padding: 28.8px;
    overflow: visible;
  }

  body[data-page="admin"] .topbar {
    position: static;
    width: 100%;
    padding: 16px 18px;
    margin-bottom: 0;
    border-radius: var(--radius-lg);
    border: 0.9px solid var(--theme-border) !important;
  }

  .brand__logo--sidebar {
    position: static;
    width: 110px;
    height: 64px;
    transform: none;
    left: auto;
    top: auto;
  }

  body[data-page="admin"] .sidebar {
    position: static;
    top: auto;
    border-bottom: 0.9px solid var(--theme-border) !important;
    padding: 0 0 21.6px 0;
    margin-bottom: 7.2px;
    min-height: auto;
    max-height: none;
    overflow: visible;
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 7.2px;
    margin: 14.4px 0;
  }

  .sidebar-footer {
    display: none;
  }

  body[data-page="admin"] .main-content {
    overflow: visible;
  }

  .main-scroll-area {
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .users-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .shell {
    width: min(100%, calc(100% - 28px));
    padding: 20px 0 32px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    margin-top: 14px;
  }

  .session-floating {
    top: 12px;
    right: 12px;
  }

  .apps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .app-icon {
    width: 72px;
    height: 72px;
  }

  .users-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 87.5%;
  }

  .login-modal,
  .panel {
    padding: 24px;
  }

  .dialog-actions,
  .mail-detail-actions {
    flex-direction: column;
  }

  .dialog-actions .btn,
  .mail-detail-actions .btn {
    width: 100%;
  }
}