/* ygrek-pos — interface tactile iPhone / iPad. */
:root {
  --brand: #C8102E;
  --brand-ink: #fff;
  --bg: #F7F4EF;
  --card: #FFFFFF;
  --ink: #1C1C1E;
  --muted: #6E6A64;
  --line: #E6E0D6;
  --soft: #EFEAE2;
  --ok: #1E7F4B;
  --warn: #B86A00;
  --bad: #B3261E;
  --r: 16px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --cart-w: 380px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { overscroll-behavior: none; touch-action: manipulation; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- boutons ---------- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; transition: transform .06s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.small { min-height: 38px; font-size: 14px; padding: 0 12px; }
.btn.danger { background: #FBE9E7; color: var(--bad); }
.link { color: var(--brand); font-weight: 600; padding: 8px; }
.row { display: flex; gap: 10px; }
.row > .btn { flex: 1; }

/* ---------- connexion ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.logo { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--brand); }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 22px; min-height: 16px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots span.on { background: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.keypad button {
  height: 68px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow);
  font-size: 26px; font-weight: 500; width: 68px; justify-self: center;
}
.keypad button.fn { background: transparent; box-shadow: none; font-size: 16px; color: var(--muted); }
.keypad button:active { background: var(--soft); }
.device-field { display: block; margin-top: 22px; text-align: left; font-size: 13px; color: var(--muted); }
.device-field input, .sheet input, .sheet select, .form input, .form select, .form textarea {
  width: 100%; min-height: 48px; margin-top: 6px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); font-size: 17px;
}
.form textarea { padding: 12px 14px; min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* ---------- structure ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: calc(8px + var(--safe-t)) 14px 8px;
  background: var(--card); border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; white-space: nowrap; }
.brand-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--brand); }
.tabs { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; margin: 0 auto; }
.tab { padding: 8px 18px; border-radius: 9px; font-weight: 600; font-size: 15px; color: var(--muted); }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sync {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: #E7F4EC; color: var(--ok); white-space: nowrap;
}
.sync.warn { background: #FFF1DC; color: var(--warn); }
.sync.bad { background: #FBE9E7; color: var(--bad); }
.view { flex: 1; min-height: 0; }
.menu-btn {
  width: 40px; height: 36px; border-radius: 10px; background: var(--soft); font-size: 18px; font-weight: 700;
  display: grid; place-items: center; flex: none;
}
.admin-top { flex-wrap: wrap; }
.admin-top .brand { margin-right: auto; }
@media (max-width: 1100px) {
  .admin-top .tabs { order: 3; width: 100%; margin: 4px 0 0; overflow-x: auto; scrollbar-width: none; }
  .admin-top .tab { flex: 1 0 auto; }
}

/* ---------- vente ---------- */
.sale { display: grid; grid-template-columns: 1fr var(--cart-w); }
.catalog { overflow-y: auto; padding: 14px 14px calc(110px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.promo-banner {
  background: var(--brand); color: var(--brand-ink); border-radius: var(--r-sm);
  padding: 10px 14px; font-weight: 700; margin-bottom: 12px; font-size: 15px;
}
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 15px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-weight: 600; font-size: 15px;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.search {
  flex: 1 1 200px; min-height: 42px; border-radius: 999px; border: 1px solid var(--line); padding: 0 16px;
  background: var(--card); font-size: 16px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  position: relative; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; text-align: left; display: flex; flex-direction: column; min-height: 150px;
  user-select: none; -webkit-user-select: none; transition: transform .06s;
}
.tile:active { transform: scale(.96); }
.tile .ph {
  aspect-ratio: 4 / 3; background: var(--soft) center / cover no-repeat;
  display: grid; place-items: center; font-size: 34px; font-weight: 800; color: rgba(0,0,0,.18);
}
.tile .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.tile .name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.tile .sub { font-size: 13px; color: var(--muted); line-height: 1.2; }
.tile .price { margin-top: auto; padding-top: 6px; font-weight: 700; font-size: 16px; }
.tile .qty {
  position: absolute; top: 8px; right: 8px; min-width: 32px; height: 32px; padding: 0 9px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.tile .stock {
  position: absolute; top: 8px; left: 8px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.92); color: var(--muted);
}
.tile .stock.low { color: var(--warn); }
.tile .stock.out { color: #fff; background: var(--bad); }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); }

.cart {
  background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 14px 14px calc(14px + var(--safe-b)); min-height: 0;
}
.cart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#cartClose { display: none; }
.cart-lines { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.cline { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--soft); }
.cline .n { font-weight: 600; font-size: 15px; }
.cline .p { text-align: right; font-weight: 700; }
.cline .p s { color: var(--muted); font-weight: 400; font-size: 13px; display: block; }
.cline .badge { display: inline-block; font-size: 12px; font-weight: 700; color: var(--brand); margin-left: 4px; }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--soft); border-radius: 999px; }
.stepper button { width: 38px; height: 34px; font-size: 20px; font-weight: 600; }
.stepper span { min-width: 22px; text-align: center; font-weight: 700; }
.cline .u { font-size: 13px; color: var(--muted); align-self: center; text-align: right; }
.cart-totals { padding: 10px 0; border-top: 1px solid var(--line); margin-top: 6px; }
.trow { display: flex; justify-content: space-between; font-size: 15px; padding: 2px 0; color: var(--muted); }
.trow.disc { color: var(--brand); }
.trow.total { color: var(--ink); font-size: 26px; font-weight: 800; padding-top: 6px; }
.cart-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.cart-actions .btn { flex: 1; min-height: 42px; font-size: 15px; }
.pay-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn.pay { min-height: 64px; background: var(--ink); color: #fff; font-size: 17px; border-radius: var(--r-sm); }
.btn.pay[data-pay="twint"] { background: #000; }
.btn.pay[data-pay="cash"] { background: var(--ok); }
.cartbar { display: none; }

/* ---------- feuilles (modales) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,20,.38); z-index: 20; display: flex;
  align-items: center; justify-content: center; padding: 20px; animation: fade .15s;
}
.sheet {
  background: var(--card); border-radius: 22px; width: 100%; max-width: 460px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 92vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px; animation: up .18s ease-out;
}
.sheet .big { font-size: 44px; font-weight: 800; text-align: center; letter-spacing: -.02em; }
.sheet .instr { text-align: center; color: var(--muted); font-size: 16px; margin: 0; }
.sheet .change { text-align: center; font-size: 22px; font-weight: 700; color: var(--ok); min-height: 30px; }
.sheet .change.short { color: var(--bad); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { flex: 1 0 auto; min-height: 46px; padding: 0 14px; border-radius: var(--r-sm); background: var(--soft); font-weight: 700; }
.quick button.active { background: var(--ink); color: #fff; }
.seg { display: flex; background: var(--soft); padding: 3px; border-radius: 12px; }
.seg button { flex: 1; min-height: 40px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.btn.confirm { min-height: 60px; font-size: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

/* ---------- journal ---------- */
.journal { overflow-y: auto; padding: 14px 14px calc(30px + var(--safe-b)); }
.journal-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.journal-head input[type=date] {
  min-height: 38px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 10px; background: var(--card);
}
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 4px; }
.kpi .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.main { background: var(--ink); color: #fff; }
.kpi.main .l, .kpi.main .s { color: rgba(255,255,255,.7); }
.cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; align-items: start; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.prow, .srow { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--soft); font-size: 15px; }
.prow:last-child, .srow:last-child { border-bottom: 0; }
.srow { align-items: center; }
.srow .meta { font-size: 13px; color: var(--muted); }
.srow .items { font-size: 14px; }
.srow .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.srow.voided .items, .srow.voided .amt { text-decoration: line-through; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--soft); text-transform: uppercase; letter-spacing: .03em; }
.tag.card { background: #E8EEF9; color: #2B4C8C; }
.tag.twint { background: #111; color: #fff; }
.tag.cash { background: #E7F4EC; color: var(--ok); }
.tag.void { background: #FBE9E7; color: var(--bad); }
.tag.warn { background: #FFF1DC; color: var(--warn); }
.pending { background: #FFF6E8; border: 1px solid #F3D6A8; border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.pending.bad { background: #FDECEA; border-color: #F2B8B5; }

/* ---------- ticket ---------- */
.receipt-wrap { overflow-x: auto; background: var(--soft); border-radius: var(--r-sm); padding: 12px; }
.receipt {
  margin: 0 auto; box-sizing: content-box; background: #fff; padding: 14px 10px; box-shadow: var(--shadow);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: clamp(7px, calc((100vw - 90px) / 30), 12px); line-height: 1.35;
  white-space: pre; color: #111;
}
.receipt .r-title { text-align: center; font-weight: 800; font-size: 1.9em; line-height: 1.2; margin-bottom: 2px; white-space: normal; }
.receipt .r-c { text-align: center; }
.receipt .r-b { font-weight: 700; }
.receipt .r-total { font-weight: 800; transform: scaleY(1.6); margin: 5px 0; }
.receipt .r-feed { height: .9em; }
.receipt .r-logo { text-align: center; }
.receipt .r-logo img { image-rendering: pixelated; max-width: 100%; }
.brand:has(.brand-logo) .brand-dot { display: none; }
.brand-logo { height: 26px; max-width: 140px; object-fit: contain; display: block; }
.login-logo { max-height: 72px; max-width: 220px; object-fit: contain; display: block; margin: 0 auto 6px; }
.print-settings { box-shadow: none; background: var(--soft); }
.print-settings select { width: 100%; min-height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card); padding: 0 10px; margin-top: 6px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 30px);
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); }
#toast.warn { background: var(--warn); }

/* ---------- iPad portrait / petites tablettes ---------- */
@media (max-width: 900px) { :root { --cart-w: 320px; } .tiles { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); } }

/* ---------- iPhone ---------- */
@media (max-width: 700px) {
  .topbar { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .brand { font-size: 16px; gap: 6px; }
  .brand span:last-child { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .tabs { margin: 0 0 0 auto; }
  .tab { padding: 7px 10px; font-size: 14px; }
  .sync { padding: 6px 8px; }
  .sale { grid-template-columns: 1fr; position: relative; }
  .catalog { padding: 12px 12px calc(96px + var(--safe-b)); }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile { min-height: 0; }
  .cart {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; max-height: 88vh;
    border-radius: 22px 22px 0 0; border-left: 0; box-shadow: 0 -10px 40px rgba(0,0,0,.2);
    transform: translateY(105%); transition: transform .22s ease-out;
  }
  .cart.open { transform: none; }
  #cartClose { display: inline-block; }
  .cartbar {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); z-index: 10;
    min-height: 60px; border-radius: 16px; background: var(--ink); color: #fff; align-items: center;
    justify-content: space-between; padding: 0 20px; font-size: 16px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
  }
  .cartbar.has { background: var(--brand); color: var(--brand-ink); }
  .cartbar strong { font-size: 20px; }
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 22px 22px 0 0; max-width: none; padding-bottom: calc(22px + var(--safe-b)); }
  .cols { grid-template-columns: 1fr; }
  .sync .txt { display: none; }
}

/* ---------- admin ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 14px 14px calc(40px + var(--safe-b)); }
.admin-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-head .tabs { margin: 0; }
.alist { display: grid; gap: 8px; }
.aitem {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; background: var(--card);
  border-radius: var(--r-sm); padding: 8px 12px 8px 8px; box-shadow: var(--shadow); text-align: left; width: 100%;
}
.aitem.off { opacity: .5; }
.aitem .th { width: 56px; height: 56px; border-radius: 8px; background: var(--soft) center / cover; display: grid; place-items: center; font-weight: 800; color: rgba(0,0,0,.2); }
.aitem .t { font-weight: 700; }
.aitem .m { font-size: 13px; color: var(--muted); }
.aitem .r { text-align: right; font-weight: 700; }
.form { display: grid; gap: 10px; }
.form label { font-size: 13px; color: var(--muted); font-weight: 600; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--ink) !important; }
.check input { width: 24px; height: 24px; min-height: 0; margin: 0; }
.img-edit { display: flex; gap: 12px; align-items: center; }
.img-edit .logo-th { width: 160px; background-size: contain; background-repeat: no-repeat; background-color: #fff; border: 1px solid var(--line); }
.img-edit .th { width: 88px; height: 88px; border-radius: 12px; background: var(--soft) center / cover; flex: none; }
ul.errors { color: var(--bad); font-size: 14px; padding-left: 18px; margin: 6px 0; }
