@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --bg: #f4f6fb;
  --bg-subtle: #eef1f8;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.35);
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --sidebar-bg: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #3730a3 100%);
  --sidebar-w: 272px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* ——— Login ——— */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(79, 70, 229, 0.12), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.1), transparent 40%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2.75rem 2.5rem;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.login-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px var(--primary-glow);
}

.login-card h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card .subtitle {
  color: var(--text-secondary);
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.login-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 420px));
  gap: 1.25rem;
  width: 100%;
  max-width: 900px;
  align-items: stretch;
}

.login-card-extension {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

.login-extension-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.login-extension-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.login-extension-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #dbeafe, #c7d2fe);
  color: #4338ca;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.login-extension-steps {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.login-extension-steps ol {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}

.login-extension-steps p {
  margin: 0;
}

.login-form-block .form-row {
  margin-bottom: 0.75rem;
}

.login-form-block label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-secondary);
}

.login-form-block input[type="text"],
.login-form-block input[type="password"],
.login-form-block .input-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
}

.login-form-block input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-block {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 1rem;
  justify-content: center;
}

.btn-download-ext {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #4338ca;
}

.btn-download-ext:hover {
  background: #e0e7ff;
}

.login-hint {
  margin: 0.65rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 720px) {
  .login-layout {
    grid-template-columns: 1fr;
    max-width: 420px;
  }
}

/* ——— Shell ——— */
.portal-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #e0e7ff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 200;
  box-shadow: 4px 0 24px rgba(30, 27, 75, 0.2);
}

.sidebar-brand {
  padding: 1.5rem 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: #fff;
}

.sidebar-brand-text small {
  display: block;
  font-weight: 500;
  font-size: 0.7rem;
  opacity: 0.7;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar nav {
  flex: 1;
  padding: 1rem 0.85rem;
  overflow-y: auto;
}

.nav-section {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45);
  padding: 1rem 0.75rem 0.4rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}

.user-chip strong {
  display: block;
  font-size: 0.85rem;
  color: #fff;
  font-weight: 600;
}

.user-chip span {
  font-size: 0.75rem;
  opacity: 0.65;
}

/* ——— Main ——— */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.topbar-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.main-content {
  padding: 1.75rem 2rem 2.5rem;
  flex: 1;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ——— Stats ——— */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-weight: 500;
}

/* ——— Cards ——— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card + .card { margin-top: 1.25rem; }

.card-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-hover);
}

.card-body { padding: 1.35rem; }

.info-banner {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  color: var(--primary-dark);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.info-banner svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* ——— Table ——— */
.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table th,
table.data-table td {
  padding: 0.85rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

table.data-table tbody tr {
  transition: background var(--transition);
}

table.data-table tbody tr:hover td {
  background: var(--surface-hover);
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

.cell-title strong {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.cell-title small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-public {
  background: var(--success-bg);
  color: var(--success);
}

.badge-personal {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.badge-staff {
  background: var(--primary-light);
  color: var(--primary);
}

/* ——— Forms ——— */
.form-grid {
  display: grid;
  gap: 1.15rem;
  max-width: 560px;
}

.form-section-title {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-row input,
.form-row select,
.form-row textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row .helptext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-row .errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 500;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.form-check input { width: 1rem; height: 1rem; accent-color: var(--primary); }

.checkbox-list {
  display: grid;
  gap: 0.45rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.85rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: background var(--transition);
}

.checkbox-list label:hover { background: var(--surface); }

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.4rem 0.6rem;
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--danger);
}

.btn-icon svg { width: 16px; height: 16px; }

/* ——— Filters ——— */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  align-items: center;
}

.filters-bar input,
.filters-bar select {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  min-width: 140px;
}

.filters-bar input[type="search"] { flex: 1; min-width: 200px; }

/* ——— Messages ——— */
.messages {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}

.messages li {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.messages .success {
  background: var(--success-bg);
  border: 1px solid #a7f3d0;
  color: #047857;
}

.messages .error {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.messages .warning {
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  color: #b45309;
}

/* ——— Pagination ——— */
.pagination {
  display: flex;
  gap: 0.65rem;
  margin-top: 1.25rem;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem !important;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

/* ——— Users ——— */
.filters-bar-users { position: relative; padding-left: 2.75rem; }
.filters-bar-users .filters-icon {
  position: absolute;
  left: 1.15rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.user-card:hover {
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
}

.user-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.user-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.user-card-identity { flex: 1; min-width: 0; }

.user-card-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.user-card-username {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.user-card-badges {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-end;
}

.badge-inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-super {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}

.user-card-meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.user-card-meta li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border);
}

.user-card-meta li:last-child { border-bottom: none; }

.meta-label { color: var(--text-muted); font-weight: 500; }
.meta-value { color: var(--text); text-align: right; word-break: break-word; }

.user-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

.user-card-actions .btn { flex: 1; }

.user-toggle-form {
  display: contents;
}

.empty-state-card {
  text-align: center;
  padding: 3.5rem 2rem;
}

.empty-state-card h3 { margin: 0.5rem 0 0.35rem; }

.empty-state-card p {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

/* ——— Access / permissions ——— */
.access-form { display: grid; gap: 1.25rem; max-width: 880px; }

.access-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.access-section-header {
  display: flex;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border);
}

.access-section-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.access-section-header p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.access-section-header code {
  font-size: 0.8em;
  background: var(--bg-subtle);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.access-section-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--primary);
  background: var(--primary-light);
}

.access-section-icon-favorites {
  color: #d97706;
  background: var(--warning-bg);
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.65rem;
  padding: 1.15rem 1.35rem;
}

.perm-grid-single { grid-template-columns: 1fr; max-width: 480px; }

.perm-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface);
}

.perm-toggle:hover { border-color: #a5b4fc; background: var(--bg-subtle); }

.perm-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.perm-toggle-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--border-strong);
  flex-shrink: 0;
  position: relative;
  transition: background var(--transition);
  margin-top: 2px;
}

.perm-toggle-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition);
}

