/* ===== Variables (palette MEDEF) ===== */
:root {
  --navy: #1b2a4a;
  --navy-light: #243558;
  --red: #e30613;
  --red-hover: #c80510;
  --blue: #0055a4;
  --blue-light: #ebf2fa;
  --green: #16a34a;
  --green-bg: #ecfdf5;
  --orange: #e97b1e;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 8px rgba(27, 42, 74, 0.07);
  --shadow-lg: 0 4px 16px rgba(27, 42, 74, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ===== Reset ===== */
* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

body {
  font-family:
    "Barlow Condensed",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== Page de connexion ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(
    135deg,
    var(--navy) 0%,
    #2c3e6b 50%,
    var(--bg) 100%
  );
}

.login-box {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.login-header {
  background: var(--navy);
  padding: 1.5rem 2rem;
}

.login-header h1 {
  margin: 0;
  font-size: 1.35rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}

.login-logo {
  display: block;
  max-width: 220px;
  height: auto;
  margin: 0 auto;
}

.login-header .login-subtitle {
  margin: 0.35rem 0 0 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
  text-align: center;
}

.login-body {
  padding: 1.75rem 2rem 2rem;
}

.login-body form button[type="submit"] {
  margin-left: auto;
  display: block;
}

.login-footer {
  margin-top: 1.25rem;
  font-size: 0.9rem;
}

.login-footer a {
  color: var(--blue);
}

/* ===== Layout dashboard ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0 0.75rem;
  color: rgba(255, 255, 255, 0.85);
}

.sidebar-brand {
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 0.5rem;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.sidebar-logo {
  width: 42px;
  height: auto;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 0.5rem;
  overflow-y: auto;
}

.sidebar-section-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
  padding: 0.9rem 0.75rem 0.3rem;
  user-select: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 6px;
  transition:
    background 0.15s,
    color 0.15s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: rgba(227, 6, 19, 0.18);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}
.nav-link.active .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 0.5rem 1rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-logout {
  width: 100%;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.1s;
}

.btn-logout:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

/* ----- Zone principale ----- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.main-header {
  background: var(--card);
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.view-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}

.user-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
/* --- User avatar chip --- */
.hdr-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem 0.25rem 0.3rem;
  border-radius: 999px;
  background: rgba(0, 85, 164, 0.06);
  color: var(--text-main);
  text-decoration: none;
  transition:
    background 0.15s,
    box-shadow 0.15s;
  cursor: pointer;
}
.hdr-user-chip:hover {
  background: rgba(0, 85, 164, 0.12);
  box-shadow: 0 0 0 2px rgba(0, 85, 164, 0.15);
}
.hdr-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  text-transform: uppercase;
}
.hdr-email {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr-user-chip:hover .hdr-email {
  color: var(--blue);
}
/* --- End user chip --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--text-muted);
  transition:
    background 0.15s,
    color 0.15s;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.header-icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.header-icon-btn:hover {
  background: rgba(0, 85, 164, 0.08);
  color: var(--blue);
}
.header-divider {
  width: 1px;
  height: 20px;
  background: var(--clr-border);
  margin: 0 0.25rem;
}
.btn-logout-header {
  padding: 0.3rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-logout-header:hover {
  background: #c0392b;
}
/* Power-icon logout button */
.hdr-logout-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(231, 76, 60, 0.1);
  color: var(--red);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    box-shadow 0.15s;
  padding: 0;
}
.hdr-logout-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hdr-logout-icon:hover {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

.main-content {
  flex: 1;
  padding: 1.75rem;
}

.main-footer {
  padding: 0.75rem 1.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  background: var(--card);
  border-top: 1px solid var(--border);
}

/* ===== Vues ===== */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* ===== KPIs ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-top: 3px solid var(--border);
  transition:
    box-shadow 0.2s,
    transform 0.2s;
}

.kpi-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* Filets de couleur sur les KPIs */
.kpi-card.kpi-accent-red {
  border-top-color: var(--red);
}
.kpi-card.kpi-accent-blue {
  border-top-color: var(--blue);
}
.kpi-card.kpi-accent-green {
  border-top-color: var(--green);
}
.kpi-card.kpi-accent-orange {
  border-top-color: var(--orange);
}
.kpi-card.kpi-accent-purple {
  border-top-color: #8b5cf6;
}

.kpi-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}

