:root {
  --bg: #0f1114;
  --bg-card: #1a1c1e;
  --bg-hover: #222528;
  --border: #2e3238;
  --text: #f5f5f5;
  --muted: #8b9199;
  --primary: #c5a880;
  --primary-hover: #d4b892;
  --success: #22c55e;
  --danger: #c45c5c;
  --warning: #f59e0b;
  --radius: 10px;
  --touch-min: 48px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

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

/* ——— Layout sidebar + contenu ——— */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem;
}

.app-sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.35rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.app-sidebar-logo {
  display: block;
  width: 100%;
  text-decoration: none;
}

.app-sidebar-logo img {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

.app-sidebar-tag {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  font-weight: 600;
}

.app-sidebar-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow-y: auto;
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.app-sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.app-sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.app-sidebar-link.active {
  background: var(--primary);
  color: #1a1510;
}

.app-sidebar-link.active svg {
  opacity: 1;
}

/* Groupes / sous-menus */
.app-sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.app-sidebar-group-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.app-sidebar-group-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.app-sidebar-group.is-open > .app-sidebar-group-toggle,
.app-sidebar-group:has(.app-sidebar-sublink.active) > .app-sidebar-group-toggle {
  color: var(--text);
}

.app-sidebar-group-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.app-sidebar-chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.6;
  transition: transform 0.2s ease;
}

.app-sidebar-group.is-open .app-sidebar-chevron {
  transform: rotate(180deg);
}

.app-sidebar-group-toggle .app-sidebar-badge {
  margin-left: 0;
  margin-right: 0.15rem;
}

.app-sidebar-sub {
  display: none;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.15rem 0 0.35rem 0.35rem;
  margin-left: 0.65rem;
  border-left: 1px solid var(--border);
}

.app-sidebar-group.is-open .app-sidebar-sub {
  display: flex;
}

.app-sidebar-sublink {
  padding: 0.5rem 0.65rem 0.5rem 0.5rem;
  font-size: 0.84rem;
  font-weight: 500;
  gap: 0.5rem;
}

.app-sidebar-sublink svg {
  display: none;
}

.app-sidebar-sublink-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.app-sidebar-sublink.active .app-sidebar-sublink-dot {
  background: #1a1510;
}

.app-sidebar-sublink.active {
  background: var(--primary);
  color: #1a1510;
}

.app-sidebar-sublink .app-sidebar-badge {
  min-width: 20px;
  height: 20px;
  font-size: 0.7rem;
  padding: 0 5px;
}

.app-sidebar-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #1a1510;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.75rem;
}

.app-sidebar-footer strong {
  display: block;
  font-size: 0.8rem;
  color: var(--text);
}

.app-sidebar-footer span {
  color: var(--muted);
}

.app-sidebar-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  margin-left: auto;
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-topbar-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.app-topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.app-topbar-user strong {
  display: block;
  color: var(--text);
}

.app-topbar-user span {
  color: var(--muted);
  font-size: 0.8rem;
}

.app-topbar-logout {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.app-topbar-logout:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.app-content {
  flex: 1;
  padding: 1.25rem;
  overflow: auto;
}

.page { padding: 0; max-width: 1400px; margin: 0 auto; width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-hover);
  color: var(--text);
  transition: background 0.15s;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 40px; padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn-icon { min-width: var(--touch-min); padding: 0.5rem; }

.touch-input, input, select, textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
label { display: block; margin: 0.75rem 0 0.35rem; color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h2, .card h3 { margin-bottom: 0.75rem; }
.muted { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--primary-hover); }
.stat-card .label { color: var(--muted); margin-top: 0.25rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
tr:hover td { background: var(--bg-hover); }

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-success { background: #14532d; color: #86efac; }
.badge-warning { background: #78350f; color: #fcd34d; }
.badge-danger { background: #7f1d1d; color: #fca5a5; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: #7f1d1d; color: #fecaca; }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.login-card h1 { text-align: center; margin-bottom: 0.25rem; }

.app-logo {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  margin: 0 auto 1rem;
  object-fit: contain;
}

.app-logo--picto {
  max-width: 96px;
}

.app-logo-nav {
  max-width: 160px;
  max-height: 40px;
  margin: 0;
  width: auto;
}

.brand-logo-link {
  display: flex;
  align-items: center;
  padding: 0.25rem 0;
}

.login-subtitle {
  text-align: center;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.login-card .hint { margin-top: 1rem; font-size: 0.8rem; color: var(--muted); text-align: center; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-header h1 { font-size: 1.5rem; }

.hidden { display: none !important; }

/* POS */
body.pos-screen { overflow: hidden; }
.pos-app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pos-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.pos-search { flex: 1; font-size: 1.1rem; }
.pos-body { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.pos-sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.category-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  overflow-x: auto;
  flex-shrink: 0;
}
.cat-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.cat-btn.active { border-color: var(--cat-color, var(--primary)); background: var(--bg-hover); }
.product-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
  align-content: start;
}
.product-tile {
  min-height: 90px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
}
.product-tile:active { transform: scale(0.97); background: var(--primary); }
.product-name { font-size: 0.9rem; font-weight: 600; line-height: 1.2; }
.product-price { color: var(--success); font-weight: 700; }

.pos-cart {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  min-height: 0;
}
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.cart-lines {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0.5rem;
}
.cart-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.cart-line .qty-controls { display: flex; gap: 0.25rem; }
.cart-line .qty-btn {
  min-width: 40px;
  min-height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.cart-client { padding: 0.5rem 1rem; border-top: 1px solid var(--border); }
.cart-adjustments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.cart-adjustments label { font-size: 0.75rem; margin: 0; }
.cart-adjustments .touch-input { min-height: 40px; font-size: 0.95rem; }
.cart-line .btn-remove { background: var(--danger); color: #fff; }
.client-badge {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--primary);
  border-radius: 8px;
  font-size: 0.9rem;
}
.cart-totals {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}
.cart-totals div { display: flex; justify-content: space-between; margin: 0.25rem 0; }
.cart-totals .total-ttc { font-size: 1.25rem; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.cart-totals .total-ttc strong { color: var(--success); }
.cart-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
}
.btn-pay {
  min-height: 56px;
  font-size: 1.1rem;
  background: var(--success);
  color: #fff;
}
.btn-pay.btn-mixed { background: var(--warning); color: #000; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
}
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}
.numpad-key {
  min-height: 56px;
  font-size: 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text);
  cursor: pointer;
}
.modal-actions { display: flex; gap: 0.5rem; }
.modal-actions .btn { flex: 1; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  z-index: 2000;
}

/* Responsive : voir responsive.css */
