/* ==========================================================================
   LANAYATECH - ADMINISTRATION
   Feuille de style autonome de l'espace d'administration.
   ========================================================================== */

:root {
  --red: #f20d16;
  --red-dark: #c9080f;
  --red-soft: #fee2e2;
  --dark: #0b1220;
  --dark-2: #0f172a;
  --dark-3: #111c31;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 34px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 30px 80px rgba(2, 6, 23, 0.24);
  --font: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  padding: 18px;
  background: var(--red);
  color: #fff;
  text-align: center;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Démarrage
   -------------------------------------------------------------------------- */

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(242, 13, 22, 0.24), transparent 34%),
    radial-gradient(circle at 85% 90%, rgba(37, 99, 235, 0.12), transparent 34%),
    linear-gradient(145deg, #070b14, #0f172a 58%, #111c31);
  color: #fff;
}

.boot-mark {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.boot-mark img {
  width: 230px;
  height: auto;
}

.boot-mark p {
  color: #94a3b8;
  font-size: 0.9rem;
}

.boot-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   Authentification
   -------------------------------------------------------------------------- */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 24px;
  background:
    radial-gradient(circle at 12% 18%, rgba(242, 13, 22, 0.28), transparent 30%),
    radial-gradient(circle at 88% 82%, rgba(37, 99, 235, 0.14), transparent 32%),
    linear-gradient(140deg, #070b14, #0f172a 54%, #121c30);
}

.auth-shell {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  align-items: center;
  gap: 70px;
  margin: auto 0;
}

.auth-brand {
  color: #fff;
}

.auth-logo {
  width: 230px;
  height: auto;
  display: block;
  margin-bottom: 26px;
}

.auth-kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: #fca5a5;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-brand h1 {
  max-width: 520px;
  font-size: clamp(2rem, 3.4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.auth-brand p {
  max-width: 480px;
  margin-top: 16px;
  color: #a9b4c7;
  font-size: 0.98rem;
  line-height: 1.65;
}

.auth-card {
  width: 100%;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  border-radius: 12px;
  background: #f1f5f9;
}

.auth-tab {
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.auth-form {
  display: grid;
  gap: 15px;
}

.auth-hint {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
  text-align: center;
}

.auth-back {
  grid-column: 1 / -1;
  justify-self: center;
  color: #cbd5e1;
  font-size: 0.84rem;
  text-decoration: none;
  transition: color 0.18s ease;
}

.auth-back:hover {
  color: #fff;
}

.notice {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--blue-soft);
  border-radius: 11px;
  background: #eff6ff;
  color: var(--blue);
  font-size: 0.82rem;
  line-height: 1.5;
}

.notice strong {
  font-weight: 800;
}

.notice code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(29, 78, 216, 0.1);
  font-size: 0.78rem;
}

.notice-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.notice-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

/* --------------------------------------------------------------------------
   Compte en attente
   -------------------------------------------------------------------------- */

.pending-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(242, 13, 22, 0.22), transparent 32%),
    linear-gradient(145deg, #070b14, #0f172a 60%, #111c31);
}

.pending-card {
  width: min(520px, 100%);
  padding: 38px 32px;
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 14px;
}