.kpi-card.kpi-accent-red .kpi-value {
  color: var(--red);
}
.kpi-card.kpi-accent-blue .kpi-value {
  color: var(--blue);
}
.kpi-card.kpi-accent-green .kpi-value {
  color: var(--green);
}
.kpi-card.kpi-accent-orange .kpi-value {
  color: var(--orange);
}
.kpi-card.kpi-accent-purple .kpi-value {
  color: #8b5cf6;
}

.kpi-value.ok {
  color: var(--green) !important;
}

.kpi-value.ko {
  color: #dc2626 !important;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Grille dashboard ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  min-height: 180px;
}

.card h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  padding-left: 0.75rem;
  border-left: 3px solid var(--red);
}
/* Dashboard cards override: icon replaces border-left */
.card-header h3 {
  margin: 0;
  font-size: 0.95rem;
  padding-left: 0;
  border-left: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Card header system --- */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
}
.card-header-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.card-icon-blue {
  background: var(--blue);
}
.card-icon-green {
  background: #16a34a;
}
.card-icon-orange {
  background: #d97706;
}
.card-icon-purple {
  background: #8b5cf6;
}
.card-icon-red {
  background: #dc2626;
}
.card-icon-indigo {
  background: #4f46e5;
}

.card-header-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.card-header-link:hover {
  opacity: 0.7;
}

