/* ==========================================================================
   Lumisphere ERP — Design System
   Thème : Anthracite + Amber | Polices : Inter, Oswald (system fallbacks)
   ========================================================================== */

/* --- Variables globales --- */
:root {
  --bg:           #0f1117;
  --bg-card:      #1a1d27;
  --bg-sidebar:   #13151d;
  --bg-input:     #1e2130;
  --border:       rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);

  --text:         #e5e7eb;
  --text-muted:   #9ca3af;
  --text-dim:     #6b7280;

  --gold:         #f59e0b;
  --gold-light:   #fbbf24;
  --gold-dark:    #d97706;
  --navy:         #1f2937;

  --green:        #22c55e;
  --blue:         #3b82f6;
  --red:          #ef4444;
  --purple:       #a855f7;
  --orange:       #f97316;

  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 4px 24px rgba(0,0,0,0.3);

  --sidebar-width: 240px;
  --header-height: 56px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1a1d27 100%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 28px; font-weight: 700;
  letter-spacing: 5px; text-align: center;
  color: #fff; margin-bottom: 4px;
}
.login-logo span { color: var(--gold); }
.login-sub {
  font-size: 11px; text-align: center; color: var(--text-dim);
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 36px;
}
.login-error {
  color: var(--red); font-size: 13px; text-align: center;
  margin-bottom: 12px; display: none;
}
.login-error.show { display: block; }

/* ==========================================================================
   LAYOUT — Sidebar + Main
   ========================================================================== */
.app-layout {
  display: none; /* Affiché après login */
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  min-height: 100vh;
}
.app-layout.active { display: grid; }

/* --- Header --- */
.app-header {
  grid-column: 1 / -1;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}
.header-brand {
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 18px; font-weight: 700; letter-spacing: 4px; color: #fff;
}
.header-brand span { color: var(--gold); }
.header-user {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-muted); font-size: 13px;
}
.header-user .user-name { font-weight: 600; color: var(--text); }
.header-user .user-role {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  background: rgba(245,158,11,0.15); color: var(--gold-light);
  padding: 2px 8px; border-radius: 20px;
}
.btn-logout {
  background: transparent; border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted); padding: 6px 14px; border-radius: 8px;
  cursor: pointer; font-size: 12px; font-weight: 600; transition: all 0.2s;
}
.btn-logout:hover { background: rgba(239,68,68,0.15); color: var(--red); border-color: rgba(239,68,68,0.3); }

/* --- Sidebar --- */
.app-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
}
.sidebar-section {
  padding: 0 12px; margin-bottom: 20px;
}
.sidebar-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-dim); padding: 0 12px; margin-bottom: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer;
  font-size: 13px; font-weight: 500;
  transition: all 0.15s; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: rgba(245,158,11,0.12); color: var(--gold-light); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

/* --- Main content --- */
.app-main {
  padding: 24px 32px;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height));
}

/* ==========================================================================
   PANELS (sections de contenu)
   ========================================================================== */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.panel-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.panel-header .icon { font-size: 1.5em; }
.panel-header h2 { font-size: 1.4em; font-weight: 700; color: #fff; }
.panel-desc { color: var(--text-muted); font-size: 0.9em; margin-bottom: 24px; line-height: 1.6; }

/* ==========================================================================
   FORM ELEMENTS
   ========================================================================== */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group label .req { color: var(--red); }

input, select, textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--radius);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
select { cursor: pointer; }
select option { background: var(--bg-card); color: var(--text); }
textarea { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; resize: vertical; min-height: 100px; }

.csv-help { font-size: 12px; color: var(--text-dim); margin-top: 4px; font-style: italic; }

/* --- Search input with icon --- */
.search-box {
  position: relative;
}
.search-box input { padding-left: 36px; }
.search-box::before {
  content: '🔍'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); font-size: 14px; pointer-events: none;
}

