/* =====================================================================
   ClickPrint3D — Portail de gestion (back-office + espace client)
   Thème « liquid glass » du site www.clickprint3d.fr.
   Nécessite : css/fonts.css puis css/tokens.css (jetons partagés avec le site).
   ===================================================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; background: var(--bg); color-scheme: dark; }
body {
  position: relative; min-height: 100vh;
  font: 400 .95rem/1.6 var(--f-body);
  color: var(--ink); background: transparent;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
/* Fond du site : aurores de couleurs (statiques ici, pour rester léger) + grille */
body::before {
  content: ""; position: fixed; inset: -20vmax; z-index: -2; pointer-events: none;
  background:
    radial-gradient(28vmax 28vmax at 12% 18%, rgba(58, 160, 255, .26), transparent 70%),
    radial-gradient(26vmax 26vmax at 88% 12%, rgba(255, 98, 179, .20), transparent 70%),
    radial-gradient(30vmax 30vmax at 78% 82%, rgba(142, 118, 255, .24), transparent 70%),
    radial-gradient(22vmax 22vmax at 18% 88%, rgba(51, 224, 178, .14), transparent 70%);
  filter: blur(30px);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 80%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 80%);
}

a { color: var(--blue); text-decoration: none; text-underline-offset: 3px; transition: color .2s var(--ease); }
a:hover { color: var(--ink); }
img { max-width: 100%; height: auto; display: block; }
::selection { background: var(--violet); color: #fff; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
code, kbd, .mono { font-family: var(--f-mono); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .24); }

/* Verre liquide (cartes, panneaux, barres) */
.glass, .auth-card, .panel, .stat-card, .portal-card, .modal-box, .sidebar, .topbar, .toast {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
}
/* Anciens éléments décoratifs : remplacés par le fond du site */
.bg-grid, .orb { display: none; }

/* ===== Pages de connexion ===== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { position: relative; width: 100%; max-width: 440px; padding: 40px 36px 34px; border-radius: var(--r-lg); overflow: hidden; }
.auth-card::before, .portal-card::before, .panel-accent::before {
  content: ""; position: absolute; left: 12%; right: 12%; top: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo img { height: 40px; width: auto; margin: 0 auto 18px; }
.auth-logo h1 { font-size: 1.45rem; font-weight: 800; color: var(--ink); }
.auth-badge {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 6px 13px 6px 10px;
  font: 500 .72rem/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
  background: rgba(255, 255, 255, .06); border: 1px solid var(--glass-border); border-radius: 999px;
}
.auth-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: conic-gradient(var(--blue), var(--violet), var(--pink), var(--coral), var(--sun), var(--mint), var(--blue)); box-shadow: 0 0 10px rgba(142, 118, 255, .9); }
.auth-links { text-align: center; margin-top: 20px; font-size: .86rem; color: var(--ink-3); }
.auth-links a { color: var(--blue); }
.auth-links a:hover { color: var(--ink); }
.auth-switch { display: flex; gap: 8px; margin-top: 22px; justify-content: center; flex-wrap: wrap; }
.auth-switch a { padding: 8px 16px; border-radius: 999px; font-size: .82rem; color: var(--ink-2); border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .04); }
.auth-switch a:hover { color: var(--ink); background: rgba(255, 255, 255, .1); }

/* ===== Formulaires (identiques au formulaire de devis du site) ===== */
.form-group { margin-bottom: 16px; min-width: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group.full { grid-column: 1 / -1; }
.form-label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.form-label .req { color: var(--pink); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px; font: inherit; font-size: .93rem; color: var(--ink);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--glass-border); border-radius: var(--r-sm);
  outline: none; transition: border-color .2s, background .2s, box-shadow .2s;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--ink-3); }
.form-select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23A9B0CE' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.form-select option { background: var(--bg-2); color: var(--ink); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--violet); background-color: rgba(255, 255, 255, .08); box-shadow: 0 0 0 4px rgba(142, 118, 255, .18); }
.form-input[readonly], .form-input:disabled { color: var(--ink-2); background-color: rgba(255, 255, 255, .025); border-style: dashed; }
input[type="date"].form-input::-webkit-calendar-picker-indicator { filter: invert(.8); cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--ink-3); margin-top: 6px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--violet); width: 16px; height: 16px; }