.card-header-btn {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue);
  background: none;
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition:
    background 0.15s,
    color 0.15s;
}
.card-header-btn:hover {
  background: var(--blue);
  color: #fff;
}
.card-header-btn svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-list {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.dashboard-list-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.dashboard-list-item:last-child {
  border-bottom: none;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0 0;
}

/* ===== Formulaires ===== */
label {
  display: block;
  margin-top: 0.85rem;
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

input,
select {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.1);
}

button[type="submit"],
/* --- Shared button base --- */
.btn-primary,
.btn-secondary,
.btn-success {
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background 0.15s,
    box-shadow 0.15s;
  line-height: 1.4;
}

.btn-primary {
  background: var(--red);
  color: #fff;
  border: none;
}

button[type="submit"]:hover,
.btn-primary:hover {
  background: var(--red-hover);
  box-shadow: 0 2px 8px rgba(227, 6, 19, 0.2);
}

button:disabled {
  background: #9ca3af !important;
  cursor: not-allowed;
  box-shadow: none !important;
}

.btn-secondary {
  background: var(--blue-light);
  color: var(--navy);
  border: 1px solid rgba(0, 85, 164, 0.2);
}

.btn-secondary:hover {
  background: #d6e6f6;
}

.btn-success {
  background: var(--green);
  color: #fff;
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
  background: #15803d;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  margin-bottom: 0;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--red);
}

/* ===== Messages et alertes ===== */
.message {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.message.error {
  color: #dc2626;
}

.message.success {
  color: var(--green);
}

.hint {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.alert {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
}

.alert-success {
  background: var(--green-bg);
  color: #065f46;
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

/* ===== Table utilisateurs ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.users-table th,
.users-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.users-table td.wrap-cell {
  white-space: normal;
  word-break: break-word;
}

.users-table th {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.users-table tbody tr:hover {
  background: var(--blue-light);
}

/* Numeric / center columns */
.users-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.users-table .col-center {
  text-align: center;
}

/* ===== Toolbar (filters) ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar-input {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
}

.toolbar-select {
  min-width: 140px;
  max-width: 200px;
}

.toolbar-check {
  margin-top: 0 !important;
  font-size: 0.85rem;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.88rem;
}

.pagination button {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  background: var(--blue-light);
  color: var(--navy);
  border: 1px solid rgba(0, 85, 164, 0.2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.pagination button:hover:not(:disabled) {
  background: #d6e6f6;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--blue-light) !important;
}

.pagination .page-info {
  color: var(--text-muted);
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-admin {
  background: rgba(227, 6, 19, 0.1);
  color: var(--red);
}

.badge-user {
  background: var(--blue-light);
  color: var(--blue);
}

.badge-active {
  background: var(--green-bg);
  color: var(--green);
}

.badge-inactive {
  background: #fef2f2;
  color: #991b1b;
}

/* ===== Action buttons (inline) ===== */
.btn-action {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #fff;
  color: var(--text);
  transition:
    background 0.12s,
    border-color 0.12s;
}

.btn-action:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn-action.btn-danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.3);
}

.btn-action.btn-danger:hover {
  background: #fef2f2;
}

.btn-action.btn-success {
  color: var(--green);
  border-color: rgba(22, 163, 74, 0.3);
}

.btn-action.btn-success:hover {
  background: var(--green-bg);
}

.actions-cell {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ===== Export buttons ===== */
.export-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.export-buttons .btn-primary,
.export-buttons .btn-secondary {
  margin-top: 0;
}

/* ===== API Key display ===== */
.apikey-display {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.apikey-display strong {
  display: block;
  margin-bottom: 0.35rem;
  font-family: system-ui, sans-serif;
  color: #92400e;
  font-size: 0.8rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .sidebar-brand {
    width: 100%;
    padding: 0 0 0.5rem 0;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  }

  .sidebar-section-label {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
    margin-bottom: 0;
    padding: 0;
  }

  .nav-link {
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    gap: 0.35rem;
  }

  .nav-icon {
    width: 15px;
    height: 15px;
  }

  .nav-link.active {
    border-bottom: 2px solid var(--red);
    background: rgba(255, 255, 255, 0.1);
  }

  .sidebar-footer {
    width: 100%;
    padding: 0.5rem 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  .btn-logout {
    width: auto;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .main-content {
    padding: 1rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .card {
    min-height: auto;
  }

  .perf-kpi-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ===== Performance KPIs ===== */
.perf-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.perf-kpi-row .kpi-value {
  font-size: 1.6rem;
}

/* Memory bars */
.perf-mem-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.perf-mem-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.perf-mem-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 90px;
  font-weight: 500;
}

.perf-mem-value {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
  min-width: 80px;
  text-align: right;
}

.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 5px;
  transition: width 0.5s ease;
  min-width: 0;
}

.progress-fill-blue {
  background: var(--blue);
}

.progress-fill-orange {
  background: var(--orange);
}

.progress-fill-red {
  background: var(--red);
}

/* HTTP status grid */
.perf-status-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.perf-status-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.perf-status-item .badge {
  min-width: 60px;
  text-align: center;
  font-size: 0.9rem;
  padding: 0.3rem 0.6rem;
}

.perf-status-label {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.perf-badge-5xx {
  background: #fef2f2;
  color: #dc2626;
}

.perf-auto-refresh {
  margin-top: 1.25rem;
  text-align: right;
  font-size: 0.8rem;
}

/* ===== Forgot Password Link ===== */
.forgot-password-link {
  margin-top: 0.5rem;
  font-size: 0.88rem;
}

.forgot-password-link a {
  color: var(--blue);
}

/* ===== Maintenance Banner ===== */
.maintenance-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #92400e;
}

.maintenance-banner::before {
  content: "\26A0";
  font-size: 1.1rem;
}

/* ===== Maintenance Settings ===== */
.maintenance-status-box {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.maintenance-actions .btn-action {
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
}

/* ===== Email verification badge ===== */
.badge-verified {
  background: var(--green-bg);
  color: var(--green);
}

.badge-unverified {
  background: #fef3c7;
  color: #92400e;
}

/* ===== PM2 & Security Info ===== */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.info-item {
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.info-item .info-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.info-item .info-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.pm2-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.pm2-badge.active {
  background: var(--green-bg);
  color: var(--green);
}

.pm2-badge.inactive {
  background: var(--bg);
  color: var(--text-muted);
}

/* Security stats now use dash-data-grid */

/* ===== Charts ===== */
.chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}

/* ===== Sessions ===== */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: #fff;
  transition: box-shadow 0.15s;
}
.session-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.session-current {
  border-left: 3px solid var(--clr-brand);
}
.session-info {
  flex: 1;
  min-width: 0;
}
.session-device {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}
.session-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--clr-text-muted);
}
.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--clr-border);
}
.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--clr-text-muted);
  line-height: 1;
}
.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--clr-border);
}

.perm-group {
  margin-bottom: 0.75rem;
}
.perm-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  cursor: pointer;
}
.perm-group label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

/* ===== Sync badges ===== */
.badge-warning {
  background: #f59e0b;
  color: #fff;
}
.badge-danger {
  background: #ef4444;
  color: #fff;
}
.badge-info {
  background: #3b82f6;
  color: #fff;
}