/* --- Drop zone (upload PDF) --- */
.drop-zone {
  border: 2px dashed rgba(245,158,11,0.25); border-radius: var(--radius-lg);
  padding: 28px; text-align: center; cursor: pointer;
  transition: all 0.3s; background: rgba(245,158,11,0.03);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--gold); background: rgba(245,158,11,0.08);
  box-shadow: 0 0 20px rgba(245,158,11,0.1);
}
.drop-zone .dz-icon { font-size: 2em; margin-bottom: 8px; }
.drop-zone .dz-text { font-size: 14px; color: var(--text-muted); }
.drop-zone .dz-text strong { color: var(--gold-light); }
.drop-zone input[type="file"] { display: none; }
.drop-zone.processing { opacity: 0.6; pointer-events: none; }
.drop-zone .dz-formats { font-size: 0.75em; color: var(--text-muted); margin-top: 6px; opacity: 0.7; }
.ai-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72em; font-weight: 600; background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(59,130,246,0.2)); color: #c084fc; padding: 3px 10px; border-radius: 20px; margin-left: 8px; }
.ai-status { font-size: 0.82em; margin-top: 8px; padding: 8px 12px; border-radius: 8px; display: none; }
.ai-status.show { display: block; }
.ai-status.parsing { background: rgba(245,158,11,0.1); color: var(--gold-light); }
.ai-status.done { background: rgba(34,197,94,0.1); color: #4ade80; }
.ai-status.err { background: rgba(239,68,68,0.1); color: #f87171; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  padding: 11px 24px; border-radius: var(--radius); border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a1a2e;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,158,11,0.3); }
.btn-secondary {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-secondary:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.btn-danger {
  background: rgba(239,68,68,0.15); color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 7px 14px; font-size: 12px; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ==========================================================================
   RESPONSE / ALERTS
   ========================================================================== */
.alert {
  padding: 14px 18px; border-radius: var(--radius); margin-top: 16px;
  font-size: 13px; display: none; line-height: 1.5;
}
.alert.show { display: block; animation: fadeIn 0.2s ease; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-error   { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--gold-light); }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }

/* ==========================================================================
   DASHBOARD — KPIs
   ========================================================================== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.kpi-card.kpi-gold::before   { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.kpi-card.kpi-green::before  { background: linear-gradient(90deg, var(--green), #4ade80); }
.kpi-card.kpi-blue::before   { background: linear-gradient(90deg, var(--blue), #60a5fa); }
.kpi-card.kpi-red::before    { background: linear-gradient(90deg, var(--red), #f87171); }
.kpi-card.kpi-purple::before { background: linear-gradient(90deg, var(--purple), #c084fc); }

.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; color: #fff; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ==========================================================================
   TABLES
   ========================================================================== */
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border);
}
.data-table thead th {
  background: rgba(255,255,255,0.03); padding: 12px 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-dim); text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* --- Badges / Tags --- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
}
.badge-green  { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-red    { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-gold   { background: rgba(245,158,11,0.15); color: var(--gold-light); }
.badge-blue   { background: rgba(59,130,246,0.15); color: #93c5fd; }
.badge-purple { background: rgba(168,85,247,0.15); color: #c084fc; }

/* ==========================================================================
   DEVIS — Lignes dynamiques
   ========================================================================== */
.devis-lines { margin-top: 16px; }
.devis-line {
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  position: relative;
}
.devis-line .line-header {
  display: flex; align-items: center; gap: 4px; margin-bottom: 10px; padding-right: 30px;
}
.devis-line .line-number {
  font-size: 12px; font-weight: 700; color: var(--gold);
  background: rgba(245,158,11,0.1); padding: 2px 10px; border-radius: 20px;
}
.devis-line .line-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 10px; align-items: end; }
.devis-line .btn-remove {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 4px;
}
.devis-line .btn-remove:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* --- Variante lines --- */
.devis-line-variante {
  background: rgba(124,58,237,0.06) !important;
  border: 2px dashed rgba(124,58,237,0.4) !important;
  position: relative;
}
.devis-line-variante .line-number {
  background: rgba(124,58,237,0.15) !important;
  color: #a855f7 !important;
}
.devis-line-variante input {
  font-style: italic;
}

/* --- Drag & drop --- */
.drag-handle {
  cursor: grab; font-size: 18px; color: var(--text-dim); user-select: none;
  padding: 0 6px; line-height: 1; opacity: 0.5; transition: opacity 0.15s;
}
.drag-handle:hover { opacity: 1; color: var(--gold); }
.drag-handle:active { cursor: grabbing; }
.devis-line[draggable="true"] { transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s; }
.devis-line-dragging { opacity: 0.4; transform: scale(0.98); }
.devis-line-drag-over {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.3);
  background: rgba(245,158,11,0.04) !important;
}

/* --- Move buttons --- */
.line-move-btns { display: flex; flex-direction: column; gap: 1px; margin-right: 8px; }
.btn-move {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 10px; padding: 0 6px; line-height: 16px; border-radius: 4px;
  cursor: pointer; transition: all 0.15s;
}
.btn-move:hover { color: var(--gold); border-color: var(--gold); background: rgba(245,158,11,0.08); }

/* --- Custom line number input --- */
.line-num-edit { display: flex; align-items: center; }
.input-custom-num {
  width: 52px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--gold); background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25); border-radius: 20px;
  padding: 2px 6px; outline: none; transition: border-color 0.15s;
}
.input-custom-num:focus {
  border-color: var(--gold); background: rgba(245,158,11,0.15);
}
.input-custom-num::placeholder { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.devis-line-variante .input-custom-num {
  background: rgba(124,58,237,0.15) !important;
  color: #a855f7 !important;
  border-color: rgba(124,58,237,0.3) !important;
}

/* --- Fiche technique link in form --- */
.ft-link-inline {
  display: inline-block; margin-top: 6px; font-size: 12px;
  color: var(--gold); text-decoration: none; font-weight: 600;
  padding: 3px 10px; border-radius: 6px;
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2);
  transition: all 0.15s;
}
.ft-link-inline:hover { background: rgba(245,158,11,0.15); border-color: var(--gold); }


