/* =============================================================
   Rubber Yard — Mobile-first PWA styling
   ธีม: น้ำตาลพาสเทล (mocha-caramel-cream)
   ขนาดตัวอักษรใหญ่ (เพราะคุณแม่อายุเยอะ)
   ============================================================= */
:root {
  --cream:        #FBF7F2;
  --cream-soft:   #F5EFE6;
  --caramel:      #D4A574;
  --caramel-dark: #B8895E;
  --mocha:        #8B6F47;
  --mocha-dark:   #5C4630;
  --leaf:         #6B8E50;
  --leaf-soft:    #C9D7B3;
  --red:          #C0533B;
  --red-soft:     #F5D6CC;
  --gold:         #D4B65C;
  --shadow:       0 2px 6px rgba(92, 70, 48, .12);
  --shadow-lg:    0 4px 16px rgba(92, 70, 48, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Sarabun", "Segoe UI", Tahoma, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  color: var(--mocha-dark);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

/* ====== App Bar ====== */
.appbar {
  background: linear-gradient(135deg, var(--mocha) 0%, var(--caramel-dark) 100%);
  color: white;
  padding: 12px 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.appbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.appbar h1 { font-size: 22px; margin: 0; font-weight: 700; }
.home-btn {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: white;
  font-family: inherit; cursor: pointer; padding: 4px 8px 4px 0;
  border-radius: 10px;
}
.home-btn:active { background: rgba(255,255,255,.12); }
.app-logo { display: inline-flex; width: 38px; height: 38px;
  background: white; border-radius: 50%; padding: 2px;
  flex-shrink: 0; }
.app-logo svg { width: 100%; height: 100%; }
.home-btn .brand-name { font-size: 19px; font-weight: 800; letter-spacing: .3px; }
.appbar-tools { display: flex; gap: 8px; }

/* settings view */
.settings-section { padding: 6px 0; }
.settings-section h3 { font-size: 18px; color: var(--mocha-dark); margin: 8px 0 4px; }
.settings-help { font-size: 14px; color: #777; margin-bottom: 14px; }
.logo-cat-title {
  font-size: 15px; color: var(--caramel-dark);
  margin: 18px 0 8px; padding: 4px 8px;
  background: var(--cream-soft); border-radius: 8px;
  display: inline-block;
}
.logo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 6px;
}
.logo-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; background: white; border: 2px solid var(--cream-soft);
  border-radius: 14px; cursor: pointer; font-family: inherit;
}
.logo-card:active { transform: scale(.97); }
.logo-card.selected {
  border-color: var(--leaf);
  background: var(--cream-soft);
  box-shadow: 0 0 0 2px var(--leaf) inset;
}
.logo-card .logo-svg { width: 64px; height: 64px; }
.logo-card .logo-svg svg { width: 100%; height: 100%; }
.logo-card .logo-name { font-size: 12px; color: var(--mocha-dark); text-align: center; }
@media (min-width: 480px) {
  .logo-grid { grid-template-columns: repeat(4, 1fr); }
}
.icon-btn {
  background: rgba(255,255,255,.18); border: 0; color: white;
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 24px; cursor: pointer;
}
.auction-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,.2);
  font-size: 17px;
}
.auction-info { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.auction-label { opacity: .8; font-size: 15px; }
.auction-no { font-size: 22px; font-weight: 800; }
.auction-price { background: rgba(255,255,255,.22); padding: 4px 10px; border-radius: 14px; font-size: 16px; }
.text-btn {
  background: transparent; color: white; border: 1px solid rgba(255,255,255,.4);
  padding: 6px 12px; border-radius: 12px; font-size: 15px; cursor: pointer;
}

/* ====== Views ====== */
main { padding: 16px 16px 100px; max-width: 720px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ====== KPIs ====== */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.kpi {
  background: white; border-radius: 14px; padding: 12px 8px;
  text-align: center; box-shadow: var(--shadow);
}
.kpi-label { font-size: 13px; color: var(--caramel-dark); margin-bottom: 4px; }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--mocha-dark); }
.kpi-value small { font-size: 13px; font-weight: 500; opacity: .7; }

/* ====== Section Title ====== */
.section-title {
  font-size: 18px; margin: 24px 0 10px;
  color: var(--mocha); font-weight: 700;
  border-left: 4px solid var(--caramel); padding-left: 10px;
}