/* ===== Ohme KPI sections ===== */
.ohme-kpi-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.ohme-kpi-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ohme-kpi-title code {
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}
.ohme-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.ohme-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem 0.5rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--clr-border);
  transition:
    box-shadow 0.15s,
    transform 0.15s;
}
.ohme-kpi:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.ohme-kpi[data-accent="blue"] {
  border-top: 3px solid var(--blue);
}
.ohme-kpi[data-accent="green"] {
  border-top: 3px solid var(--green);
}
.ohme-kpi[data-accent="orange"] {
  border-top: 3px solid var(--orange);
}
.ohme-kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 0.25rem;
}
.ohme-kpi[data-accent="blue"] .ohme-kpi-value {
  color: var(--blue);
}
.ohme-kpi[data-accent="green"] .ohme-kpi-value {
  color: var(--green);
}
.ohme-kpi[data-accent="orange"] .ohme-kpi-value {
  color: var(--orange);
}
.ohme-kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.ohme-kpi-api {
  font-size: 0.72rem;
  margin-top: 0.35rem;
  color: var(--text-muted);
}
.ohme-live-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #22c55e;
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  vertical-align: middle;
  margin-left: 0.5rem;
  animation: ohme-pulse 2s ease-in-out infinite;
}
@keyframes ohme-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@media (max-width: 600px) {
  .ohme-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Ohme tags grid ===== */
.ohme-tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.ohme-tag-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  user-select: none;
}
.ohme-tag-label:hover {
  background: rgba(0, 85, 164, 0.06);
  border-color: var(--blue);
}
.ohme-tag-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--blue);
}
.ohme-tag-label input[type="checkbox"]:checked + span {
  font-weight: 600;
  color: var(--blue);
}

/* ===== Crons page ===== */

/* -- Group -- */
.cron-group {
  margin-bottom: 1.5rem;
}
.cron-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--clr-border);
}
.cron-group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cron-group-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cron-group-count {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--clr-border);
  color: var(--text-muted);
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
}

/* -- Row -- */
.cron-row {
  display: grid;
  grid-template-columns: 6px 1fr 380px;
  gap: 0 1.25rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--clr-border);
  align-items: start;
}
.cron-row:last-child {
  border-bottom: none;
}
.cron-row-off {
  opacity: 0.45;
}

.cron-row-indicator {
  width: 6px;
  border-radius: 3px;
  align-self: stretch;
  margin: 2px 0;
}
.cron-on {
  background: #22c55e;
}
.cron-off {
  background: #ef4444;
}

.cron-row-main {
  min-width: 0;
}
.cron-row-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.3;
  margin-bottom: 0.15rem;
}
.cron-row-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* -- Details column -- */
.cron-row-details {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
}
.cron-detail {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.cron-detail-label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 105px;
  flex-shrink: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cron-detail-value {
  min-width: 0;
  word-break: break-word;
}
.cron-freq-text {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
}

/* -- Shared -- */
.cron-expr {
  font-size: 0.76rem;
  background: var(--bg-code, #f1f5f9);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: monospace;
  white-space: nowrap;
}
.cron-error {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #dc2626;
  background: #fef2f2;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.25rem;
  cursor: help;
}

@media (max-width: 768px) {
  .cron-row {
    grid-template-columns: 6px 1fr;
  }
  .cron-row-details {
    grid-column: 2;
    margin-top: 0.4rem;
  }
}

/* ===== Settings page (stg-*) ===== */

.stg-card {
  padding: 1.25rem 1.5rem;
  min-height: auto;
  margin-bottom: 1.25rem;
}
.stg-card:last-child {
  margin-bottom: 0;
}

.stg-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.35rem 0 !important;
  font-size: 0.95rem !important;
  padding-left: 0 !important;
  border-left: none !important;
}

.stg-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--navy);
}

.stg-hint {
  margin: 0 0 0.75rem !important;
  font-size: 0.8rem !important;
  color: var(--text-muted);
}

/* -- Form row: fields + buttons aligned -- */
.stg-form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* -- Field -- */
.stg-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.stg-field label {
  margin: 0 !important;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  line-height: 1.4;
}
.stg-field input,
.stg-field select {
  height: 38px !important;
  padding: 0 0.75rem !important;
  font-size: 0.9rem !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}
.stg-field select {
  padding-right: 2rem !important;
  cursor: pointer;
}
.stg-field input:focus,
.stg-field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(0, 85, 164, 0.12);
}
.stg-field-grow {
  flex: 1;
  min-width: 200px;
}
.stg-field-fixed {
  flex: 0 0 auto;
  min-width: 130px;
}
.stg-field-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* -- 4-column grid -- */
.stg-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
@media (max-width: 768px) {
  .stg-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* -- Buttons -- */
.stg-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  /* Match label height (0.72rem * 1.4) + flex gap (0.2rem) to align buttons with inputs */
  padding-top: calc(0.72rem * 1.4 + 0.2rem);
}