.pending-card h1 {
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.pending-card p {
  max-width: 420px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Coquille application
   -------------------------------------------------------------------------- */

.admin-app {
  min-height: 100vh;
  background: var(--bg);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: #080d17;
  color: #fff;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
}

.app-brand-logo {
  width: 128px;
  height: auto;
  display: block;
}

.app-brand-tag {
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.18s ease;
}

.topbar-link svg {
  width: 17px;
  height: 17px;
}

.topbar-link:hover {
  color: #fff;
}

.role-badge {
  padding: 5px 9px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 999px;
  background: rgba(242, 13, 22, 0.14);
  color: #fecaca;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.user-email {
  max-width: 220px;
  overflow: hidden;
  color: #94a3b8;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #cbd5e1;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.icon-btn:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.app-layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.app-sidebar {
  position: sticky;
  top: 68px;
  height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  padding: 26px 18px;
  background:
    linear-gradient(180deg, rgba(242, 13, 22, 0.06), transparent 22%),
    #0b1220;
  color: #fff;
}

.sidebar-profile {
  display: grid;
  gap: 5px;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.sidebar-eyebrow {
  color: #fca5a5;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-name {
  font-size: 1.02rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.sidebar-meta {
  color: #94a3b8;
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.app-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 650;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-item.is-active {
  background: var(--red);
  color: #fff;
  box-shadow: 0 7px 18px rgba(242, 13, 22, 0.24);
}

.sidebar-note {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1.5;
}

.sidebar-note strong {
  color: #fff;
  font-size: 0.78rem;
}

.app-main {
  min-width: 0;
  padding: 32px;
}

/* --------------------------------------------------------------------------
   En-têtes de page
   -------------------------------------------------------------------------- */

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

.eyebrow {
  margin-bottom: 5px;
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.page-head h1 {
  font-size: clamp(1.6rem, 2.4vw, 2.05rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.page-subtitle {
  max-width: 680px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.app-message {
  margin-bottom: 18px;
  padding: 12px 15px;
  border: 1px solid var(--blue-soft);
  border-radius: 12px;
  background: #eff6ff;
  color: var(--blue);
  font-size: 0.84rem;
}

.app-message.is-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.app-message.is-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

/* --------------------------------------------------------------------------
   Tableau de bord
   -------------------------------------------------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

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

.stat-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--red-soft);
  color: var(--red);
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-icon.is-green {
  background: var(--green-soft);
  color: var(--green);
}

.stat-icon.is-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.stat-icon.is-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.stat-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.stat-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

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

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-head h2 {
  font-size: 1.03rem;
  letter-spacing: -0.015em;
}

.panel-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.panel-link:hover {
  color: var(--red-dark);
}

.mini-list {
  display: grid;
}

.mini-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.mini-item:last-child {
  border-bottom: 0;
}

.mini-thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  object-fit: cover;
}

.mini-avatar {
  display: grid;
  place-items: center;
  background: var(--red-soft);
  color: var(--red-dark);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.mini-info {
  min-width: 0;
  flex: 1;
}

.mini-name {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.73rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-price {
  flex: 0 0 auto;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.empty-mini {
  padding: 26px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Barre d'outils et tableaux
   -------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-field {
  min-width: 240px;
  height: 44px;
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-field:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(242, 13, 22, 0.1);
}

.search-field svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--muted-light);
}

.search-field input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
}

.select-field select {
  height: 44px;
  max-width: 240px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.84rem;
  outline: 0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.select-field select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(242, 13, 22, 0.1);
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.data-table th {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.86rem;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: #fcfdff;
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.product-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  object-fit: cover;
}

.product-name {
  display: block;
  max-width: 250px;
  overflow: hidden;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.price-cell {
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.muted-cell {
  color: var(--muted);
}

.supplier-name {
  display: block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-email {
  display: block;
  max-width: 210px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-success {
  background: var(--green-soft);
  color: var(--green);
}

.badge-warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-muted {
  background: #f1f5f9;
  color: #475569;
}

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

.actions-col {
  text-align: right !important;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}

.empty-state strong {
  font-size: 0.98rem;
}

.empty-state > span {
  max-width: 420px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.empty-state .btn {
  margin-top: 8px;
}

.empty-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  border-radius: 16px;
  background: var(--red-soft);
  color: var(--red);
}

.empty-icon svg {
  width: 30px;
  height: 30px;
}

/* --------------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------------- */

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.nav-item:focus-visible,
.auth-tab:focus-visible,
.panel-link:focus-visible {
  outline: 3px solid rgba(242, 13, 22, 0.22);
  outline-offset: 2px;
}

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

.btn-primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 7px 16px rgba(242, 13, 22, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--red-dark);
}

.btn-outline {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
}

.btn-outline:hover:not(:disabled) {
  border-color: #94a3b8;
  background: #f8fafc;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: #f1f5f9;
  color: var(--text);
}

.btn-ghost.is-danger {
  color: var(--danger);
}

.btn-ghost.is-danger:hover:not(:disabled) {
  background: #fef2f2;
  color: var(--danger);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.74rem;
}

.btn-block {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Formulaires
   -------------------------------------------------------------------------- */

.field {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.field > span:first-child {
  color: var(--text-soft);
  font-size: 0.77rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: 0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a8b3c4;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(242, 13, 22, 0.1);
}

.field.full {
  grid-column: 1 / -1;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: #f1f5f9;
  color: var(--text);
}

.password-toggle svg {
  width: 19px;
  height: 19px;
}

.password-toggle .eye-closed {
  display: none;
}

.password-toggle.is-visible .eye-open {
  display: none;
}

.password-toggle.is-visible .eye-closed {
  display: block;
}

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

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
}

.switch-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--red);
}

.help {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.supplier-help {
  padding: 10px 12px;
  border-radius: 9px;
  background: #f8fafc;
}

.form-message {
  padding: 10px 12px;
  border: 1px solid var(--blue-soft);
  border-radius: 9px;
  background: #eff6ff;
  color: var(--blue);
  font-size: 0.8rem;
  line-height: 1.5;
}

.form-message.is-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.form-message.is-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

/* --------------------------------------------------------------------------
   Modales
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(3px);
}

.modal-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s ease both;
}

.modal-dialog-small {
  width: min(620px, 100%);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
}

.modal-head h2 {
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.modal-head .icon-btn {
  color: var(--muted);
}

.modal-head .icon-btn:hover {
  border-color: var(--border);
  background: #f1f5f9;
  color: var(--text);
}

.modal-body {
  display: grid;
  gap: 18px;
  padding: 22px 24px 24px;
}

.image-uploader {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-soft);
}

.image-preview {
  position: relative;
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.image-preview:focus-visible {
  outline: 3px solid rgba(242, 13, 22, 0.22);
  outline-offset: 2px;
}

.image-preview.is-dragging {
  border-color: var(--red);
  background: #fff5f5;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 10px;
  color: var(--muted-light);
  font-size: 0.72rem;
  text-align: center;
}

.image-placeholder svg {
  width: 30px;
  height: 30px;
}

.image-controls {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.image-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.image-url {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.image-url input {
  min-width: 180px;
  height: 38px;
  flex: 1;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  outline: 0;
}

.image-url input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(242, 13, 22, 0.1);
}

.image-status {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.image-status.is-error {
  color: var(--danger);
}

.image-status.is-success {
  color: var(--green);
}

.modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  max-width: min(380px, calc(100vw - 40px));
  padding: 13px 16px;
  border-left: 4px solid #22c55e;
  border-radius: 11px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 0.84rem;
  line-height: 1.45;
  animation: toast-in 0.18s ease both;
}

.toast.is-error {
  border-left-color: #ef4444;
}

.toast.is-info {
  border-left-color: #3b82f6;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .app-layout {
    grid-template-columns: 224px minmax(0, 1fr);
  }

  .auth-shell {
    gap: 44px;
  }
}

@media (max-width: 900px) {
  .auth-screen {
    padding: 28px 16px;
  }

  .auth-shell {
    max-width: 560px;
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .auth-brand {
    display: grid;
    justify-items: center;
    text-align: center;
  }

  .auth-logo {
    width: 200px;
    margin-bottom: 14px;
  }

  .auth-brand h1 {
    font-size: 1.8rem;
  }

  .auth-brand p {
    max-width: 440px;
    margin-top: 10px;
  }

  .auth-back {
    grid-column: auto;
  }

  .app-topbar {
    padding: 0 16px;
  }

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

  .app-sidebar {
    position: static;
    height: auto;
    padding: 13px 16px;
    gap: 12px;
  }

  .sidebar-profile,
  .sidebar-note {
    display: none;
  }

  .app-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    min-height: 40px;
    padding: 9px 12px;
    font-size: 0.82rem;
  }

  .nav-item svg {
    width: 17px;
    height: 17px;
  }

  .app-main {
    padding: 22px 16px 34px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .page-head > .btn {
    align-self: flex-start;
  }

  .topbar-link span,
  .user-email {
    display: none;
  }

  .role-badge {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

  .search-field {
    min-width: 0;
    width: 100%;
  }

  .select-field select {
    width: 100%;
    max-width: none;
  }

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

  .field.full {
    grid-column: auto;
  }

  .image-uploader {
    grid-template-columns: 1fr;
  }

  .image-preview {
    width: 100%;
    height: 190px;
  }

  .modal {
    padding: 0;
  }

  .modal-dialog,
  .modal-dialog-small {
    width: 100%;
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-head {
    border-radius: 0;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .auth-card {
    padding: 22px 18px;
  }

  .auth-tabs {
    grid-template-columns: 1fr;
  }

  .auth-brand h1 {
    font-size: 1.55rem;
  }

  .auth-logo {
    width: 185px;
  }

  .app-brand-logo {
    width: 105px;
  }

  .app-brand-tag {
    display: none;
  }

  .role-badge {
    display: none;
  }

  .page-head h1 {
    font-size: 1.65rem;
  }

  .data-table {
    min-width: 740px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
