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

:root {
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-input: #f1f5f9;
  --bg-hover: #f1f5f9;
  --bg-sidebar: #ffffff;
  
  --border-light: rgba(0, 0, 0, 0.04);
  --border-medium: rgba(0, 0, 0, 0.08);
  --border-strong: #e2e8f0;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --primary: #0f172a;
  --primary-hover: #334155;
  --accent: #2563eb;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-float: 0 20px 40px -8px rgba(0,0,0,0.08);
  
  --transition: all 0.2s ease-in-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-size: 0.9rem;
  height: 100vh;
  overflow: hidden;
  
}

.hidden { display: none !important; }

.material-symbols-outlined {
  font-size: 1.25rem;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

h1, h2, h3, h4, h5 {
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--text-main);
}

/* Layout */
.layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Hero / Login */
.hero {
  text-align: center;
  padding: 60px 20px 30px;
}
.hero .eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.hero .lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
}

.auth-panel {
  max-width: 380px;
  margin: 0 auto 60px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border-strong);
  padding: 40px;
}
.auth-panel .panel-header {
  margin-bottom: 24px;
  text-align: center;
}
.auth-panel .panel-header h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.auth-panel .panel-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Dashboard Top Header */


.dashboard-top {
  flex-shrink: 0;
  background: #1e293b; /* Dark slate corporate color */
  border-bottom: 1px solid #0f172a;
  padding: 24px 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: sticky;
  top: 0;
  z-index: 50;
}
.user-profile-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.avatar-circle {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}
.avatar-circle .material-symbols-outlined {
  font-size: 32px;
}
.user-profile-info {
  display: flex;
  flex-direction: column;
}
.user-profile-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.user-profile-title h2 {
  font-size: 1.25rem;
  margin: 0;
  color: #ffffff;
}
.user-profile-info .lead-small {
  margin: 0 0 8px 0;
  color: #cbd5e1;
}
.dashboard-top .badge {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.dashboard-top .btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.dashboard-top .btn.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}
/* Portal Switcher */
.portal-switcher {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-strong);
}
.portal-nav {
  display: flex;
  padding: 0 40px;
  gap: 32px;
}
.portal-nav-item {
  background: transparent;
  border: none;
  padding: 16px 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.portal-nav-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}
.portal-nav-item.active { color: var(--text-main); }
.portal-nav-item.active::after { transform: scaleX(1); }

/* Apps Workspace */
#apps-workspace {
  flex-grow: 1;
  overflow-y: auto;
  padding: 40px;
  background: var(--bg-body);
}
.selector-panel {
  max-width: 1200px;
  margin: 0 auto 32px;
}
.selector-panel .panel-header h2 {
  font-size: 1.25rem;
}
.selector-panel .panel-header p {
  color: var(--text-muted);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}
.app-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.app-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  border-color: #cbd5e1;
}

/* Admin View (Natural Scrolling) */

#admin-view {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.admin-panel {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
}
.admin-panel > .panel-header {
  display: none;
}
.admin-shell {
  display: flex;
  flex-grow: 1;
  overflow: hidden; /* Contains the sidebar and main area */
}


/* Admin Sidebar */
.admin-sidebar {
  width: 280px; /* Slightly wider for ERP consistency */
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-strong);
  padding: 24px 16px;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 32px;
}
.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.brand-text strong {
  font-size: 1.1rem;
}
.admin-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}
.admin-menu-item:hover {
  background: var(--bg-body);
  color: var(--text-main);
}
.admin-menu-item.active {
  background: var(--bg-input);
  color: var(--text-main);
  font-weight: 600;
}
.admin-menu-item.active .material-symbols-outlined {
  color: var(--accent);
}


/* Admin Main Content */
.admin-main {
  flex-grow: 1;
  padding: 40px;
  background: var(--bg-body);
  overflow-y: auto; /* Only this part scrolls */
}
.admin-section-panel {
  max-width: 1200px;
  margin: 0 auto;
}
.admin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.admin-card .card-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-card .card-header h3 {
  font-size: 1.15rem;
}
.admin-section-layout {
  display: grid;
  grid-template-columns: 360px 1fr; /* Better proportion */
  gap: 40px; /* More breathing room */
  padding: 32px;
}

.manual-shell {
  padding: 32px;
}

.manual-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.manual-toolbar .field {
  flex: 1;
}

.manual-status {
  padding: 18px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-body);
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 18px;
}