.error-msg, .success-msg, .info-msg {
  font-size: .88rem; padding: 11px 15px; border-radius: var(--r-sm); margin-bottom: 16px; border: 1px solid;
}
.error-msg { background: rgba(255, 107, 107, .1); border-color: rgba(255, 107, 107, .35); color: #FFB3B3; }
.success-msg { background: rgba(51, 224, 178, .1); border-color: rgba(51, 224, 178, .35); color: #9FF3DA; }
.info-msg { background: rgba(58, 160, 255, .1); border-color: rgba(58, 160, 255, .35); color: #B7DBFF; }

/* ===== Boutons (pilules du site) ===== */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .78em 1.35em; border-radius: 999px; border: 1px solid transparent;
  font: 600 .9rem/1.1 var(--f-body); color: #fff; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease), border-color .25s var(--ease);
}
.btn:hover { color: #fff; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--violet) 70%, var(--pink));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 10px 30px -10px rgba(142, 118, 255, .7), 0 0 0 1px rgba(255, 255, 255, .12);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 16px 40px -10px rgba(255, 98, 179, .6), 0 0 0 1px rgba(255, 255, 255, .2); }
.btn-secondary, .btn-ghost {
  background: rgba(255, 255, 255, .06); border-color: var(--glass-border); color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-secondary:hover, .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: var(--ink); transform: translateY(-1px); }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--glass-border); }
.btn-danger { background: rgba(255, 107, 107, .12); color: #FFB3B3; border-color: rgba(255, 107, 107, .35); }
.btn-danger:hover { background: rgba(255, 107, 107, .22); color: #fff; }
.btn-success { background: rgba(51, 224, 178, .12); color: #9FF3DA; border-color: rgba(51, 224, 178, .35); }
.btn-success:hover { background: rgba(51, 224, 178, .22); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .6em 1.05em; font-size: .82rem; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ===== Structure : barre latérale + barre du haut ===== */
.app-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar {
  display: flex; flex-direction: column; position: sticky; top: 12px; height: calc(100vh - 24px);
  margin: 12px 0 12px 12px; border-radius: var(--r-md); overflow: hidden;
  background: rgba(10, 14, 32, .55);
}
.sidebar-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 22px 20px 18px; border-bottom: 1px solid var(--line); position: relative; }
.sidebar-brand::after { content: ""; position: absolute; left: 20px; right: 20px; bottom: -1px; height: 1px; background: var(--spectrum); opacity: .7; }
.sidebar-brand img { height: 30px; width: auto; }
.sidebar-brand-text { display: flex; flex-direction: column; }
.sidebar-brand-text strong { font-family: var(--f-display); font-size: .95rem; }
.sidebar-brand-text span { font: 500 .68rem/1.3 var(--f-mono); color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; }
.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.sidebar-section { font: 500 .68rem/1 var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 16px 12px 8px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 999px; margin-bottom: 2px;
  color: var(--ink-2); font-size: .9rem; font-weight: 500; transition: color .2s, background .2s;
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255, 255, 255, .07); color: var(--ink); }
.sidebar-link.active { color: var(--ink); background: linear-gradient(90deg, rgba(58, 160, 255, .22), rgba(142, 118, 255, .14)); box-shadow: inset 0 0 0 1px rgba(142, 118, 255, .35); }
.sidebar-link.active svg { color: var(--blue); }
.sidebar-link .badge-count { margin-left: auto; background: var(--pink); color: #fff; font: 700 .68rem/1.4 var(--f-body); padding: 1px 8px; border-radius: 999px; box-shadow: 0 0 12px rgba(255, 98, 179, .6); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); }
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font: 700 .85rem var(--f-display); color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet) 60%, var(--pink)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: .74rem; color: var(--ink-3); }
.sidebar-logout { color: var(--ink-3); display: inline-flex; padding: 6px; border-radius: 50%; }
.sidebar-logout:hover { color: var(--danger); background: rgba(255, 107, 107, .1); }

.main-col { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.topbar {
  position: sticky; top: 12px; z-index: 20; margin: 12px 12px 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px 12px 24px; border-radius: 999px; background: rgba(10, 14, 32, .55);
}
.topbar h1 { font-size: 1.15rem; font-weight: 800; }
.topbar-sub { font-size: .8rem; color: var(--ink-3); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.main-content { padding: 24px 12px 40px 16px; flex: 1; min-width: 0; }
.main-content > * { max-width: 1400px; }
.app-footer { padding: 18px 16px 24px; font-size: .78rem; color: var(--ink-3); display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid var(--line); margin: 0 12px 0 16px; }
.app-footer a { color: var(--ink-2); }

.mobile-menu-btn { display: none; flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .06); color: var(--ink); cursor: pointer; align-items: center; justify-content: center; }
.mobile-menu-btn svg { width: 20px; height: 20px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: 280px; margin: 8px; z-index: 100; transform: translateX(-110%); transition: transform .3s var(--ease); background: rgba(10, 14, 32, .92); box-shadow: var(--shadow-pop); }
  .sidebar.open { transform: none; }
  .mobile-menu-btn { display: inline-flex; }
  .topbar { margin: 8px 8px 0; padding: 8px 10px 8px 8px; border-radius: var(--r-md); }
  .topbar > div:first-child, .topbar > .topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .topbar h1 { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-sub { display: none; }
  .topbar-actions .btn { padding: .6em .9em; font-size: .8rem; }
  .main-content { padding: 16px 8px 32px; }
  .app-footer { margin: 0 8px; }
  .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
}

/* ===== Cartes de statistiques ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .stat-card { padding: 16px; } .stat-value { font-size: 1.3rem !important; } }
.stat-card { position: relative; overflow: hidden; border-radius: var(--r-md); padding: 20px; --c: var(--blue); }
.stat-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%); pointer-events: none; }
.stat-card-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; color: #fff; background: var(--c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 0 18px color-mix(in srgb, var(--c) 60%, transparent); }
.stat-card-icon svg { width: 19px; height: 19px; }
.stat-card:has(.stat-icon-blue) { --c: var(--blue); }
.stat-card:has(.stat-icon-green) { --c: var(--mint); }
.stat-card:has(.stat-icon-orange) { --c: var(--coral); }
.stat-card:has(.stat-icon-red) { --c: var(--pink); }
.stat-card:has(.stat-icon-purple) { --c: var(--violet); }
.stat-icon-blue { --c: var(--blue); } .stat-icon-green { --c: var(--mint); } .stat-icon-orange { --c: var(--coral); } .stat-icon-red { --c: var(--pink); } .stat-icon-purple { --c: var(--violet); }
.stat-value { font: 800 1.75rem/1.1 var(--f-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; color: var(--ink-2); margin-top: 6px; }
.stat-trend { font-size: .76rem; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.stat-trend.up { color: var(--mint); } .stat-trend.down { color: var(--danger); }

/* ===== Panneaux ===== */
.panel { position: relative; border-radius: var(--r-md); padding: 22px; margin-bottom: 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { font-size: 1.05rem; }
.panel-head-sub { font-size: .82rem; color: var(--ink-3); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .panel { padding: 16px; } }

/* ===== Tableaux (style « matériaux » du site) ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: inherit; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font: 500 .7rem/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: middle; }
.data-table tbody tr { transition: background .2s; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, .045); }
.data-table tbody tr[data-href] { cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .cell-strong { font-weight: 600; color: var(--ink); }
.data-table td.cell-strong:first-child { font-family: var(--f-mono); font-weight: 500; font-size: .85rem; white-space: nowrap; }
.data-table td.cell-muted, .data-table td.cell-right { white-space: nowrap; }
.data-table .cell-muted { color: var(--ink-3); font-size: .84rem; }
.data-table .cell-right { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { text-align: center; padding: 50px 20px; color: var(--ink-3); }
.table-empty svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .4; }
@media (max-width: 700px) {
  .data-table { min-width: 620px; }
  .data-table th, .data-table td { padding: 11px 10px; } .data-table td { font-size: .85rem; }
  .table-wrap { background: linear-gradient(90deg, transparent calc(100% - 24px), rgba(255, 255, 255, .05)); }
}

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--ink-2); border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .04); cursor: pointer; transition: all .2s var(--ease); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--ink); background: rgba(255, 255, 255, .12); }
.icon-btn.danger:hover { color: #FFB3B3; border-color: rgba(255, 107, 107, .4); background: rgba(255, 107, 107, .12); }

/* ===== Badges (pastilles « filaments ») ===== */
.badge { --c: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; color: color-mix(in srgb, var(--c) 80%, #fff); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 32%, transparent); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.badge-pending { --c: var(--sun); }
.badge-sent { --c: var(--blue); }
.badge-accepted, .badge-paid, .badge-refunded { --c: var(--mint); }
.badge-ordered { --c: var(--violet); }
.badge-refused, .badge-overdue { --c: var(--danger); }
.badge-draft, .badge-applied { --c: #9AA3C4; }
.badge-cancelled { --c: var(--ink-3); }
.badge-devis { --c: var(--violet); }
.badge-facture { --c: var(--blue); }
.badge-avoir { --c: var(--coral); }

/* ===== Filtres, onglets ===== */
.filters-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters-bar .form-input, .filters-bar .form-select { width: auto; min-width: 170px; }
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-3); pointer-events: none; }
.search-input-wrap input { padding-left: 40px; width: 100%; border-radius: 999px; }
@media (max-width: 600px) { .filters-bar .form-select, .filters-bar .form-input { flex: 1 1 140px; min-width: 0; } }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; overflow-x: auto; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); width: fit-content; max-width: 100%; }
.tab-link { padding: 8px 16px; font-size: .86rem; color: var(--ink-2); font-weight: 500; border-radius: 999px; white-space: nowrap; }
.tab-link:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }
.tab-link.active { color: #fff; background: linear-gradient(135deg, var(--brand), var(--violet)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3); }

/* ===== Modales ===== */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(4, 6, 14, .65); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-overlay.open { display: flex; animation: fade-in .2s var(--ease); }
.modal-box { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; border-radius: var(--r-lg); background: rgba(14, 20, 48, .92); box-shadow: var(--shadow-pop); }
.modal-box.modal-lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(14, 20, 48, .97); z-index: 2; }
.modal-head h3 { font-size: 1.08rem; }
.modal-close { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 6px; border-radius: 50%; display: inline-flex; }
.modal-close:hover { color: var(--ink); background: rgba(255, 255, 255, .08); }
.modal-close svg { width: 20px; height: 20px; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 600px) { .modal-overlay { align-items: flex-end; padding: 0; } .modal-box { max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; } .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; } }

/* ===== Notifications ===== */
.toast { position: fixed; bottom: 24px; right: 24px; z-index: 2000; max-width: min(440px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px; padding: 13px 20px; border-radius: 999px; font-size: .9rem; background: rgba(14, 20, 48, .9); box-shadow: var(--shadow-pop); transform: translateY(20px); opacity: 0; pointer-events: none; transition: transform .3s var(--ease), opacity .3s var(--ease); }
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.toast.success { border-color: rgba(51, 224, 178, .45); } .toast.success .toast-dot { background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.toast.error { border-color: rgba(255, 107, 107, .5); } .toast.error .toast-dot { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
@media (max-width: 600px) { .toast { left: 16px; right: 16px; bottom: 16px; border-radius: var(--r-md); } }

/* ===== État vide ===== */
.empty-state { text-align: center; padding: 56px 20px; }
.empty-state svg { width: 48px; height: 48px; color: var(--ink-3); margin: 0 auto 16px; opacity: .6; }
.empty-state h4 { font-size: 1.05rem; margin-bottom: 6px; }
.empty-state p { color: var(--ink-3); font-size: .9rem; margin-bottom: 18px; }

/* ===== Accueil du portail ===== */
.portal-page { min-height: 100vh; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px; text-align: center; }
.portal-kicker { display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px 7px 10px; border-radius: 999px; margin-bottom: 26px; font: 500 .78rem/1.3 var(--f-mono); letter-spacing: .04em; color: var(--ink-2); background: rgba(255, 255, 255, .06); border: 1px solid var(--glass-border); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.portal-kicker svg { width: 13px; height: 13px; color: var(--mint); }
.portal-logo { height: 46px; width: auto; margin-bottom: 26px; }
.portal-title { font: 800 clamp(2.2rem, 5.4vw, 3.6rem)/1.05 var(--f-display); letter-spacing: -.035em; margin-bottom: 16px; }
.portal-title span { background: linear-gradient(90deg, var(--blue), var(--violet) 40%, var(--pink) 70%, var(--coral)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 24px rgba(142, 118, 255, .4)); }
.portal-subtitle { color: var(--ink-2); font-size: 1.08rem; max-width: 480px; margin: 0 auto 44px; }
.portal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 800px; width: 100%; margin: 0 auto; }
@media (max-width: 700px) { .portal-grid { grid-template-columns: 1fr; } }
.portal-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; border-radius: var(--r-lg); padding: 36px 28px; overflow: hidden; color: var(--ink); --c: var(--blue); transition: transform .3s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease); }
.portal-grid .portal-card:nth-child(2) { --c: var(--pink); }
.portal-card:hover { color: var(--ink); transform: translateY(-4px); border-color: color-mix(in srgb, var(--c) 60%, transparent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 24px 50px -24px color-mix(in srgb, var(--c) 80%, transparent); }
.portal-card > * { position: relative; z-index: 1; }
.portal-card-icon { width: 58px; height: 58px; border-radius: 18px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; color: #fff; background: var(--c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 0 26px color-mix(in srgb, var(--c) 70%, transparent); transition: transform .3s var(--ease); }
.portal-card:hover .portal-card-icon { transform: scale(1.06) rotate(-3deg); }
.portal-card-icon svg { width: 26px; height: 26px; }
.portal-card h3 { font-size: 1.25rem; margin-bottom: 10px; }
.portal-card p { color: var(--ink-2); font-size: .92rem; margin-bottom: 24px; flex: 1; }
.portal-footer-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 40px; color: var(--ink-3); font-size: .86rem; }
.portal-footer-link:hover { color: var(--ink); }
.portal-footer-link svg { width: 14px; height: 14px; }

/* =====================================================================
   Document A4 (devis / facture / avoir) — clair, sobre, imprimable,
   aux couleurs de la marque. Aperçu à l'écran + export PDF (html2pdf).
   ===================================================================== */
.doc-render {
  --d-ink: #0B1024; --d-ink-2: #3A4160; --d-ink-3: #6B7290; --d-line: #E3E6F0; --d-soft: #F5F6FB; --d-accent: var(--brand);
  position: relative; background: #fff; color: var(--d-ink); border-radius: 3px;
  padding: 14mm 14mm 12mm; width: 210mm; min-height: 296mm; box-sizing: border-box; transform-origin: top left;
  font: 400 12.5px/1.5 var(--f-body); box-shadow: 0 10px 40px rgba(0, 0, 0, .45); color-scheme: light;
}
.doc-render::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: linear-gradient(90deg, #3AA0FF, #8E76FF, #FF62B3, #FF8A5E, #FFC94A, #33E0B2); }
.doc-render * { box-sizing: border-box; }
.doc-render .doc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1.5px solid var(--d-line); }
.doc-render .doc-brand img { height: 36px; width: auto; }
.doc-render .doc-type-label { text-align: right; }
.doc-render .doc-type-name { font: 800 28px/1 var(--f-display); letter-spacing: -.01em; text-transform: uppercase; color: var(--d-ink); }
.doc-render .doc-number { font: 400 11px/1.6 var(--f-mono); color: var(--d-ink-3); margin-top: 6px; }
.doc-render .doc-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-bottom: 18px; }
.doc-render .doc-info-block h4 { font: 500 9.5px/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--d-accent); margin-bottom: 8px; }
.doc-render .doc-info-block p { font-size: 11.5px; color: var(--d-ink-2); line-height: 1.5; }
.doc-render .doc-info-block strong { color: var(--d-ink); font-weight: 600; }
.doc-render .doc-validity { margin-bottom: 14px; padding: 8px 12px; background: #FFF8E6; border-radius: 6px; border-left: 3px solid #F5B51F; font-size: 11.5px; color: var(--d-ink-2); }
.doc-render .doc-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.doc-render .doc-table tr { break-inside: avoid; }
.doc-render .doc-table thead th { background: var(--d-ink); color: #fff; font: 500 9.5px/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: .07em; padding: 10px 12px; text-align: left; }
.doc-render .doc-table thead th:first-child { border-radius: 6px 0 0 6px; }
.doc-render .doc-table thead th:last-child { border-radius: 0 6px 6px 0; text-align: right; }
.doc-render .doc-table thead th.right { text-align: right; }
.doc-render .doc-table tbody td { padding: 7px 12px; border-bottom: 1px solid var(--d-line); font-size: 12px; color: var(--d-ink-2); vertical-align: top; }
.doc-render .doc-table tbody td.right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-render .doc-table tbody td strong { display: block; color: var(--d-ink); font-weight: 600; }
.doc-render .doc-totals { display: flex; justify-content: flex-end; margin-bottom: 16px; break-inside: avoid; }
.doc-render .doc-totals-table { width: 270px; }
.doc-render .doc-totals-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; color: var(--d-ink-3); font-variant-numeric: tabular-nums; }
.doc-render .doc-totals-row.total { margin-top: 6px; padding: 11px 14px; border-radius: 8px; font: 700 15px/1.2 var(--f-display); color: #fff; background: linear-gradient(135deg, #0170C3, #8E76FF); }
.doc-render .doc-notes { margin-bottom: 10px; padding: 9px 12px; background: var(--d-soft); border-radius: 6px; border-left: 3px solid var(--d-accent); break-inside: avoid; }
.doc-render .doc-notes h4 { font: 500 9.5px/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--d-accent); margin-bottom: 6px; }
.doc-render .doc-notes p { font-size: 10.5px; color: var(--d-ink-2); line-height: 1.55; white-space: pre-wrap; }
.doc-render .doc-notes p + p { margin-top: 4px; }
.doc-render .doc-signature { margin: 14px 0; padding: 10px 14px; border: 1px dashed #C9CDDC; border-radius: 8px; break-inside: avoid; }
.doc-render .doc-signature img { max-height: 70px; }
.doc-render .doc-legal { font-size: 9px; color: var(--d-ink-3); line-height: 1.5; padding-top: 8px; break-inside: avoid; border-top: 1px solid var(--d-line); }
.doc-render a { color: var(--d-accent); }

.doc-preview-outer { border-radius: var(--r-md); padding: 20px; overflow: hidden; background: rgba(0, 0, 0, .28); border: 1px solid var(--line); }
.doc-page-scaler { width: 100%; overflow: hidden; }
@media (max-width: 600px) { .doc-preview-outer { padding: 8px; } }

/* ===== Divers ===== */
.text-muted { color: var(--ink-3); }
.text-green { color: var(--mint); }
.text-red { color: var(--danger); }
.text-orange { color: var(--sun); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .justify-between { justify-content: space-between; } .w-full { width: 100%; }
.progress-bar { height: 7px; background: rgba(255, 255, 255, .08); border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 999px; background: var(--spectrum); box-shadow: 0 0 12px rgba(142, 118, 255, .6); transition: width .4s var(--ease); }
.lock-badge { display: inline-flex; align-items: center; gap: 6px; font: 500 .74rem var(--f-mono); color: var(--ink-2); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .05); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media print {
  body::before, body::after, .sidebar, .topbar, .no-print, .app-footer, .toast { display: none !important; }
  html, body { background: #fff !important; color: #000; }
  .app-shell { display: block !important; }
  .main-content { padding: 0 !important; }
  .doc-preview-outer { background: none; border: 0; padding: 0; }
  .doc-render { box-shadow: none; transform: none !important; }
}

/* Commandes : origine (boutique / devis) et règlement manuel des commandes sur devis */
.order-src { display: inline-block; font: 600 .72rem/1.5 var(--f-body); padding: 1px 8px; border-radius: 999px; background: rgba(154, 163, 196, .16); color: var(--ink-2, inherit); }
.order-src-devis { background: rgba(139, 92, 246, .16); }
.order-origin a { font-weight: 700; }
.pay-form { margin-top: 16px; padding: 14px; border: 1px solid var(--line, rgba(154, 163, 196, .3)); border-radius: 12px; display: grid; gap: 10px; max-width: 520px; }
.pay-form-title { font-weight: 700; }
.pay-row { display: grid; gap: 4px; }
.pay-row .form-label { margin-bottom: 0; }
.pay-form .btn { justify-self: start; }
.is-hidden { display: none !important; }

/* Changement de statut libre + historique des statuts (documents et commandes) */
.status-change { margin-top: 16px; display: grid; gap: 6px; }
.status-change-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-change-row .form-select { width: auto; min-width: 220px; }
.status-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: .85rem; }
.status-history li { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.status-history li:last-child { border-bottom: 0; padding-bottom: 0; }
.status-history .sh-date, .status-history .sh-meta { color: var(--text-secondary); font-size: .78rem; }