.stg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background 0.15s,
    box-shadow 0.15s,
    border-color 0.15s;
  margin: 0;
  line-height: 1;
}

.stg-btn-primary {
  background: var(--red);
  color: #fff;
}
.stg-btn-primary:hover {
  background: var(--red-hover);
  box-shadow: 0 2px 8px rgba(227, 6, 19, 0.2);
}

.stg-btn-secondary {
  background: var(--blue-light);
  color: var(--navy);
  border: 1px solid rgba(0, 85, 164, 0.18);
}
.stg-btn-secondary:hover {
  background: #d6e6f6;
}

.stg-btn-outline-danger {
  background: #fff;
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.3);
}
.stg-btn-outline-danger:hover {
  background: #fef2f2;
}

.stg-btn-outline-success {
  background: #fff;
  color: var(--green);
  border: 1px solid rgba(22, 163, 74, 0.3);
}
.stg-btn-outline-success:hover {
  background: var(--green-bg);
}

.stg-btn:disabled {
  background: #9ca3af !important;
  color: #fff !important;
  cursor: not-allowed;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* -- Checkbox -- */
.stg-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem !important;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}
.stg-checkbox input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  accent-color: var(--red);
  cursor: pointer;
}

/* -- Separator + sub-title -- */
.stg-separator {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.stg-sub-title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}
.stg-history {
  font-size: 0.82rem;
}

/* Legacy compat — keep old class names working */
.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.settings-field label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.settings-field-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ===== Dashboard redesign ===== */
.dash-data-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.dash-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem 0.25rem;
  border-radius: 6px;
  background: var(--bg-subtle, #f8fafc);
}
.dash-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}
.dash-data-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.dash-data-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}
.dash-stat-sync {
  color: #16a34a;
}
.dash-stat-error {
  color: #dc2626;
}
.dash-stat-warn {
  color: #d97706;
}
.dash-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: center;
}
.dash-sync-last {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  background: var(--bg-subtle, #f8fafc);
}
.dash-sync-err {
  color: #dc2626;
}
.dash-sync-label {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dash-mini-stats {
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
  align-items: center;
}

@media (max-width: 600px) {
  .dash-data-grid,
  .dash-data-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== Security page ===== */
.sec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.sec-table th {
  text-align: left;
  padding: 0.5rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--clr-border);
  white-space: nowrap;
}
.sec-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--clr-border);
  vertical-align: middle;
  white-space: nowrap;
}
.sec-table tbody tr:hover {
  background: rgba(0, 85, 164, 0.03);
}
.sec-table code {
  font-size: 0.82rem;
  background: var(--bg-code, #f1f5f9);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
.sec-table-sm {
  font-size: 0.82rem;
}
.sec-table-sm th {
  font-size: 0.68rem;
}
.sec-table-sm td {
  padding: 0.35rem 0.5rem;
}

.sec-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  white-space: nowrap;
}
.sec-badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--clr-border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.btn-sm:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
}

.sec-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.sec-config-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--clr-border);
  border-radius: 6px;
}
.sec-config-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.sec-config-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}

/* ===== API Keys — Scopes Grid ===== */
.scopes-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.scopes-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.scopes-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.scope-checkbox {
  margin-top: 0 !important;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.scope-checkbox:hover {
  background: var(--bg-hover);
}
.scope-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 1.65rem;
}

/* ===== API Keys — Scope Badges ===== */
.scope-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-muted);
  margin: 1px 2px;
  white-space: nowrap;
}
.scope-badge-full {
  background: rgba(22, 163, 74, 0.1);
  color: var(--green);
  font-weight: 600;
}
.scope-badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  font-weight: 600;
}
.scope-badge-expired {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  font-weight: 600;
}

/* ===== API Keys — Key Display ===== */
.apikey-display {
  margin-top: 1rem;
  padding: 1rem;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: var(--radius-sm);
}
.apikey-key-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.apikey-key-value {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-dark);
  color: #fbbf24;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  word-break: break-all;
  font-family: monospace;
}
.btn-copy-key {
  margin-top: 0 !important;
  white-space: nowrap;
}
.btn-copied {
  background: var(--green) !important;
  color: #fff !important;
  border-color: var(--green) !important;
}