/* ====== Truck Cards ====== */
.truck-cards { display: grid; gap: 10px; }
.truck-card {
  background: var(--leaf-soft); border-left: 6px solid var(--leaf);
  padding: 12px 14px; border-radius: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 6px;
}
.truck-card .plate { font-size: 20px; font-weight: 800; }
.truck-card .count { font-size: 15px; opacity: .8; }
.truck-card .weight { font-size: 22px; font-weight: 800; color: var(--mocha-dark); }
.truck-card .net { font-size: 14px; color: var(--leaf); }

/* ====== Entry Cards ====== */
.entry-cards { display: grid; gap: 8px; }
.entry-card {
  background: white; border-radius: 12px; padding: 12px 14px;
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px;
  cursor: pointer;
  transition: transform .12s;
}
.entry-card:active { transform: scale(.98); }
.entry-card.completed { opacity: .65; }
.entry-card .seq { font-size: 12px; color: var(--caramel-dark); }
.entry-card .name { font-size: 18px; font-weight: 700; color: var(--mocha-dark); }
.entry-card .meta { font-size: 14px; color: #6b6258; }
.entry-card .weight { font-size: 20px; font-weight: 800; color: var(--mocha); text-align: right; }
.entry-card .truck-tag {
  display: inline-block; background: var(--leaf-soft); color: var(--leaf);
  padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600;
}
.empty { text-align: center; color: #aaa; padding: 30px 10px; font-size: 16px; }

/* ====== Form ====== */
form { display: grid; gap: 14px; padding: 8px 0 20px; }
label { display: grid; gap: 6px; }
label > span {
  font-size: 16px; font-weight: 600; color: var(--mocha);
}
label em { color: var(--red); font-style: normal; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  font-family: inherit; font-size: 20px;
  padding: 14px 14px; border: 2px solid var(--cream-soft);
  border-radius: 12px; background: white;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--caramel); }

/* ====== Current truck picker (Dashboard) ====== */
.current-truck {
  display: flex; align-items: center; gap: 8px;
  background: var(--cream-soft);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-left: 5px solid var(--caramel);
}
.current-truck label {
  display: inline; font-size: 16px; font-weight: 600;
  color: var(--mocha-dark); white-space: nowrap;
}
.current-truck select {
  flex: 1; min-width: 0;
  font-size: 18px;
  padding: 10px 12px;
  border: 2px solid white;
  border-radius: 10px; background: white;
  font-family: inherit;
}
.btn-add-truck {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border: none; background: var(--caramel); color: white;
  border-radius: 10px; font-size: 24px; font-weight: 700;
  cursor: pointer; line-height: 1;
}
.btn-add-truck:active { background: var(--caramel-dark); }

/* ====== Supplier autocomplete ====== */
.suggest-wrap { position: relative; }
.suggest-box {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 50;
  background: white;
  border: 2px solid var(--caramel);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  max-height: 320px; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 4px;
}
.suggest-box[hidden] { display: none; }
.suggest-item {
  display: block; width: 100%;
  text-align: left;
  background: white; border: none;
  padding: 14px 16px;
  font-size: 19px; font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  color: var(--mocha-dark);
  border-bottom: 1px solid var(--cream-soft);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:active,
.suggest-item:hover { background: var(--cream-soft); }
.suggest-item small {
  display: block; font-size: 14px; color: var(--caramel-dark); margin-top: 2px;
}
.advanced summary {
  font-size: 15px; color: var(--mocha); cursor: pointer;
  padding: 8px 0; user-select: none;
}
.advanced[open] { background: var(--cream-soft); padding: 8px 12px; border-radius: 12px; }

/* ====== Calc Panel ====== */
.calc-panel {
  background: var(--cream-soft); border-radius: 14px; padding: 14px 18px;
  display: grid; gap: 8px;
}
.calc-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; }
.calc-row span { color: var(--caramel-dark); }
.calc-row strong { font-size: 22px; }
.calc-row.total {
  border-top: 2px solid var(--caramel); padding-top: 10px; margin-top: 4px;
}
.calc-row.total span { color: var(--mocha-dark); font-weight: 700; font-size: 19px; }
.calc-row.total strong { font-size: 30px; color: var(--leaf); }

/* ====== Weight pair (ชั่ง 2 ครั้ง) ====== */
.weight-pair {
  background: var(--cream-soft); padding: 14px;
  border-radius: 14px; display: grid; gap: 12px;
  border-left: 5px solid var(--leaf);
}
.weight-pair label { gap: 4px; }
.weight-pair label > span { font-size: 15px; }
.weight-pair input { font-size: 22px; font-weight: 700; }
.weight-in-block { display: grid; gap: 6px; }
.weight-label { font-size: 15px; font-weight: 600; color: var(--mocha); }
.weight-label em { color: var(--red); font-style: normal; }
#weightInList { display: grid; gap: 6px; }
.weight-row { display: flex; gap: 6px; align-items: center; }
.weight-row input.weight-part {
  flex: 1; min-width: 0; font-size: 22px; font-weight: 700;
  padding: 12px 14px; border: 2px solid var(--cream-soft);
  border-radius: 12px; background: white; font-family: inherit;
}
.weight-row input.weight-part:focus { outline: none; border-color: var(--caramel); }
.weight-row-del {
  flex-shrink: 0; width: 44px; height: 44px;
  background: var(--red-soft); color: var(--red);
  border: 0; border-radius: 10px;
  font-size: 18px; font-weight: 700; cursor: pointer;
}
.weight-row-del:disabled { opacity: .25; cursor: not-allowed; }
.weight-row-del:not(:disabled):active { background: var(--red); color: white; }
.btn-add-weight {
  background: var(--leaf); color: white; border: 0;
  border-radius: 10px; padding: 10px 14px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: inherit;
  align-self: flex-start;
}
.btn-add-weight:active { background: var(--leaf-dark, #557A40); }
.weight-sum {
  background: white; padding: 8px 12px; border-radius: 8px;
  font-size: 15px; color: var(--mocha-dark);
  display: flex; justify-content: space-between; align-items: baseline;
  border: 1.5px dashed var(--caramel);
}
.weight-sum strong { font-size: 17px; color: var(--leaf-dark, #557A40); }

/* ====== Expenses ====== */
.section-title .exp-total {
  float: right; font-size: 17px; font-weight: 800;
  color: var(--red, #c0533b);
  background: #fff3d6; padding: 4px 10px; border-radius: 8px;
}
.expense-form {
  display: grid; grid-template-columns: 1fr 100px 70px; gap: 6px;
  margin-bottom: 8px;
  background: var(--cream-soft); padding: 8px; border-radius: 12px;
  border-left: 4px solid var(--gold, #D4A857);
}
.expense-form input {
  border: 1.5px solid white; border-radius: 8px;
  padding: 10px 12px; font-size: 16px; font-family: inherit;
  background: white; min-width: 0;
}
.expense-form input:focus { outline: none; border-color: var(--caramel); }
.btn-add-exp {
  background: var(--gold, #D4A857); color: var(--mocha-dark);
  border: 0; border-radius: 8px; font: 700 16px inherit; cursor: pointer;
  font-family: inherit;
}
.btn-add-exp:active { background: #C29845; }
.expense-list { display: grid; gap: 4px; margin-bottom: 14px; }
.exp-row {
  display: flex; align-items: center; gap: 8px;
  background: white; padding: 8px 12px; border-radius: 8px;
  border-left: 3px solid var(--caramel);
}
.exp-desc { flex: 1; min-width: 0; font-size: 15px; color: var(--mocha-dark); }
.exp-amt { font-weight: 800; font-size: 15px; color: var(--mocha-dark); white-space: nowrap; }
.exp-del {
  width: 30px; height: 30px;
  background: var(--red-soft); color: var(--red);
  border: 0; border-radius: 6px; cursor: pointer;
  font-size: 18px; font-weight: 700; line-height: 1;
}
.exp-del:active { background: var(--red); color: white; }
.exp-empty { padding: 16px 10px; font-size: 14px; }

/* ====== Chat widget + TODO ====== */
.chat-fab {
  position: fixed; bottom: 88px; right: 16px; z-index: 90;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--leaf, #6B8E50); color: white;
  border: 0; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(107,142,80,.4);
}
.chat-fab:active { transform: scale(.95); }
.chat-panel {
  position: fixed; bottom: 12px; right: 12px; left: 12px; z-index: 100;
  max-width: 420px; margin-left: auto;
  background: white; border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
  height: 75vh; max-height: 600px;
  overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--mocha-dark); color: white;
}
.chat-title strong { font-size: 16px; display: block; }
.chat-title small { font-size: 12px; opacity: .8; }
.chat-close {
  background: rgba(255,255,255,.2); border: 0; color: white;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 22px; cursor: pointer; line-height: 1;
}
.chat-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px; background: #faf9f5;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-empty { text-align: center; color: #aaa; padding: 30px 10px; font-size: 14px; }
.chat-msg {
  background: white; padding: 8px 12px; border-radius: 10px;
  border-left: 3px solid #ddd;
  font-size: 14px;
}
.chat-msg.user { border-left-color: var(--leaf, #6B8E50); }
.chat-msg.system { background: var(--cream-soft); border-left-color: var(--gold, #D4A857); }
.chat-msg-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px; font-size: 11px;
}
.chat-tag {
  padding: 2px 7px; border-radius: 6px; font-weight: 700;
}
.chat-time { color: #999; }
.chat-todo { color: var(--leaf-dark, #557A40); font-weight: 700; margin-left: auto; }
.chat-msg-body { color: var(--mocha-dark); white-space: pre-wrap; word-break: break-word; }
.chat-form {
  display: flex; gap: 8px; padding: 10px;
  background: white; border-top: 1px solid #eee;
}
.chat-form input {
  flex: 1; min-width: 0;
  padding: 10px 14px; font-size: 15px; font-family: inherit;
  border: 1.5px solid #ddd; border-radius: 22px;
}
.chat-form input:focus { outline: none; border-color: var(--leaf, #6B8E50); }
.chat-send {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--leaf, #6B8E50); color: white;
  border: 0; font-size: 18px; cursor: pointer;
}
.chat-send:active { background: var(--leaf-dark, #557A40); }

/* TODO view */
.todo-help { font-size: 13px; color: #888; margin: 4px 0 14px; }
.todo-section {
  font-size: 15px; font-weight: 700; color: var(--mocha-dark);
  margin: 16px 0 8px; padding: 4px 10px;
  background: var(--cream-soft); border-radius: 6px;
}
.todo-section.done { background: #e8f0d8; color: var(--leaf-dark, #557A40); }
.todo-card {
  background: white; padding: 10px 12px; border-radius: 10px;
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border-left: 4px solid #ccc;
}
.todo-card.status-open { border-left-color: var(--gold, #D4A857); }
.todo-card.status-in_progress { border-left-color: #4a90e2; }
.todo-card.status-done { border-left-color: var(--leaf, #6B8E50); opacity: .85; }
.todo-card.status-wont_do { border-left-color: #888; opacity: .6; }
.todo-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.todo-tag {
  padding: 2px 7px; border-radius: 6px; font-size: 12px; font-weight: 700;
}
.todo-pri {
  background: var(--mocha-dark); color: white;
  padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 800;
}
.todo-del {
  margin-left: auto;
  width: 24px; height: 24px; border-radius: 5px;
  background: var(--red-soft); color: var(--red);
  border: 0; font-size: 16px; cursor: pointer; line-height: 1;
}
.todo-title { font-size: 15px; color: var(--mocha-dark); margin: 4px 0; line-height: 1.3; }
.todo-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #888;
}
.todo-status {
  border: 1px solid #ddd; border-radius: 6px;
  padding: 4px 8px; font-size: 13px; font-family: inherit;
  background: white;
}
.btn-export-claude {
  display: block; width: 100%; margin-top: 14px;
  background: var(--mocha-dark); color: white;
  border: 0; border-radius: 10px; padding: 12px;
  font: 700 15px inherit; font-family: inherit; cursor: pointer;
}
.btn-export-claude:active { transform: scale(.98); }

/* ====== Sale loads (ขายให้โรงงาน) ====== */
.section-title .sale-total {
  float: right; font-size: 17px; font-weight: 800;
  color: var(--leaf-dark, #557A40);
  background: #e8f0d8; padding: 4px 10px; border-radius: 8px;
}
.sale-list { display: grid; gap: 8px; margin-bottom: 8px; }
.sale-row {
  background: white; padding: 12px 14px; border-radius: 12px;
  border-left: 4px solid var(--leaf, #6B8E50);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.sale-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.sale-head strong { font-size: 16px; color: var(--mocha-dark); flex: 1; }
.sale-date { font-size: 13px; color: #888; }
.sale-del {
  width: 30px; height: 30px;
  background: var(--red-soft); color: var(--red);
  border: 0; border-radius: 6px; cursor: pointer;
  font-size: 18px; font-weight: 700; line-height: 1;
}
.sale-del:active { background: var(--red); color: white; }
.sale-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px;
  font-size: 14px; padding: 4px 0;
}
.sale-body strong { color: var(--mocha-dark); }
.sale-foot {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1.2px dashed #e7e0d0; padding-top: 8px; margin-top: 6px;
  font-size: 16px;
}
.sale-foot strong { font-size: 19px; font-weight: 800; }
.sale-foot strong.pos { color: var(--leaf-dark, #557A40); }
.btn-add-sale {
  display: block; width: 100%; margin-bottom: 14px;
  background: var(--leaf, #6B8E50); color: white;
  border: 0; border-radius: 12px; padding: 14px;
  font: 700 17px inherit; font-family: inherit; cursor: pointer;
}
.btn-add-sale:active { background: var(--leaf-dark, #557A40); }
.sale-calc {
  margin: 10px 0; background: var(--cream-soft);
  padding: 10px 14px; border-radius: 10px;
  display: grid; gap: 4px;
}
.sc-row { display: flex; justify-content: space-between; font-size: 15px; }
.sc-row strong { font-weight: 700; color: var(--mocha-dark); }
.sc-row.total { border-top: 2px solid var(--leaf-dark, #557A40); padding-top: 6px; margin-top: 4px; }
.sc-row.total strong { font-size: 19px; color: var(--leaf-dark, #557A40); font-weight: 900; }

/* ====== Reports view ====== */
#viewReports h2 { font-size: 22px; margin: 6px 0 12px; color: var(--mocha-dark); }
.report-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--cream-soft); padding: 4px; border-radius: 12px;
  overflow-x: auto;
}
.rpt-tab {
  flex: 1; min-width: max-content;
  background: transparent; color: var(--mocha-dark);
  border: 0; padding: 10px 12px; font: 700 15px inherit;
  border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.rpt-tab.active { background: white; color: var(--leaf-dark, #557A40); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.rpt-pane { display: none; }
.rpt-pane.active { display: block; }

/* hero card (ครั้งที่ + วันที่) */
.rpt-hero {
  background: linear-gradient(135deg, var(--leaf, #6B8E50) 0%, var(--leaf-dark, #557A40) 100%);
  color: white; padding: 18px 22px; border-radius: 18px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(85,122,64,.25);
}
.rpt-hero-no { font-size: 16px; opacity: .9; }
.rpt-hero-no strong { font-size: 32px; font-weight: 900; letter-spacing: 1px; margin-left: 6px; }
.rpt-hero-date { font-size: 16px; opacity: .85; margin-top: 2px; }
.rpt-hero-price { font-size: 14px; opacity: .8; margin-top: 6px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.2); }

/* 2-column big stats */
.rpt-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.rpt-stat {
  background: white; padding: 16px; border-radius: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
  border-left: 5px solid #ccc;
}
.rpt-stat.green { border-left-color: var(--leaf, #6B8E50); }
.rpt-stat.gold  { border-left-color: var(--gold, #D4A857); }
.rpt-stat.red   { border-left-color: var(--red, #c0533b); }
.rpt-stat-label { font-size: 13px; color: #777; font-weight: 600; }
.rpt-stat-value { font-size: 26px; font-weight: 900; color: var(--mocha-dark); margin-top: 4px; line-height: 1.1; }
.rpt-stat-value small { font-size: 16px; opacity: .7; font-weight: 600; }
.rpt-stat-sub   { font-size: 13px; color: #888; margin-top: 4px; }

/* 3-column mini stats */
.rpt-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.rpt-mini {
  background: var(--cream-soft); padding: 12px 8px; border-radius: 12px;
  text-align: center;
}
.rpt-mini-label { font-size: 12px; color: #777; font-weight: 600; }
.rpt-mini-value { font-size: 22px; font-weight: 800; color: var(--mocha-dark); margin-top: 2px; }
.rpt-mini-value small { font-size: 12px; opacity: .7; font-weight: 600; }

/* P&L block */
.rpt-pl {
  background: white; padding: 14px 16px; border-radius: 14px;
  margin-bottom: 14px; border: 1.5px solid var(--cream-soft);
}
.rpt-section-h { font-size: 17px; font-weight: 800; color: var(--mocha-dark); margin: 16px 0 8px; }
.rpt-pl .rpt-section-h { margin-top: 0; }
.rpt-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; font-size: 15px; color: var(--mocha-dark);
}
.rpt-line + .rpt-line { border-top: 1px dashed #e7e0d0; }
.rpt-line strong { font-size: 17px; font-weight: 800; }
.rpt-line strong.pos { color: var(--leaf-dark, #557A40); }
.rpt-line strong.neg { color: var(--red, #c0533b); }
.rpt-line.total {
  margin-top: 6px; padding-top: 12px;
  border-top: 2px solid var(--mocha-dark) !important;
  font-weight: 700;
}
.rpt-note { font-size: 12px; color: #999; margin-top: 8px; font-style: italic; }

/* status chips */
.rpt-status-row { display: flex; gap: 8px; margin: 8px 0 16px; flex-wrap: wrap; }
.rpt-chip {
  font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 14px;
}
.rpt-chip.pending { background: #fff3d6; color: #6E5635; }
.rpt-chip.paid    { background: #e8f0d8; color: var(--leaf-dark, #557A40); }
.rpt-chip.voided  { background: #eee; color: #888; }

/* generic row list */
.rpt-rows { display: grid; gap: 8px; }
.rpt-row {
  background: white; padding: 12px 14px; border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  cursor: pointer;
  border-left: 4px solid var(--cream-soft);
}
.rpt-row:active { transform: scale(.99); }
.rpt-row.supplier { cursor: default; }
.rpt-row-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.rpt-row-head strong { font-size: 17px; color: var(--mocha-dark); }
.rpt-row-date { font-size: 13px; color: #888; }
.rpt-rank {
  background: var(--gold, #D4A857); color: var(--mocha-dark);
  padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 800;
}
.rpt-row-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px;
  font-size: 14px;
}
.rpt-k { color: #888; font-size: 12px; margin-right: 4px; }
.rpt-row-body strong { font-size: 15px; color: var(--mocha-dark); }
.rpt-row-body strong.pos { color: var(--leaf-dark, #557A40); }
.rpt-row-body strong.neg { color: var(--red, #c0533b); }

/* expenses grouped */
.rpt-exp-group {
  background: white; padding: 10px 12px; border-radius: 12px;
  margin-bottom: 8px; border-left: 4px solid var(--gold, #D4A857);
}
.rpt-exp-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 8px; margin-bottom: 6px;
  border-bottom: 1.2px dashed #e7e0d0;
}
.rpt-exp-head strong { font-size: 16px; color: var(--mocha-dark); }
.rpt-exp-total { font-weight: 800; color: var(--red, #c0533b); }
.rpt-exp-item {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 14px;
}
.rpt-exp-desc { color: var(--mocha-dark); }
.rpt-exp-amt  { font-weight: 700; color: var(--mocha-dark); }

/* ====== Kanban lanes (entry list grouped by status) ====== */
.kanban { display: grid; gap: 16px; }
.kanban-lane {
  background: #fafaf6;
  border-radius: 14px;
  padding: 4px;
  border: 1.5px solid transparent;
}
.kanban-lane.unpaid { background: #fff8e8; border-color: #f1d990; }
.kanban-lane.paid   { background: #f1f6e9; border-color: #b8d098; }
.kanban-lane.voided { background: #f3f3f3; border-color: #ddd; opacity: .9; }

.lane-title {
  margin: 0; padding: 10px 14px;
  font-size: 16px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  flex-wrap: wrap;
}
.kanban-lane.unpaid .lane-title { color: #6E5635; }
.kanban-lane.paid   .lane-title { color: var(--leaf-dark, #557A40); }
.kanban-lane.voided .lane-title { color: #888; }

.lane-label { white-space: nowrap; }
.lane-stats {
  font-size: 13px; font-weight: 700; opacity: .85;
  background: rgba(255,255,255,.7);
  padding: 2px 8px; border-radius: 6px;
}

.lane-cards { display: grid; gap: 6px; padding: 4px; }
.lane-cards:empty { display: none; }

.entry-card.completed { opacity: .92; }
.entry-card.voided { opacity: .55; }
.weight-net {
  background: white; padding: 10px 14px; border-radius: 10px;
  font-size: 17px; color: var(--mocha-dark);
  display: flex; justify-content: space-between; align-items: baseline;
}
.weight-net strong { font-size: 26px; color: var(--leaf); font-weight: 800; }

/* ====== Photo section ====== */
.photo-section {
  background: var(--cream-soft); padding: 12px 14px;
  border-radius: 14px; display: grid; gap: 10px;
}
.photo-section-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 16px; color: var(--mocha); font-weight: 600;
}
.photo-section-head small { font-weight: 400; color: var(--caramel-dark); }
.btn-photo {
  background: var(--caramel); color: white;
  padding: 10px 16px; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-weight: 600; font-family: inherit;
}
.btn-photo:active { transform: scale(.96); }
.photo-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  min-height: 60px;
}
.photo-grid:empty::before {
  content: 'ยังไม่มีรูป — แตะ "ถ่ายรูป/เลือก" ด้านบนเพื่อเพิ่ม';
  grid-column: 1 / -1; text-align: center; padding: 18px 10px;
  color: #aaa; font-size: 13px;
}
.photo-cell {
  position: relative; aspect-ratio: 1;
  background: white; border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow);
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.photo-cell .del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(192, 83, 59, .9); color: white;
  width: 24px; height: 24px; border: 0; border-radius: 50%;
  font-size: 14px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-cell.uploading { opacity: .5; }
.photo-cell.uploading::after {
  content: '⏳'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}

/* photo viewer overlay */
.photo-viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.9);
  display: none; align-items: center; justify-content: center;
  z-index: 300; padding: 20px;
}
.photo-viewer.show { display: flex; }
.photo-viewer img { max-width: 100%; max-height: 100%; }
.photo-viewer .close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.2); color: white;
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  font-size: 22px; cursor: pointer;
}

/* ====== Entry card pending state ====== */
.entry-card.draft { border-left: 5px solid var(--gold); background: #fffaef; }
.entry-card.draft .name { color: var(--caramel-dark); }
.entry-card .pending-badge {
  background: var(--gold); color: var(--mocha-dark);
  padding: 2px 8px; border-radius: 8px; font-size: 11px;
  font-weight: 700; margin-left: 6px;
}

/* ====== Buttons ====== */
.actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin-top: 8px; }
.btn-draft {
  background: var(--gold); color: var(--mocha-dark);
  font-size: 16px; font-weight: 700; padding: 16px;
  border-radius: 14px; border: 0; cursor: pointer; font-family: inherit;
}
.btn-primary, .btn-secondary, .btn-danger {
  font-size: 18px; font-weight: 700; padding: 16px;
  border-radius: 14px; border: 0; cursor: pointer;
  font-family: inherit;
}
.btn-danger {
  background: var(--red); color: white;
}
.btn-danger:active { transform: scale(.98); }
.btn-unpay {
  display: block; width: 100%; margin-top: 10px;
  background: var(--gold, #D4A857); color: var(--mocha-dark);
  font: 700 17px inherit; padding: 14px;
  border: 2px dashed var(--caramel-dark);
  border-radius: 14px; cursor: pointer;
  font-family: inherit;
}
.btn-unpay[hidden] { display: none; }
.btn-unpay:active { transform: scale(.98); background: #C29845; }
.receipt-actions {
  display: grid; grid-template-columns: 2fr 1fr; gap: 8px;
  margin-top: 10px;
}
.btn-print-receipt, .btn-preview-receipt {
  font: 700 18px inherit; padding: 16px;
  border: 0; border-radius: 14px; cursor: pointer;
  font-family: inherit;
}
.btn-print-receipt {
  background: var(--mocha); color: white;
}
.btn-preview-receipt {
  background: var(--cream-soft); color: var(--mocha-dark);
  font-weight: 600; font-size: 16px;
  border: 2px solid var(--caramel);
}
.btn-print-receipt:active,
.btn-preview-receipt:active { transform: scale(.98); }
.share-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 8px;
}
.btn-share-line {
  background: #06C755; color: white;
  font: 700 17px inherit; padding: 14px 8px;
  border: 0; border-radius: 14px; cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 4px rgba(6,199,85,.25);
}
.btn-share-line.member {
  background: var(--caramel); color: white;
  box-shadow: 0 2px 4px rgba(139,111,71,.25);
}
.btn-share-line:active { transform: scale(.98); background: #05a847; }
.btn-share-line.member:active { background: var(--caramel-dark); }
.btn-primary {
  background: linear-gradient(135deg, var(--leaf) 0%, #557A40 100%);
  color: white;
  box-shadow: var(--shadow-lg);
}
.btn-primary:active { transform: scale(.98); }
.btn-primary.big { width: 100%; padding: 18px; font-size: 20px; margin-top: 16px; }
.btn-secondary {
  background: var(--red-soft); color: var(--red);
}
.back-btn {
  background: transparent; border: 0; color: var(--mocha);
  font-size: 18px; padding: 8px 4px; cursor: pointer; font-weight: 600;
  margin-bottom: 8px;
}

/* ====== Seq Badge ====== */
.seq-badge {
  background: var(--gold); color: var(--mocha-dark);
  padding: 10px 14px; border-radius: 12px; margin-bottom: 16px;
  font-size: 15px;
  display: flex; justify-content: space-between; align-items: center;
}
.seq-badge strong { font-size: 18px; }

/* ====== Save indicator ====== */
.save-indicator { font-size: 13px; padding: 4px 8px; border-radius: 10px; }
.save-indicator.saving { background: rgba(255,255,255,.4); }
.save-indicator.saved { background: var(--leaf); color: white; }
.save-indicator.error { background: var(--red); color: white; }

/* ====== FAB ====== */
.fab {
  position: fixed; bottom: 20px; right: 16px;
  background: linear-gradient(135deg, var(--leaf) 0%, #557A40 100%);
  color: white; border: 0; border-radius: 100px;
  padding: 16px 22px; font-size: 18px; font-weight: 800;
  box-shadow: var(--shadow-lg);
  cursor: pointer; z-index: 50;
}
.fab:active { transform: scale(.95); }

/* ====== Auction picker ====== */
.auction-cards { display: grid; gap: 10px; }
.auction-cards .auction-row {
  background: white; padding: 14px; border-radius: 12px;
  box-shadow: var(--shadow); cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.auction-cards .auction-row.current { border: 2px solid var(--leaf); background: var(--leaf-soft); }
.auction-cards strong { font-size: 22px; }
.auction-cards .meta { font-size: 14px; color: #6b6258; }
.badge-open { background: var(--leaf); color: white; padding: 2px 8px; border-radius: 8px; font-size: 12px; }
.badge-closed { background: #ccc; color: #555; padding: 2px 8px; border-radius: 8px; font-size: 12px; }
.auction-cards .auction-row { gap: 10px; }
.auction-row-main { flex: 1; min-width: 0; }
.btn-trash {
  flex-shrink: 0;
  width: 40px; height: 40px;
  background: var(--red-soft); color: var(--red);
  border: 0; border-radius: 10px;
  font-size: 20px; cursor: pointer;
}
.btn-trash:active { background: var(--red); color: white; }

/* ====== Dialog ====== */
dialog {
  border: 0; border-radius: 16px; padding: 20px;
  background: var(--cream); box-shadow: var(--shadow-lg);
  max-width: 90vw; width: 360px;
}
dialog::backdrop { background: rgba(92, 70, 48, .5); }
dialog h3 { margin: 0 0 16px; color: var(--mocha); }
dialog form { gap: 12px; }
dialog menu { display: flex; justify-content: flex-end; gap: 10px; margin: 16px 0 0; padding: 0; }
dialog menu button {
  font-size: 16px; padding: 12px 18px; border-radius: 12px;
  background: white; color: var(--mocha-dark); border: 0; cursor: pointer; font-family: inherit;
}
dialog menu button.btn-primary { background: var(--leaf); color: white; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--mocha-dark); color: white;
  padding: 12px 20px; border-radius: 14px;
  box-shadow: var(--shadow-lg); font-size: 16px;
  opacity: 0; pointer-events: none; transition: opacity .3s;
  z-index: 200;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }
.toast.success { background: var(--leaf); }

/* ====== Responsive (tablet+) ====== */
@media (min-width: 768px) {
  body { font-size: 19px; }
  .kpi-value { font-size: 28px; }
  main { padding: 24px 32px 120px; }
  .truck-cards, .entry-cards { grid-template-columns: 1fr 1fr; }
}

/* ====== Print (สำหรับใบเสร็จ ทำใน V1.1) ====== */
@media print {
  .appbar, .fab, .back-btn, .actions, .seq-badge .save-indicator { display: none; }
  body { background: white; }
}
