:root {
  --primary: #1e5f4e;
  --primary-dark: #123f33;
  --accent: #d99a2b;
  --danger: #b5342d;
  --warn: #c47e17;
  --ok: #2f7a3e;
  --bg: #f4f6f5;
  --panel-bg: #ffffff;
  --border: #dfe3e1;
  --text: #1f2b28;
  --muted: #6b7a75;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

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

/* ---- Login ---- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}
.login-box {
  background: var(--panel-bg); padding: 32px; border-radius: var(--radius);
  width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-box h1 { margin: 0; color: var(--primary); letter-spacing: 1px; }
.login-box .subtitle { color: var(--muted); margin-top: 0; margin-bottom: 20px; }
.login-box fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.login-box legend { padding: 0 6px; font-size: 13px; color: var(--muted); }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 10px; margin-top: 4px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; font-family: inherit;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; font-size: 14px; text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 8px; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary-dark); color: #fff; padding: 10px 24px; flex-wrap: wrap; gap: 8px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; letter-spacing: 1px; }
.entreprise { opacity: .7; font-size: 13px; }
.topbar-nav { display: flex; gap: 16px; flex-wrap: wrap; }
.topbar-nav a { color: #fff; opacity: .85; font-size: 14px; }
.topbar-nav a:hover { opacity: 1; text-decoration: underline; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar-right .btn { background: rgba(255,255,255,.15); color: #fff; border-color: transparent; }

.content { padding: 24px; max-width: 1200px; margin: 0 auto; }
h1 { color: var(--primary-dark); margin-top: 0; }

/* ---- Alerts ---- */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: #e3f3e5; color: var(--ok); border: 1px solid #b7dfbd; }
.alert-error { background: #fbe6e4; color: var(--danger); border: 1px solid #f0bcb7; }

/* ---- Panels / cards ---- */
.panel { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.panel-warn { border-color: var(--warn); background: #fff8ea; }
.panel h2 { margin-top: 0; font-size: 17px; color: var(--primary-dark); }

.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2col-wide { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2col, .grid-2col-wide { grid-template-columns: 1fr; } }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card {
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-card.kpi-warn { border-color: var(--danger); background: #fff3f2; }
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--primary-dark); }

.report-link {
  display: block; background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; color: var(--text);
}
.report-link h3 { margin: 0 0 6px; color: var(--primary); }
.report-link p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---- Tables ---- */
.table-simple { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-simple th, .table-simple td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table-simple thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.row-warn { background: #fff6ea; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-nouvelle { background: #e5e9f7; color: #354ba8; }
.badge-validee { background: #e3ecfb; color: #2360bf; }
.badge-en_preparation { background: #fdf1d8; color: var(--warn); }
.badge-prete { background: #e2f6e6; color: var(--ok); }
.badge-servie { background: #dff3ec; color: #1a7f61; }
.badge-payee, .badge-cloturee, .badge-ok, .badge-fermee { background: #e3f3e5; color: var(--ok); }
.badge-annulee, .badge-danger, .badge-manquant { background: #fbe6e4; color: var(--danger); }
.badge-warn, .badge-surplus { background: #fdf1d8; color: var(--warn); }
.badge-ouverte, .badge-locked { background: #e5e9f7; color: #354ba8; }

/* ---- Produit grid (caisse & serveuse) ---- */
.produits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px,1fr)); gap: 8px; margin: 12px 0; max-height: 320px; overflow-y: auto; }
.produit-btn {
  background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px 6px;
  cursor: pointer; font-size: 12px; text-align: center;
}
.produit-btn:hover { border-color: var(--primary); background: #f0f7f4; }

/* ---- Tables (dining) ---- */
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; }
.table-card {
  border-radius: var(--radius); padding: 16px; border: 2px solid var(--border); background: var(--panel-bg);
}
.table-card-link { color: inherit; display: block; }
.table-libre { border-color: var(--ok); }
.table-occupee { border-color: var(--warn); background: #fff9ec; }
.table-card h3 { margin: 0 0 8px; }

/* ---- Fiches (cuisine/bar/frigo) ---- */
.fiches-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 14px; }
.fiche-card { background: var(--panel-bg); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; }
.fiche-nouvelle { border-color: #354ba8; }
.fiche-en_preparation { border-color: var(--warn); }
.fiche-prete { border-color: var(--ok); }
.fiche-items { padding-left: 18px; font-size: 13px; }
.fiche-note {
  background: #fff8ea; border: 1px solid #f0d999; border-radius: 6px; padding: 6px 10px;
  font-size: 12.5px; color: #7a5a12; margin: 6px 0;
}

/* ---- Commande cards (caisse waiting list) ---- */
.commande-card { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.commande-card form { margin-top: 4px; }

.tab-links { display: flex; gap: 6px; margin-bottom: 14px; }
.tab-links a { padding: 6px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--border); font-size: 13px; }
.tab-links a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.muted { color: var(--muted); font-size: 13px; }

/* =====================================================================
   POS INTERFACE — Caisse & Vente (design "boutique" style teal)
   ===================================================================== */
:root {
  --pos-teal: #38c9c2;
  --pos-teal-dark: #2ba39d;
  --pos-teal-darker: #1f8c86;
  --pos-navy: #17313a;
  --pos-ink: #24333a;
  --pos-price: #1d4ed8;
  --pos-stock: #16a34a;
  --pos-annuler: #f5a623;
  --pos-proforma: #52606d;
  --pos-danger: #d64545;
}

.pos-body { background: #eef2f2; margin: 0; }

/* ---- Topbar ---- */
.pos-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--pos-teal); color: #fff; padding: 0 20px; height: 58px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08); position: relative; z-index: 40;
  flex-wrap: wrap; gap: 10px;
}
.pos-topbar-left { display: flex; align-items: center; gap: 10px; }
.pos-logo {
  width: 34px; height: 34px; border-radius: 6px; background: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800;
  color: var(--pos-teal-darker); font-size: 13px; overflow: hidden;
}
.pos-brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }

.pos-nav { display: flex; align-items: center; gap: 4px; }
.pos-nav-btn, .pos-user-btn {
  background: transparent; border: none; color: #fff; font-size: 13px; font-weight: 600;
  letter-spacing: .3px; padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 4px;
  border-radius: 6px;
}
.pos-nav-btn:hover, .pos-user-btn:hover { background: rgba(255,255,255,.14); }
.pos-nav-btn .badge-count {
  background: #fff; color: var(--pos-teal-darker); border-radius: 10px; font-size: 10px;
  padding: 1px 6px; margin-left: 2px; font-weight: 700;
}
.caret { font-size: 10px; opacity: .8; }

.pos-topbar-right { display: flex; align-items: center; gap: 6px; }
.pos-clock { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 0 8px; opacity: .95; }
.pos-clock .clock-face {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; position: relative;
}
.pos-clock .clock-face::before, .pos-clock .clock-face::after {
  content: ''; position: absolute; background: #fff; left: 50%; top: 50%; transform-origin: 0 0;
}
.pos-clock .clock-face::before { width: 1px; height: 6px; margin-top: -6px; }
.pos-clock .clock-face::after { width: 1px; height: 4px; margin-top: -4px; transform: rotate(90deg); }

.pos-user-btn { font-weight: 700; }
.pos-bell { position: relative; font-size: 14px; }
.pos-bell .dot { position: absolute; top: -2px; right: -3px; width: 6px; height: 6px; background: #ff5a5a; border-radius: 50%; }

.pos-dropdown { position: relative; }
.pos-dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--pos-ink);
  border-radius: 8px; box-shadow: 0 12px 30px rgba(0,0,0,.18); min-width: 210px; padding: 6px 0;
  border: 1px solid #e5e9e9;
}
.pos-dropdown.pos-align-left .pos-dropdown-menu { left: 0; right: auto; }
.pos-dropdown.open .pos-dropdown-menu { display: block; }
.pos-dropdown-menu a, .pos-dropdown-menu .pos-dropdown-disabled {
  display: block; padding: 9px 16px; font-size: 13.5px; color: var(--pos-ink); white-space: nowrap;
}
.pos-dropdown-menu a:hover { background: #f0fbfa; }
.pos-dropdown-menu .pos-dropdown-disabled { color: #a7b0b0; cursor: not-allowed; }
.pos-dropdown-menu .pos-dropdown-empty { padding: 10px 16px; font-size: 12.5px; color: #9aa5a5; }
.pos-dropdown-wide { min-width: 260px; max-height: 320px; overflow-y: auto; }
.pos-dropdown-divider { height: 1px; background: #ececec; margin: 6px 0; }

/* ---- Main layout ---- */
.pos-main {
  display: grid; grid-template-columns: 340px 1fr; gap: 18px; padding: 18px; max-width: 1500px; margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) { .pos-main { grid-template-columns: 1fr; } }

/* ---- Cart panel (left) ---- */
.pos-cart-panel {
  background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex; flex-direction: column; gap: 12px;
}
.pos-client-search { display: flex; gap: 8px; position: relative; }
.pos-client-search input { flex: 1; margin: 0; }
.pos-client-results {
  display: none; position: absolute; top: 100%; left: 0; right: 74px; background: #fff;
  border: 1px solid #e2e6e6; border-radius: 8px; box-shadow: 0 10px 24px rgba(0,0,0,.12);
  z-index: 20; max-height: 200px; overflow-y: auto; margin-top: 4px;
}
.pos-client-results.open { display: block; }
.pos-client-results div { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.pos-client-results div:hover { background: #f0fbfa; }
.pos-client-selected {
  font-size: 12.5px; color: var(--pos-teal-darker); background: #eafbfa; border-radius: 6px;
  padding: 6px 10px; display: none; align-items: center; justify-content: space-between;
}
.pos-client-selected.show { display: flex; }
.pos-client-quick-add { display: none; gap: 8px; background: #f7fafa; padding: 10px; border-radius: 8px; }
.pos-client-quick-add.open { display: flex; flex-wrap: wrap; }
.pos-client-quick-add input { flex: 1; min-width: 110px; margin: 0; }

.btn-teal {
  background: var(--pos-teal); color: #fff; border: none; border-radius: 6px; padding: 9px 14px;
  font-weight: 700; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.btn-teal:hover { background: var(--pos-teal-dark); }

.pos-cart-box { border: 1px solid #eef1f1; border-radius: 8px; padding: 12px; }
.cart-empty-msg { color: var(--pos-danger); font-weight: 700; text-align: center; margin: 18px 0; font-size: 15px; }
.pos-cart-table { width: 100%; border-collapse: collapse; font-size: 13px; display: none; }
.pos-cart-table.has-items { display: table; }
.pos-cart-table th { text-align: left; color: #8a9494; font-weight: 600; font-size: 11px; text-transform: uppercase; padding: 6px 4px; border-bottom: 1px solid #eef1f1; }
.pos-cart-table td { padding: 8px 4px; border-bottom: 1px solid #f4f6f6; vertical-align: middle; }
.pos-cart-table input[type="number"] { width: 52px; padding: 5px; margin: 0; }
.pos-cart-remove { background: none; border: none; color: var(--pos-danger); cursor: pointer; font-size: 15px; }

.pos-cart-total-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #e2e6e6; }
.pos-cart-total-row .total-label { font-size: 12px; color: #8a9494; font-weight: 700; text-transform: uppercase; }
.pos-cart-total-row .total-value { font-size: 19px; font-weight: 800; color: var(--pos-ink); margin-left: 6px; }
.pos-cart-total-row .qte-total { font-size: 13px; color: #8a9494; margin-right: 8px; }
.pos-cart-total-row .right-group { display: flex; align-items: center; }

.pos-cart-note { display: flex; flex-direction: column; gap: 4px; }
.pos-cart-note label { font-size: 12px; font-weight: 700; color: #52606d; text-transform: uppercase; letter-spacing: .3px; }
.pos-cart-note label .muted { text-transform: none; font-weight: 400; font-size: 11px; }
.pos-cart-note textarea {
  width: 100%; border: 1px solid #e2e6e6; border-radius: 8px; padding: 8px 10px; font-family: inherit;
  font-size: 13px; resize: vertical; min-height: 44px;
}

.pos-cart-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.pos-cart-actions button {
  border: none; border-radius: 6px; padding: 12px 6px; font-weight: 800; font-size: 12.5px;
  letter-spacing: .3px; cursor: pointer; color: #fff;
}
.btn-annuler { background: var(--pos-annuler); }
.btn-annuler:hover { background: #dd9315; }
.btn-proforma { background: var(--pos-proforma); }
.btn-proforma:hover { background: #3f4a51; }
.btn-payer { background: var(--pos-teal); }
.btn-payer:hover { background: var(--pos-teal-dark); }
.btn-commander {
  width: 100%; background: var(--pos-teal); color: #fff; border: none; border-radius: 6px;
  padding: 14px; font-weight: 800; font-size: 13.5px; letter-spacing: .4px; cursor: pointer;
}
.btn-commander:hover { background: var(--pos-teal-dark); }
.btn-commander:disabled, .pos-cart-actions button:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Product panel (right) ---- */
.pos-produits-panel { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.pos-produits-filtres { display: grid; grid-template-columns: 1fr 220px; gap: 10px; margin-bottom: 14px; }
@media (max-width: 600px) { .pos-produits-filtres { grid-template-columns: 1fr; } }
.pos-produits-filtres input, .pos-produits-filtres select { margin: 0; }

.pos-produits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 14px; max-height: 640px; overflow-y: auto; padding-right: 4px; }
.pos-produit-card {
  background: #fff; border: 1px solid #edf0f0; border-radius: 10px; padding: 10px; cursor: pointer;
  text-align: left; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .12s, border-color .12s;
}
.pos-produit-card:hover { border-color: var(--pos-teal); box-shadow: 0 6px 16px rgba(56,201,194,.18); }
.pos-produit-card.out-of-stock { opacity: .5; cursor: not-allowed; }
.pos-produit-img {
  width: 100%; aspect-ratio: 1/1; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 26px; overflow: hidden; background-size: cover; background-position: center;
}
.pos-produit-nom { font-size: 13px; font-weight: 600; color: var(--pos-ink); line-height: 1.2; }
.pos-produit-prix { font-size: 14px; font-weight: 800; color: var(--pos-price); }
.pos-produit-stock { font-size: 11.5px; color: var(--pos-stock); font-weight: 600; }
.pos-produit-stock.low { color: var(--pos-danger); }

/* ---- Secondary sections below (validation / paiement / retours) ---- */
.pos-subsection { max-width: 1500px; margin: 0 auto; padding: 0 18px 24px; }
.pos-subsection .panel { border-radius: 10px; }

/* =====================================================================
   APP SHELL — Sidebar layout (référence design "Agape / TOK POS")
   ===================================================================== */
.app-shell { background: #f4f6f5; margin: 0; }

.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--pos-teal, #38c9c2); color: #fff; padding: 0 20px; height: 54px;
  position: sticky; top: 0; z-index: 50;
}
.app-topbar-left { display: flex; align-items: center; gap: 10px; }
.app-logo {
  width: 32px; height: 32px; border-radius: 6px; background: #fff; color: var(--pos-teal-darker, #1f8c86);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px;
}
.app-brand { font-weight: 700; font-size: 16px; }
.app-topbar-right { display: flex; align-items: center; gap: 6px; }
.app-bell-btn, .app-user-btn {
  background: transparent; border: none; color: #fff; font-size: 13px; cursor: pointer;
  padding: 7px 10px; border-radius: 6px; display: flex; align-items: center; gap: 4px; font-weight: 600;
}
.app-bell-btn:hover, .app-user-btn:hover { background: rgba(255,255,255,.15); }

.app-body { display: flex; align-items: flex-start; min-height: calc(100vh - 54px); }

.app-sidebar {
  width: 220px; flex-shrink: 0; background: #fff; border-right: 1px solid #e7ebea;
  min-height: calc(100vh - 54px); padding: 18px 0; position: sticky; top: 54px;
}
.app-sidebar-user { padding: 0 18px 14px; border-bottom: 1px solid #eef1f1; margin-bottom: 10px; }
.app-sidebar-role { display: block; font-size: 11px; color: #96a19f; text-transform: uppercase; letter-spacing: .4px; }
.app-sidebar-user strong { font-size: 13.5px; color: var(--pos-navy, #17313a); }

.app-nav { display: flex; flex-direction: column; }
.app-nav-section {
  padding: 14px 18px 6px; font-size: 10.5px; color: #a3adac; text-transform: uppercase;
  letter-spacing: .6px; font-weight: 700;
}
.app-nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: #4b5a58;
  font-size: 13.5px; font-weight: 500; border-left: 3px solid transparent;
}
.app-nav-link:hover { background: #f4fbfa; color: var(--pos-teal-darker, #1f8c86); }
.app-nav-link.active { background: #eafbfa; color: var(--pos-teal-darker, #1f8c86); border-left-color: var(--pos-teal, #38c9c2); font-weight: 700; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }
.app-sidebar-version { padding: 18px; font-size: 11px; color: #c1c8c7; margin-top: 20px; }

.app-content { flex: 1; padding: 22px 26px; min-width: 0; }
.app-content h1 { margin-top: 0; }

@media (max-width: 900px) {
  .app-body { flex-direction: column; }
  .app-sidebar { width: 100%; position: static; min-height: auto; border-right: none; border-bottom: 1px solid #e7ebea; }
  .app-nav { flex-direction: row; flex-wrap: wrap; }
  .app-nav-link { border-left: none; border-bottom: 3px solid transparent; }
  .app-nav-link.active { border-left: none; border-bottom-color: var(--pos-teal, #38c9c2); }
}

/* ---- Print (Imprimer) — reçus/fiches ---- */
.print-page { max-width: 380px; margin: 0 auto; padding: 20px; font-family: 'Courier New', monospace; color: #111; }
.print-page h1 { font-size: 16px; text-align: center; margin: 4px 0; }
.print-page .print-sub { text-align: center; font-size: 12px; color: #444; margin-bottom: 10px; }
.print-page hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.print-page table { width: 100%; border-collapse: collapse; font-size: 12px; }
.print-page td, .print-page th { padding: 3px 0; text-align: left; }
.print-page .col-right { text-align: right; }
.print-page .total-line { font-weight: 700; font-size: 14px; }
.print-actions { text-align: center; margin: 16px 0; }
.print-actions button { padding: 8px 18px; }
@media print {
  .print-actions { display: none; }
  body { background: #fff; }
  .app-topbar, .app-sidebar, .no-print { display: none !important; }
  .app-body { display: block !important; }
  .app-content { padding: 0 !important; }
}

.btn-print-report {
  background: #fff; border: 1px solid #dfe3e1; border-radius: 6px; padding: 7px 14px;
  font-size: 12.5px; font-weight: 600; color: #17313a; cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn-print-report:hover { background: #f0fbfa; border-color: #38c9c2; }
.report-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
