/* Duka POS - plain CSS, mobile first. Palette taken from a till receipt:
   paper background, ink text, a teal "cash" accent, amber for pending,
   red reserved for voids/danger only. */

:root {
  --paper: #faf9f6;
  --paper-dim: #f0efe9;
  --ink: #1c2430;
  --ink-soft: #566072;
  --line: #dedad0;
  --teal: #0f6b5c;
  --teal-dark: #0b4f44;
  --amber: #c07f1a;
  --amber-bg: #fbf0dc;
  --red: #b13d31;
  --red-bg: #f8e6e3;
  --white: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.08);
  --sidebar-w: 220px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { line-height: 1.5; }
a { color: var(--teal-dark); }

.app-shell {
  min-height: 100vh;
  padding-bottom: 64px; /* room for mobile tab bar */
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--paper);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; color: var(--white); text-decoration: none; }
.topbar .brand span { color: #7fd6c4; }
.topbar .who { font-size: .85rem; color: #c7d0da; text-align: right; }
.topbar .who a { color: #ffd9a0; }

/* ---------- mobile bottom tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--line);
  z-index: 40;
  overflow-x: auto;
}
.tabbar a {
  flex: 1 0 auto;
  text-align: center;
  padding: 8px 10px;
  font-size: .68rem;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  border-top: 2px solid transparent;
}
.tabbar a.active { color: var(--teal-dark); border-top-color: var(--teal); font-weight: 600; }

/* ---------- desktop sidebar ---------- */
.sidebar { display: none; }

@media (min-width: 900px) {
  .app-shell { padding-bottom: 0; padding-left: var(--sidebar-w); }
  .tabbar { display: none; }
  .sidebar {
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--ink);
    color: #cfd7e0;
    overflow-y: auto;
    z-index: 35;
  }
  .sidebar .brand { display: block; padding: 18px 18px 10px; color: var(--white); font-weight: 700; text-decoration: none; }
  .sidebar .brand span { color: #7fd6c4; }
  .sidebar nav a {
    display: block;
    padding: 9px 18px;
    color: #b7c1cd;
    text-decoration: none;
    font-size: .9rem;
    border-left: 3px solid transparent;
  }
  .sidebar nav a.active, .sidebar nav a:hover { background: rgba(255,255,255,.06); color: var(--white); border-left-color: var(--teal); }
  .sidebar .section-label { padding: 16px 18px 4px; font-size: .68rem; color: #7c8896; }
  .topbar { display: none; }
  .mobile-only-header {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; background: var(--paper); border-bottom: 1px solid var(--line);
  }
}

/* ---------- layout helpers ---------- */
.page { padding: 16px; max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.kpi { display: grid; gap: 4px; }
.kpi .value { font-size: 1.6rem; font-weight: 700; }
.kpi .label { color: var(--ink-soft); font-size: .82rem; }

/* ---------- forms ---------- */
label { display: block; font-size: .82rem; color: var(--ink-soft); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  font-size: 1rem;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.field { margin-bottom: 12px; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input[type=checkbox] { width: auto; }
.checkline label { margin: 0; color: var(--ink); }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
legend { padding: 0 6px; font-weight: 600; font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--teal);
  color: var(--white);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--teal-dark); }
.btn.secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--paper-dim); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #8f2f26; }
.btn.block { width: 100%; }
.btn.small { padding: 6px 10px; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; font-size: .78rem; text-transform: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.table-wrap table { min-width: 560px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 600; }
.badge.ok { background: #e2f3ee; color: var(--teal-dark); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.muted { background: var(--paper-dim); color: var(--ink-soft); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
.flash.success { background: #e2f3ee; color: var(--teal-dark); }
.flash.error { background: var(--red-bg); color: var(--red); }
.flash.info { background: var(--amber-bg); color: var(--amber); }

.muted { color: var(--ink-soft); }
.right { text-align: right; }
.stack { display: grid; gap: 10px; }
.hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }

/* ---------- POS till screen ---------- */
.till {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .till { grid-template-columns: 1fr 380px; align-items: start; }
}
.product-search { margin-bottom: 10px; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.product-tile {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px;
  cursor: pointer;
  text-align: left;
  min-height: 84px;
}
.product-tile:active { background: var(--paper-dim); }
.product-tile .name { font-weight: 600; font-size: .87rem; display: block; margin-bottom: 6px; }
.product-tile .price { color: var(--teal-dark); font-weight: 700; font-size: .92rem; }
.product-tile .stock { display: block; margin-top: 4px; font-size: .72rem; color: var(--ink-soft); }
.product-tile[disabled] { opacity: .45; cursor: not-allowed; }

.cart { position: sticky; top: 12px; }
.cart-lines { max-height: 40vh; overflow-y: auto; margin: 10px 0; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.cart-line .qty-controls { display: flex; align-items: center; gap: 6px; }
.cart-line .qty-controls button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--white); cursor: pointer; }
.cart-totals { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
.cart-totals .row { display: flex; justify-content: space-between; padding: 3px 0; font-size: .9rem; }
.cart-totals .row.total { font-size: 1.15rem; font-weight: 700; padding-top: 6px; }

.pay-methods { display: flex; gap: 8px; margin: 10px 0; }
.pay-methods label {
  flex: 1; text-align: center; padding: 9px 6px; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; font-size: .82rem; color: var(--ink); margin: 0;
}
.pay-methods input { position: absolute; opacity: 0; pointer-events: none; }
.pay-methods label.active { border-color: var(--teal); background: #e2f3ee; color: var(--teal-dark); font-weight: 600; }

/* ---------- receipts (screen preview vs print) ---------- */
.receipt {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .82rem;
  width: 300px;
  max-width: 100%;
  margin: 0 auto;
  background: var(--white);
  border: 1px dashed var(--line);
  padding: 14px;
}
.receipt .center { text-align: center; }
.receipt .line { display: flex; justify-content: space-between; gap: 6px; }
.receipt hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.print-hint { font-size: .8rem; color: var(--ink-soft); margin-top: 8px; }

@media print {
  .no-print { display: none !important; }
  body { background: var(--white); }
  .receipt { border: none; width: 80mm; }
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink) 45%, var(--paper) 45%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.login-card .brand { text-align: center; margin-bottom: 18px; font-weight: 700; font-size: 1.2rem; }
.login-card .brand span { color: var(--teal); }
