:root {
  --r: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .08);
}

* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif
}

body {
  margin: 0;
  background: #f5f6fa;
  color: #111
}

a {
  text-decoration: none;
  color: inherit
}

.app {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 16px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
  display: flex;
  justify-content: space-between;
  align-items: center
}

.brand {
  font-weight: 900;
  letter-spacing: .6px
}

.user {
  font-size: 18px;
  opacity: .7
}

.content {
  padding: 14px 14px 90px
}

.card {
  background: #fff;
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px
}

.row {
  display: flex;
  gap: 10px;
  align-items: center
}

.row>* {
  flex: 1
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  background: #111;
  color: #fff;
  font-weight: 800;
  cursor: pointer
}

.btn.ghost {
  background: #fff;
  color: #111;
  border: 1px solid rgba(0, 0, 0, .12)
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, .12);
  outline: none
}

.small {
  font-size: 15px;
  opacity: .7
}

.divider {
  height: 1px;
  background: rgba(0, 0, 0, .08);
  margin: 12px 0
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 14px;
  z-index: 20;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 999px;
  padding: 10px 15px;
  display: flex;
  gap: 20px;
  box-shadow: var(--shadow)
}

.bottom-nav a {
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 18px
}

.bottom-nav a.active {
  background: #111;
  color: #fff
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 92px;
  z-index: 50;
  background: rgba(17, 17, 17, .92);
  color: #fff;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 18px;
  max-width: 90vw
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  z-index: 60
}

.modal {
  margin-bottom: 90px; /* เผื่อ tabbar */
  width: min(580px, 100%);
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 14px
}

.modal h3 {
  margin: 6px 0 12px
}

.tag {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, .12);
  font-size: 15px;
  font-weight: 800
}

.tag.on {
  background: #111;
  color: #fff;
  border-color: #111
}

.toast {
  padding: 12px 14px;
  border-radius: 14px;
  margin: 12px 0;
  background: rgba(255, 0, 0, 0.08);
  border: 1px solid rgba(255, 0, 0, 0.18);
  font-size: 14px;
}

/* ===== Bill Status Colors ===== */

.bill-card {
  border-left: 6px solid transparent;
}

.bill-paid {
  border-left-color: #2ecc71;
  background: #ecfdf3;
}

.bill-partial {
  border-left-color: #f1c40f;
  background: #fffbea;
}

.bill-unpaid {
  border-left-color: #e74c3c;
  background: #fff1f0;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-paid {
  background: #2ecc71;
  color: #fff;
}

.badge-partial {
  background: #f1c40f;
  color: #000;
}

.badge-unpaid {
  background: #e74c3c;
  color: #fff;
}

/* ===== Filters ===== */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid rgba(0, 0, 0, .12);
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
}

.chip.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.search {
  margin-top: 10px;
}

/* ===== Sale Layout 30:70 ===== */

.sale-layout {
  display: grid;
  grid-template-columns: 30% 70%;
  gap: 20px;
  height: calc(100vh - 120px);
}

.sale-left {
  overflow: auto;
}

.sale-right {
  overflow: auto;
}

/* iPad breakpoint */
@media (max-width: 1024px) {
  .sale-layout {
    grid-template-columns: 35% 65%;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .sale-layout {
    display: block;
  }

  .sale-left,
  .sale-right {
    display: none;
  }

  .sale-left.active,
  .sale-right.active {
    display: block;
  }
}

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 260px;
  margin: 0 auto;
}

.pin-grid button {
  color: black;
  height: 60px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .08);
  background: white;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}

.pin-grid button:active {
  transform: scale(.95);
  background: #f3f3f3;
}

.pin-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 260px;
  margin: 0 auto;
}

/* กัน double tap zoom / select */
html,
body {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

button,
a,
.btn,
.chip,
.tag {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== iOS Floating Tab Bar ===== */
.ios-tabbar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;

  width: min(520px, calc(100% - 28px));
  padding: 10px;
  border-radius: 999px;

  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  border: 1px solid rgba(0, 0, 0, .06);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .12);
  z-index: 999;
}

/* กันเนื้อหาถูก navbar บัง */
.page-pad-bottom {
  padding-bottom: 92px;
}

/* iOS Floating Tab Bar */
.ios-tabbar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;

  width: min(520px, calc(100% - 28px));
  padding: 10px;
  border-radius: 999px;

  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  border: 1px solid rgba(0, 0, 0, .06);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .12);
  z-index: 999;
}

.ios-tabbar .tab {
  text-decoration: none;
  color: rgba(0, 0, 0, .60);

  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;

  font-weight: 800;
  font-size: 12px;

  border-radius: 999px;
  transition: transform .12s ease, background .12s ease, color .12s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.ios-tabbar .tab .ico {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

.ios-tabbar .tab .ico svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  opacity: .9;
}

.ios-tabbar .tab .lbl {
  line-height: 1;
}

.ios-tabbar .tab.active {
  background: #111;
  color: #fff;
  box-shadow: 0 10px 18px rgba(0, 0, 0, .18);
}

