/* Layout, dialog, and touch-target corrections for phone, iPad, and desktop. */
[hidden] { display: none !important; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
.app-shell, main, .view, .pos-layout, .catalog-panel, .cart-panel { min-width: 0; }
.auth-screen { min-height: 100svh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%, #dff4d9 0, transparent 28%), #f6f8f4; }
.login-card { width: min(100%, 420px); padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 18px 55px #163d2b18; }
.login-brand { display: inline-flex; padding: 0 0 28px; color: var(--ink); }
.login-card h1 { margin: 4px 0 8px; font-size: 26px; letter-spacing: -.7px; }
.login-copy { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 0 0 22px; }
.login-card label { display: grid; gap: 7px; color: #52645a; font-size: 12px; font-weight: 700; margin-top: 15px; }
.login-card input { width: 100%; height: 45px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: 14px inherit; outline-color: var(--green); }
.login-card .pay-button { margin-top: 22px; }
.login-error { min-height: 16px; color: #c74f43; font-size: 12px; margin: 12px 0 -5px; }
.demo-login { margin: 16px 0 0; color: var(--muted); font-size: 11px; text-align: center; line-height: 1.6; }
.branch-label { display: inline-flex; align-items: center; gap: 4px; color: var(--green); background: var(--green-light); padding: 7px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.branch-label::before { content: '●'; font-size: 8px; color: #4eaa74; }
.branch-select { height: 34px; max-width: 160px; border: 1px solid #cce4d5; border-radius: 9px; padding: 0 26px 0 9px; color: var(--green); background: #fff; font: 700 11px inherit; outline-color: var(--green); }
.view-branch-control { display: flex; min-width: 0; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.view-branch-control > span { flex: none; }
.view-branch-control .branch-select { width: 170px; max-width: 190px; height: 40px; background: rgba(255,255,255,.68); border-color: rgba(190,211,197,.75); font-size: 12px; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.view-branch-control .branch-select:focus { border-color: #61a37e; box-shadow: 0 0 0 3px rgba(71,148,104,.12); }
.payment-modal, .small-modal { box-sizing: border-box; width: calc(100vw - 24px) !important; min-width: 0 !important; min-inline-size: 0; inline-size: min(430px, calc(100dvw - 24px)) !important; max-inline-size: calc(100dvw - 24px) !important; max-width: calc(100vw - 24px); max-height: calc(100svh - 24px); overflow: auto; overscroll-behavior: contain; }
.payment-modal form, .small-modal form { width: 100%; max-width: 100%; }
.payment-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; margin: 7px 0 22px !important; }
.payment-summary > span { font-size: 19px; font-weight: 700; white-space: nowrap; }
.payment-summary strong { min-width: 0; margin-left: auto; color: var(--ink); font-size: clamp(25px, 7vw, 34px); line-height: 1; letter-spacing: -.8px; white-space: nowrap; }
.payment-methods button { min-width: 0; min-height: 68px; overflow: hidden; }
.payment-methods button span { display: block; overflow-wrap: anywhere; }
.cash-input input { min-width: 0; }
.empty-message, .empty-row { color: var(--muted); font-size: 12px; text-align: center; padding: 18px; }
.section-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.inventory-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 16px; }
.inventory-kpi { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.inventory-kpi span, .inventory-kpi small { display: block; color: var(--muted); font-size: 11px; }
.inventory-kpi strong { display: inline-block; margin: 8px 5px 2px 0; font-size: 27px; line-height: 1; }
.inventory-kpi.warning strong { color: #b77908; }
.inventory-kpi.danger strong { color: #c64e42; }
.inventory-kpi.green strong { color: var(--green); }
.inventory-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr); gap: 16px; align-items: start; }
.inventory-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.inventory-toolbar { display: flex; align-items: center; gap: 10px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.inventory-toolbar > div:first-child { margin-right: auto; }
.inventory-toolbar h2 { margin: 0 0 3px; font-size: 15px; }
.inventory-toolbar p { margin: 0; color: var(--muted); font-size: 10px; }
.inventory-search { max-width: 210px; height: 38px; }
.inventory-filter { height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 0 28px 0 10px; background: #fff; color: var(--ink); font: 600 11px inherit; }
.inventory-list { display: grid; }
.inventory-list-head, .inventory-row { display: grid; grid-template-columns: minmax(190px, 1.7fr) 90px 100px 90px; gap: 12px; align-items: center; padding: 11px 18px; }
.inventory-list-head { background: #fafcfa; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.inventory-row { min-height: 68px; border-top: 1px solid #f0f2f0; background: #fff; text-align: left; }
.inventory-product { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inventory-product-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: #f2f7ef; font-size: 23px; }
.inventory-product strong, .inventory-product small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-product strong { font-size: 12px; }
.inventory-product small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.inventory-count { font-size: 18px; font-weight: 700; }
.inventory-count small { color: var(--muted); font-size: 10px; font-weight: 500; }
.stock-status { display: inline-flex; width: fit-content; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 99px; background: #e8f5ed; color: #26764c; font-size: 10px; font-weight: 700; }
.stock-status::before { content: '●'; font-size: 7px; }
.stock-status.low { background: #fff4d8; color: #9a6908; }
.stock-status.out { background: #fde9e6; color: #b64339; }
.stock-adjust-button { min-height: 36px; border: 1px solid #cde1d4; border-radius: 9px; background: #fff; color: var(--green); font: 700 11px inherit; cursor: pointer; }
.stock-adjust-button:hover { background: #edf7f1; }
.movement-list { max-height: 566px; overflow: auto; }
.movement-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 13px 17px; border-top: 1px solid #f0f2f0; }
.movement-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #e9f5ed; color: var(--green); font-weight: 800; }
.movement-icon.minus { background: #fdebea; color: #bd4a40; }
.movement-item strong, .movement-item small { display: block; }
.movement-item strong { font-size: 11px; }
.movement-item small { margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.movement-amount { text-align: right; color: var(--green); font-size: 13px; font-weight: 800; white-space: nowrap; }
.movement-amount.minus { color: #bd4a40; }
.inventory-modal { box-sizing: border-box; width: min(440px, calc(100vw - 24px)); min-width: 0; max-width: calc(100vw - 24px); max-height: calc(100svh - 24px); overflow: auto; border: 0; border-radius: 20px; padding: 0; box-shadow: 0 20px 80px #10291b40; }
.inventory-modal::backdrop { background: #123d2d6d; }
.inventory-modal form { position: relative; padding: 27px; }
.inventory-modal h2 { margin: 5px 0 4px; font-size: 20px; }
.inventory-current { display: flex; justify-content: space-between; margin: 0 0 18px; padding: 10px 12px; border-radius: 10px; background: #f2f7f3; color: var(--muted); font-size: 12px; }
.inventory-current strong { color: var(--ink); }
.stock-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 17px; }
.stock-modes button { min-width: 0; min-height: 58px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); font: 700 11px inherit; cursor: pointer; }
.stock-modes button b { display: block; margin-bottom: 2px; color: inherit; font-size: 17px; }
.stock-modes button.active { border-color: #65a880; background: #edf7f1; color: var(--green); }

@media (min-width: 821px) and (max-width: 1120px) {
  .app-shell { grid-template-columns: 210px 1fr; }
  .sidebar { width: 210px; }
  main { padding: 28px 24px; }
  .pos-layout { grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
  .inventory-layout { grid-template-columns: 1fr; }
  .movement-list { max-height: 360px; }
}
@media (max-width: 820px) {
  .sidebar { overflow: hidden; }
  .main-nav { flex: 1; justify-content: space-around; }
  .nav-item { min-width: 46px; min-height: 44px; justify-content: center; }
  .nav-item.active { background: #235640; }
  .page-head { margin-bottom: 18px; }
  .head-actions { flex-wrap: wrap; }
  .pos-layout { min-height: auto; }
  .catalog-panel { order: 1; }
  .cart-panel { order: 2; }
  .cart-items { max-height: 290px; }
  .chart-wrap { height: 220px; }
  .inventory-kpis { grid-template-columns: repeat(2, 1fr); }
  .inventory-layout { grid-template-columns: 1fr; }
  .movement-list { max-height: 360px; }
}
@media (max-width: 600px) {
  main { padding: 20px 12px 28px; }
  .sidebar { height: 58px; padding: 8px 10px; }
  .brand { margin-right: 4px; }
  .brand b { display: none; }
  .brand span { width: 26px; height: 26px; }
  .main-nav { gap: 0; }
  .nav-item { padding: 8px; }
  .page-head h1 { font-size: 24px; }
  .head-actions { gap: 7px; }
  .view-branch-control { width: 100%; }
  .view-branch-control .branch-select { width: 100%; max-width: none; min-height: 44px; }
  .head-actions .outline-btn { margin-left: auto; }
  .branch-label { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .date-label { font-size: 11px; }
  .product-grid { gap: 10px; }
  .product-card { min-height: 178px; padding: 9px; }
  .fruit-visual { height: 90px; font-size: 51px; }
  .stock-pill { top: 14px; left: 14px; }
  .cart-panel { border-radius: 15px; }
  .kpi-grid { gap: 10px; }
  .dashboard-grid { gap: 10px; }
  .chart-card, .table-card { border-radius: 13px; }
  .payment-content { justify-content: center; }
  .payment-modal, .small-modal { inset: auto 12px; margin: auto; inline-size: calc(100dvw - 24px) !important; max-inline-size: calc(100dvw - 24px) !important; border-radius: 18px; }
  .payment-modal form, .small-modal form { padding: 24px 18px 18px; }
  .modal-close { right: 10px; top: 9px; }
  .payment-summary { margin-top: 11px !important; }
  .payment-methods { grid-template-columns: 1fr; gap: 7px; }
  .payment-methods button { min-height: 48px; padding: 8px 12px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
  .payment-methods button b { font-size: 17px; margin: 0; }
  .cash-input.show { display: grid; gap: 5px; }
  .cash-input input { width: 100%; text-align: left; font-size: 18px; }
  .pay-button { min-height: 48px; }
  .inventory-toolbar { align-items: stretch; flex-wrap: wrap; padding: 14px; }
  .inventory-toolbar > div:first-child { width: 100%; }
  .inventory-search { max-width: none; flex: 1 1 170px; }
  .inventory-filter { flex: 0 0 auto; }
  .inventory-list-head { display: none; }
  .inventory-list { gap: 9px; padding: 10px; background: #f6f8f4; }
  .inventory-row { grid-template-columns: 1fr auto; gap: 8px 12px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; }
  .inventory-product { grid-column: 1 / -1; }
  .inventory-row .stock-status { grid-column: 1; grid-row: 2; }
  .inventory-count { grid-column: 2; grid-row: 2; text-align: right; }
  .stock-adjust-button { grid-column: 1 / -1; min-height: 44px; }
  .inventory-modal { width: calc(100dvw - 24px); }
  .inventory-modal form { padding: 24px 18px 18px; }
}
@media (max-width: 380px) {
  .page-head h1 { font-size: 22px; }
  .branch-label { max-width: 110px; }
  .outline-btn { font-size: 11px; padding: 9px 10px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payment-summary { display: block; }
  .payment-summary strong { display: block; margin-top: 8px; font-size: 28px; }
  .payment-methods button { min-height: 44px; }
  .inventory-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .inventory-kpi { padding: 12px; }
  .stock-modes { grid-template-columns: 1fr; }
  .stock-modes button { min-height: 44px; }
  .stock-modes button b { display: inline; margin-right: 5px; }
}