.perm-toggle input:checked + .perm-toggle-ui {
  background: var(--primary);
}

.perm-toggle input:checked + .perm-toggle-ui::after {
  transform: translateX(20px);
}

.perm-toggle input:focus-visible + .perm-toggle-ui {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.perm-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.perm-toggle-text strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.perm-toggle-text small {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.access-form-footer {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.alert-banner {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  max-width: 880px;
}

.alert-banner-info {
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  color: var(--primary-dark);
}

.alert-banner-muted {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ——— User edit form ——— */
.user-edit-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.user-edit-panel .card-body { padding: 1.35rem; }

.form-grid-wide { max-width: none; }

.form-row-full { grid-column: 1 / -1; }

.panel-hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.checkbox-chip:has(input:checked) {
  background: var(--primary-light);
  border-color: #a5b4fc;
  color: var(--primary-dark);
}

.checkbox-chip input { accent-color: var(--primary); }

.user-edit-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ——— Favorites ——— */
.stats-grid-compact {
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  max-width: 480px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-pill {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--transition);
}

.filter-pill:hover {
  border-color: #a5b4fc;
  color: var(--primary);
}

.filter-pill.active {
  background: var(--primary-light);
  border-color: #a5b4fc;
  color: var(--primary-dark);
}

.favorite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.favorite-grid-9 {
  grid-template-columns: repeat(3, 1fr);
}

.bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.bulk-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.bulk-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 120px;
}

.favorite-card-selectable {
  position: relative;
}

.favorite-card-check {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 2;
  cursor: pointer;
}

.favorite-card-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}

.favorite-card-selectable .favorite-card-top {
  padding-left: 1.35rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.favorite-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.favorite-card:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow);
}

.favorite-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.favorite-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
  display: grid;
  place-items: center;
}

.favorite-card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.favorite-card-url {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--primary);
  word-break: break-all;
  line-height: 1.4;
}

.favorite-card-url svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.favorite-card-meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.favorite-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

/* ——— Import favorites ——— */
.import-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

.import-steps {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.import-steps li { margin-bottom: 0.35rem; }

.import-example {
  margin: 1rem 0;
}

.import-example-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.import-example-code {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.import-textarea {
  min-height: 220px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}

.import-options-grid {
  display: grid;
  gap: 1rem;
  margin-top: 0.5rem;
}

.import-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.import-check input {
  margin-top: 0.2rem;
  accent-color: var(--primary);
}

.import-parse-errors {
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.import-parse-errors ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.import-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  margin-top: 1rem;
  overflow: hidden;
}

.import-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.import-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

.import-preview-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.import-preview-list li:last-child { border-bottom: none; }

.import-preview-title { font-weight: 600; color: var(--text); }
.import-preview-url { color: var(--text-muted); word-break: break-all; }

.import-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ——— Catalog (municípios / grupos) ——— */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.catalog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.catalog-card:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow);
}

