:root {
  --primary: #4A96B0;
  --primary-hover: #3D8299;
  --primary-light: #6DB8D0;
  --accent: #5DBE9A;
  --accent-hover: #4DAD88;
  --bg: #F3F7F6;
  --bg-subtle: #E4EDEB;
  --card-bg: #ffffff;
  --text: #2A3F42;
  --text-muted: #7A9B9E;
  --border: #CEDFDD;
  --success: #5BAD7A;
  --danger: #E07070;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Auth pages */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: linear-gradient(145deg, #4A96B0 0%, #3D8299 40%, #5DBE9A 100%);
}
.auth-container {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(74,150,176,0.20);
}
.auth-container h1 {
  text-align: center;
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 0.3rem;
  letter-spacing: -0.02em;
}
.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.auth-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.auth-link a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
}
.auth-link a:hover {
  color: var(--accent);
}

/* Forms */
.form-group {
  margin-bottom: 1.2rem;
}
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="color"], select, textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--card-bg);
  color: var(--text);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(74,150,176,0.12);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  text-align: center;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(74,150,176,0.25); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #4E9D6B; box-shadow: 0 4px 12px rgba(91,173,122,0.25); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #D05A5A; box-shadow: 0 4px 12px rgba(224,112,112,0.25); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(74,150,176,0.04); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(93,190,154,0.25); }

/* Error message */
.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.8rem;
  text-align: center;
  min-height: 1.2rem;
}

/* Dashboard layout (legacy, superadmin pages) */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.topbar h1 {
  font-size: 1.5rem;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  white-space: nowrap;
}
.btn-back:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-subtle);
}
.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ========== Admin sidebar layout - Dark Élégant (palette harmonisée) ========== */
.admin-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}
.admin-sidebar {
  background: linear-gradient(180deg, #1e3a5f 0%, #2d5a87 100%);
  padding: 1.8rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(30,58,95,0.25);
}
.admin-sidebar .sidebar-brand {
  padding: 0 1.5rem 1.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 1rem;
}
.admin-sidebar .sidebar-brand h2 {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.admin-sidebar .sidebar-brand h2::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}
.admin-sidebar .sidebar-company {
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.admin-sidebar .nav-section {
  padding: 1.2rem 1.5rem 0.5rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
}
.admin-sidebar a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1.5rem;
  margin: 0.15rem 0.8rem;
  text-decoration: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.25s ease;
  border-radius: 10px;
  border-left: none;
}
.admin-sidebar a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.admin-sidebar a.active {
  background: linear-gradient(135deg, rgba(93,190,154,0.25) 0%, rgba(74,150,176,0.2) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(93,190,154,0.2);
}
.admin-sidebar a.active::before {
  content: '';
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  margin-right: -0.4rem;
}
.admin-sidebar a.active:hover {
  background: linear-gradient(135deg, rgba(93,190,154,0.3) 0%, rgba(74,150,176,0.25) 100%);
}
.admin-sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1.2rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.admin-sidebar .sidebar-footer .sidebar-user {
  color: rgba(255,255,255,0.5);
  font-size: 0.78rem;
  margin-bottom: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.admin-sidebar .sidebar-footer .sidebar-user::before {
  content: '👤';
  font-size: 0.9rem;
}
.admin-sidebar .sidebar-footer button {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.admin-sidebar .sidebar-footer button::before {
  content: '⎋';
}
.admin-sidebar .sidebar-footer button:hover {
  background: rgba(224,112,112,0.2);
  border-color: rgba(224,112,112,0.4);
  color: #E07070;
}
.admin-content {
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 1100px;
}
.admin-content .page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.admin-content .page-header h1 {
  font-size: 1.4rem;
  color: var(--primary);
  letter-spacing: -0.02em;
}
@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: auto; flex-direction: row; padding: 0.5rem 0;
    overflow-x: auto; z-index: 50;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
  }
  .admin-sidebar .sidebar-brand,
  .admin-sidebar .nav-section,
  .admin-sidebar .sidebar-footer { display: none; }
  .admin-sidebar a {
    padding: 0.6rem 1rem; font-size: 0.7rem;
    margin: 0 0.2rem;
    white-space: nowrap; text-align: center;
    flex-direction: column; gap: 0.25rem;
    border-radius: 8px;
  }
  .admin-sidebar a::before { display: none; }
  .admin-sidebar a.active::before { display: none; }
  .admin-sidebar a.active {
    background: linear-gradient(135deg, rgba(93,190,154,0.25) 0%, rgba(74,150,176,0.2) 100%);
    box-shadow: none;
  }
  .admin-content { padding: 1rem; padding-bottom: 5rem; }
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(74,150,176,0.06), 0 4px 16px rgba(74,150,176,0.07);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  transition: box-shadow 0.25s;
}
.card:hover {
  box-shadow: 0 2px 6px rgba(74,150,176,0.08), 0 8px 24px rgba(74,150,176,0.10);
}
.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  color: var(--primary);
  letter-spacing: -0.01em;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 0.65rem 0.8rem;
  text-align: left;
  font-size: 0.9rem;
}
th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
}
tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}
tr:hover td {
  background: rgba(74,150,176,0.04);
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-draft { background: #E8F0EE; color: #7A9B9E; }
.badge-pending { background: #FFF3E0; color: #E09850; }
.badge-sending { background: #E0EFF5; color: #4A96B0; }
.badge-active { background: #E0F5EA; color: #459B68; }
.badge-sent { background: #E0EFF5; color: #4A96B0; }
.badge-captured { background: #E0F5EA; color: #459B68; }
.badge-processed { background: #DFF3EC; color: #3D9E76; }
.badge-completed { background: #D8F5E6; color: #3A8F5C; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Utilities */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }

/* Enhanced UX */
a { color: var(--primary); transition: color 0.2s; }
a:hover { color: var(--primary-hover); }
::selection { background: rgba(74,150,176,0.18); color: var(--text); }
html { scroll-behavior: smooth; }

/* Sidebar active accent - Dark Élégant style */
/* Active state handled in main sidebar styles above */

/* Subtle table row borders */
th { border-radius: 6px; }

/* Tooltip-style hover on badges */
.badge { transition: transform 0.15s; }
.badge:hover { transform: scale(1.05); }