.manual-link-shell {
  padding: 28px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manual-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  text-decoration: none;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.manual-open-link:hover {
  background: #dbeafe;
}

.manual-content {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.manual-viewer-page {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.manual-viewer-layout {
  max-width: 1360px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.manual-viewer-header {
  margin-bottom: 24px;
}

.manual-viewer-hero {
  padding: 28px 32px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 50px -22px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(14px);
}

.manual-viewer-actions {
  margin-top: 16px;
}

.manual-viewer-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.manual-viewer-toc-card {
  position: sticky;
  top: 24px;
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-card);
}

.manual-viewer-toc-card h3 {
  margin-bottom: 14px;
}

.manual-viewer-toc {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.manual-viewer-toc a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 10px;
  transition: var(--transition);
}

.manual-viewer-toc a:hover {
  background: #eff6ff;
  color: var(--accent);
}

.manual-viewer-toc .toc-level-1 {
  font-weight: 700;
  color: var(--text-main);
}

.manual-viewer-toc .toc-level-2 {
  padding-left: 18px;
}

.manual-viewer-toc .toc-level-3,
.manual-viewer-toc .toc-level-4 {
  padding-left: 30px;
  font-size: 0.84rem;
}

.manual-viewer-body .manual-status {
  margin-bottom: 18px;
}

.manual-viewer-body .manual-content {
  overflow: visible;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 60px -30px rgba(15, 23, 42, 0.3);
}

.manual-heading {
  padding: 28px 32px 18px;
  border-bottom: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.72);
}

.manual-heading h1 {
  font-size: 1.55rem;
  margin-bottom: 6px;
}

.manual-prose {
  padding: 28px 32px 40px;
  color: var(--text-main);
}

.manual-prose h1,
.manual-prose h2,
.manual-prose h3,
.manual-prose h4 {
  margin: 24px 0 12px;
}

.manual-prose h1 {
  font-size: 1.45rem;
}

.manual-prose h2 {
  font-size: 1.2rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-strong);
}

.manual-prose h3 {
  font-size: 1.05rem;
}

.manual-prose h4 {
  font-size: 0.95rem;
}

.manual-prose p,
.manual-prose ul,
.manual-prose ol,
.manual-prose pre {
  margin: 0 0 14px;
}

.manual-prose ul,
.manual-prose ol {
  padding-left: 22px;
}

.manual-prose li + li {
  margin-top: 6px;
}

.manual-prose code {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 0.82rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.manual-code-block {
  padding: 16px 18px;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  overflow-x: auto;
}

.manual-code-block code {
  display: block;
  padding: 0;
  background: transparent;
  color: inherit;
  border-radius: 0;
  font-size: 0.8rem;
  line-height: 1.65;
  white-space: pre;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-tag.active {
  background: #dcfce7;
  color: #166534;
}

.status-tag.inactive {
  background: #e2e8f0;
  color: #475569;
}

/* Forms */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 0.9rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
button:hover {
  background: var(--primary-hover);
}
button.secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
}
button.secondary:hover {
  background: var(--bg-body);
}
button.small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Lists */
.list-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow-y: auto;
  max-height: 400px;
}
.list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.list-item-content h4 {
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.list-item-content p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.list-item > .list-row {
  width: 100%;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.list-row-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.list-row-content strong {
  font-size: 0.95rem;
  color: var(--text-main);
}

.list-row-content span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  min-width: 220px;
}

.list-actions button {
  white-space: nowrap;
}

.list-actions .secondary.small {
  background: #eff6ff;
  color: var(--primary);
  border-color: #bfdbfe;
  font-weight: 600;
}

.list-actions .secondary.small:hover {
  background: #dbeafe;
}

@media (max-width: 768px) {
  .list-row {
    flex-direction: column;
  }

  .list-actions {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

  .manual-shell {
    padding: 20px;
  }

  .manual-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .manual-viewer-grid {
    grid-template-columns: 1fr;
  }

  .manual-viewer-toc-card {
    position: static;
  }
}

/* Choice Grid (Checkboxes) */
.choice-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-body);
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 24px;
}
.stat-card {
  padding: 20px;
  background: var(--bg-body);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
}
.stat-card h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
}


#dashboard-view {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 100%;
  overflow: hidden;
}


.launch-button {
  margin-top: auto; /* Push to bottom */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  width: 100%;
}
.launch-button:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}


.app-card h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  color: var(--text-main);
}
.app-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
  flex-grow: 1;
}
.app-card .meta {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 8px;
  flex-grow: 0;
}


.estado {
  margin-bottom: 24px;
  padding: 12px 16px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: var(--radius-sm);
  border: 1px solid #bfdbfe;
  font-size: 0.9rem;
  font-weight: 500;
}
.estado:empty {
  display: none;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.lead-small {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}


.dashboard-top .mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(71, 85, 105, 0.4);
  border-radius: 999px;
  font-size: 0.75rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
}
.dashboard-top .mini-badge .company-name {
  color: #94a3b8;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.dashboard-top .mini-badge .role-name {
  color: #38bdf8;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
}