.catalog-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.catalog-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.catalog-card-icon-municipio {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1d4ed8;
}

.catalog-card-icon-grupo {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #6d28d9;
}

.catalog-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.catalog-card-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.catalog-card-desc-empty {
  color: var(--text-muted);
  font-style: italic;
}

.catalog-card-stats {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.catalog-card-stats li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.55rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

.catalog-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.badge-muted {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-danger-text {
  color: var(--danger);
}

.btn-danger-text:hover {
  background: var(--danger-bg);
  color: #b91c1c;
}

.filter-select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  min-width: 150px;
}

.form-card-narrow {
  max-width: 520px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

/* ——— Confirm modal ——— */
.portal-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.portal-modal.hidden {
  display: none;
}

.portal-modal-open {
  overflow: hidden;
}

.portal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.portal-modal-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  text-align: center;
}

.portal-modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 0.85rem;
}

.portal-modal-icon-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.portal-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.portal-modal-message {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.portal-modal-detail {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  color: var(--warning-text, #b45309);
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  line-height: 1.4;
}

.portal-modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.portal-delete-fallback {
  text-align: center;
}

.portal-delete-fallback .portal-modal-message {
  margin-top: 0.5rem;
}

/* ——— Credentials ——— */
.stats-grid-wide {
  max-width: 560px;
}

.info-banner-compact {
  margin-bottom: 1rem;
  padding: 0.7rem 0.9rem;
}

.filters-bar-credentials {
  flex-wrap: wrap;
}

.credential-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.credential-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.credential-card:hover {
  border-color: #a7f3d0;
  box-shadow: var(--shadow);
}

.credential-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.credential-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #d1fae5, #6ee7b7);
  color: #047857;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.credential-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
}

.badge-municipio {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-2fa {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.credential-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.credential-card-meta {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.credential-card-meta li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.credential-card-meta li:only-child,
.credential-card-meta li:nth-child(3):last-child {
  grid-column: span 2;
}

.meta-value-mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.text-muted {
  color: var(--text-muted);
  font-style: italic;
}

.credential-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

/* Credential form */
.credential-form-layout {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 1.25rem;
  align-items: start;
}

.credential-form-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-section {
  overflow: hidden;
}

.form-section-header {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}

.form-section-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1d4ed8;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.form-section-icon-org {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #6d28d9;
}

.form-section-icon-lock {
  background: linear-gradient(135deg, #d1fae5, #6ee7b7);
  color: #047857;
}

.form-section-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.form-section-desc {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-section-body {
  padding: 1.15rem 1.25rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-grid-2 .span-2 {
  grid-column: span 2;
}

.input-control,
.form-section-body select,
.form-section-body input:not([type="checkbox"]),
.form-section-body textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-control:focus,
.form-section-body select:focus,
.form-section-body input:focus,
.form-section-body textarea:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.textarea-control {
  resize: vertical;
  min-height: 88px;
}

.password-field-wrap {
  position: relative;
  display: flex;
}

.password-field-wrap input {
  padding-right: 2.75rem;
}

.btn-password-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  display: grid;
  place-items: center;
}

.btn-password-toggle:hover {
  color: var(--primary);
  background: var(--bg-subtle);
}

.form-row-check {
  margin-top: 0.25rem;
}

.form-errors-banner {
  padding: 0.75rem 1rem;
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #b91c1c;
  font-size: 0.875rem;
}

.form-actions-sticky {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.25rem 0;
}

.form-actions-sticky .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.credential-form-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
}

.tips-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.tips-list li {
  margin-bottom: 0.5rem;
}

.import-options-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.import-preview-list-creds li {
  gap: 0.2rem;
}

.import-preview-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .main-content, .topbar { padding-left: 1.25rem; padding-right: 1.25rem; }
  .user-card-actions { flex-direction: column; }
  .import-layout { grid-template-columns: 1fr; }
  .favorite-grid,
  .favorite-grid-9 { grid-template-columns: 1fr; }
  .catalog-grid { grid-template-columns: 1fr; }
  .credential-grid { grid-template-columns: 1fr; }
  .credential-form-layout { grid-template-columns: 1fr; }
  .credential-form-aside { position: static; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 .span-2 { grid-column: span 1; }
  .import-options-grid-2 { grid-template-columns: 1fr; }
  .filters-bar { flex-wrap: wrap; }
  .filter-select { width: 100%; }
}