.devis-totals {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-top: 16px;
}
.devis-totals .total-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  font-size: 14px; color: var(--text-muted);
}
.devis-totals .total-row.grand-total {
  border-top: 2px solid var(--gold); padding-top: 12px; margin-top: 8px;
  font-size: 18px; font-weight: 700; color: var(--gold-light);
}

/* ==========================================================================
   LOADING / SPINNER
   ========================================================================== */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(15,17,23,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; display: none;
}
.loading-overlay.show { display: flex; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */


/* ==========================================================================
   RESPONSIVE — SMARTPHONE (max-width: 768px)
   ========================================================================== */

/* --- Hamburger Button --- */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
  z-index: 201;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* --- Sidebar Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 149;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {

  /* --- Hamburger visible --- */
  .hamburger-btn { display: flex; }

  /* --- LOGIN PAGE --- */
  .login-wrapper {
    padding: 20px 16px;
    align-items: flex-start;
    padding-top: 15vh;
  }
  .login-card {
    width: 100%;
    max-width: 100%;
    padding: 32px 20px;
    border-radius: 12px;
  }
  .login-logo {
    font-size: 24px;
    letter-spacing: 4px;
  }
  .login-sub {
    font-size: 10px;
    margin-bottom: 28px;
  }
  #login-form .form-group input {
    padding: 14px 14px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  #login-form .btn {
    min-height: 48px;
    font-size: 15px;
    border-radius: 10px;
  }

  /* --- APP LAYOUT — single column --- */
  .app-layout.active {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) 1fr;
  }

  /* --- HEADER compact --- */
  .app-header {
    padding: 0 12px;
    position: sticky;
    top: 0;
    z-index: 200;
  }
  .header-brand {
    font-size: 14px;
    letter-spacing: 2px;
  }
  .header-user {
    gap: 6px;
  }
  .header-user .user-name { display: none; }
  .header-user .user-role { font-size: 9px; padding: 2px 6px; }
  .btn-logout { padding: 5px 10px; font-size: 11px; }

  /* --- SIDEBAR — slide-in overlay --- */
  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }
  .app-sidebar.open {
    transform: translateX(0);
  }

  /* --- MAIN CONTENT --- */
  .app-main {
    padding: 16px 12px;
    max-height: none;
    overflow-y: visible;
  }

  /* --- PANELS --- */
  .panel-header {
    margin-bottom: 16px;
  }
  .panel-header h2 {
    font-size: 1.15em;
  }
  .panel-desc {
    font-size: 0.82em;
    margin-bottom: 16px;
  }

  /* --- FORM CARDS --- */
  .form-card {
    padding: 16px 14px;
    margin-bottom: 14px;
    border-radius: 12px;
  }
  .form-card h3 {
    font-size: 15px !important;
  }

  /* --- FORM GRID — stack all --- */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* --- INPUTS larger touch targets --- */
  input, select, textarea {
    padding: 12px 14px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: 8px;
  }
  .form-group label {
    font-size: 11px;
  }
  .form-group {
    margin-bottom: 12px;
  }

  /* --- DROP ZONE compact --- */
  .drop-zone {
    padding: 20px 14px;
  }
  .drop-zone .dz-icon { font-size: 1.5em; }
  .drop-zone .dz-text { font-size: 13px; }

  /* --- BUTTONS — full width stacked --- */
  .form-actions {
    flex-direction: column;
    gap: 8px;
    padding: 0 !important;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 14px;
  }

  /* --- KPI GRID --- */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 10px; }

  /* ==========================================================================
     DEVIS — Mobile Card Layout
     ========================================================================== */

  /* --- Devis header buttons: stack --- */
  #panel-devis .form-card > div[style*="display:flex"][style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  #panel-devis .form-card > div[style*="display:flex"][style*="justify-content:space-between"] > div[style*="display:flex"][style*="gap:8px"] {
    flex-direction: column !important;
  }
  #panel-devis .form-card > div[style*="display:flex"][style*="gap:8px"] .btn,
  #panel-devis .form-card > div[style*="display:flex"][style*="gap:8px"] button {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
    font-size: 13px !important;
  }

  /* --- Devis lines — card mode --- */
  .devis-line {
    padding: 14px 12px;
    margin-bottom: 12px;
    border-radius: 10px;
  }

  .devis-line .line-header {
    flex-wrap: wrap;
    gap: 6px;
    padding-right: 0;
    margin-bottom: 12px;
  }

  /* Hide drag handle on mobile */
  .devis-line .drag-handle { display: none; }

  /* Show move buttons prominently */
  .devis-line .line-move-btns {
    flex-direction: row;
    gap: 4px;
  }
  .devis-line .btn-move {
    padding: 4px 12px;
    font-size: 12px;
  }

  /* Variante / toggle buttons */
  .devis-line .btn-toggle-variante {
    font-size: 10px !important;
    padding: 3px 8px !important;
  }

  /* Line grid — VERTICAL CARD layout */
  .devis-line .line-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  /* Make each field in the line a labeled card-row */
  .devis-line .line-grid .form-group {
    margin-bottom: 4px;
  }

  /* Recherche produit field full width */
  .devis-line .search-box input {
    font-size: 15px;
  }

  /* Quantity + price fields: 2-column on mobile */
  .devis-line .line-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  /* --- Devis totals --- */
  .devis-totals {
    padding: 16px 14px;
    border-radius: 10px;
  }
  .devis-totals .total-row {
    font-size: 13px;
    padding: 5px 0;
  }
  .devis-totals .total-row.grand-total {
    font-size: 16px;
  }

  /* --- Search box --- */
  .search-box input {
    padding-left: 36px;
  }

  /* --- Tables — horizontal scroll --- */
  .data-table { display: block; overflow-x: auto; }

  /* --- Alerts --- */
  .alert { font-size: 12px; padding: 12px 14px; }

  /* --- AI badge compact --- */
  .ai-badge { font-size: 0.65em; padding: 2px 7px; }

  /* --- Prevent horizontal overflow --- */
  body { overflow-x: hidden; }
  .app-layout { overflow-x: hidden; }

}

/* ==========================================================================
   RESPONSIVE — SMALL PHONES (max-width: 375px)
   ========================================================================== */
@media (max-width: 375px) {
  .login-card { padding: 28px 16px; }
  .login-logo { font-size: 20px; letter-spacing: 3px; }
  .app-main { padding: 12px 8px; }
  .form-card { padding: 14px 10px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 20px; }
  .header-brand { font-size: 12px; letter-spacing: 1.5px; }
}
