/* Souwa Admin — palette matched to the customer site */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --ink: #2E3823;
  --ink-soft: #4a533a;
  --moss: #5E6E40;
  --sage: #8FA058;
  --gold: #BFA269;
  --cream: #FAF7EF;
  --card: #FBF9F3;
  --panel: #F4F0E5;
  --line: #E7E1D0;
  --line-soft: #cfd3bd;
  --muted: #8b917a;
  --danger: #a4553f;
}

body {
  font-family: 'Sarabun', sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-size: 15px;
}
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; }

/* ---------- login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #eef0e2, var(--cream));
}
.login-card {
  width: 360px; max-width: 92vw; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 40px 34px;
  box-shadow: 0 24px 60px -30px rgba(46,56,35,.4);
}
.login-brand { font-family: 'Noto Serif JP', serif; font-size: 40px; text-align: center; color: var(--moss); }
.login-title { text-align: center; color: var(--ink-soft); margin: 6px 0 26px; font-size: 14px; letter-spacing: .04em; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label, .stack label, .stock-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 5px;
  background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sage); }
textarea { resize: vertical; }

.btn-primary {
  background: var(--ink); color: var(--cream); border: none; border-radius: 5px;
  padding: 12px 18px; font-family: inherit; font-size: 15px; cursor: pointer; letter-spacing: .03em;
}
.btn-primary:hover { background: #3d4a2f; }
.btn-line {
  background: transparent; color: var(--ink); border: 1px solid var(--line-soft);
  border-radius: 5px; padding: 9px 16px; font-family: inherit; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn-line:hover { border-color: var(--moss); }

.alert { padding: 10px 14px; border-radius: 5px; font-size: 14px; margin-bottom: 16px; }
.alert.err, .alert.err.err { background: #f7e7e2; color: var(--danger); border: 1px solid #e6c3b8; }
.alert.ok { background: #e9efdd; color: var(--moss); border: 1px solid #cdd8b3; }

.btn-danger {
  background: var(--danger); color: #fff; border: none; border-radius: 5px;
  padding: 12px 18px; font-family: inherit; font-size: 15px; cursor: pointer; letter-spacing: .03em;
}
.btn-danger:hover { background: #8f4736; }

/* ---------- coupons ---------- */
.coupon-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.coupon-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.gen-row { display: flex; gap: 10px; }
.gen-row input { flex: 1; }
.table-wrap { overflow-x: auto; padding: 6px 20px; }
.table .row-off td { opacity: .5; }
.danger-link { color: var(--danger); border-color: #e6c3b8; }
.danger-link:hover { border-color: var(--danger); }
@media (max-width: 720px) { .coupon-form { grid-template-columns: 1fr; } }

/* ---------- system / data page ---------- */
.count-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.count-pill { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 5px 14px; font-size: 13px; color: var(--ink-soft); }
.count-pill b { color: var(--ink); }
.sys-grid { display: grid; gap: 20px; max-width: 720px; }
.sys-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 24px 26px; }
.sys-card h2 { font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 24px; margin-bottom: 6px; }
.sys-card .desc { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 18px; }
.sys-card.danger { border-color: #e6c3b8; background: #fbf1ee; }
.sys-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- shell / sidebar ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink); color: #d9dec9; padding: 26px 18px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: baseline; gap: 10px; padding: 0 8px 26px; border-bottom: 1px solid #3e4a30; }
.brand-kanji { font-family: 'Noto Serif JP', serif; font-size: 28px; color: #eaeede; }
.brand-sub { font-size: 12px; letter-spacing: .28em; color: var(--sage); }
.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 22px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 6px;
  color: #c6ccb5; font-size: 15px;
}
.side-nav a .ic { color: var(--sage); width: 18px; text-align: center; }
.side-nav a:hover { background: #35422a; color: #fff; }
.side-nav a.on { background: var(--moss); color: #fff; }
.side-nav a.on .ic { color: #dfe6c4; }
/* ป้ายจำนวนออเดอร์ใหม่บนเมนู "ออเดอร์" */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 11px; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }

/* ---------- กระดิ่งแจ้งเตือนแอดมิน ---------- */
.admin-bell { margin-left: auto; align-self: center; }
.abell-btn { position: relative; background: none; border: none; padding: 4px; cursor: pointer; color: #c6ccb5; display: inline-flex; align-items: center; line-height: 0; }
.abell-btn:hover { color: #fff; }
.abell-btn svg { display: block; }
.abell-dot { position: absolute; top: -3px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.abell-panel { position: fixed; z-index: 80; width: 340px; max-width: 92vw; background: var(--cream); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(20,26,14,.28); overflow: hidden; }
.abell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.abell-readall { background: none; border: none; padding: 0; color: var(--moss); font-size: 12px; cursor: pointer; font-family: inherit; }
.abell-readall:hover { text-decoration: underline; }
.abell-list { max-height: 66vh; overflow-y: auto; }
.abell-item { display: block; padding: 12px 16px 12px 22px; border-bottom: 1px solid var(--line); position: relative; }
.abell-item:last-child { border-bottom: none; }
.abell-item:hover { background: #f4efe2; }
.abell-item.unread { background: #fbf6ea; }
.abell-item.unread::before { content: ''; position: absolute; left: 9px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.abell-item.type-slip.unread::before { background: var(--danger); }
.abell-item.type-low_stock.unread::before { background: var(--gold); }
.abell-item .abi-title { font-size: 14px; color: var(--ink); margin-bottom: 2px; }
.abell-item .abi-body { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.abell-item .abi-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.abell-empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.side-foot { margin-top: auto; padding-top: 20px; border-top: 1px solid #3e4a30; }
.who-name { font-size: 15px; color: #eaeede; }
.who-role { font-size: 12px; color: var(--sage); }
.logout {
  margin-top: 12px; width: 100%; background: transparent; color: #c6ccb5;
  border: 1px solid #4a5738; border-radius: 5px; padding: 8px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.logout:hover { border-color: var(--gold); color: #fff; }

.main { padding: 34px 40px 60px; max-width: 1240px; }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 40px; letter-spacing: .01em; }
.muted { color: var(--muted); }
p.muted { margin: 4px 0 0; font-size: 14px; }
.back { font-size: 13px; color: var(--moss); }
.back:hover { text-decoration: underline; }
.head-total { text-align: right; }
.big-money { font-family: 'Cormorant Garamond', serif; font-size: 34px; color: var(--moss); }

/* ---------- review CTA (งานตรวจสลิปประจำวัน) ---------- */
.review-cta {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
  padding: 18px 24px; border-radius: 10px; border: 1px solid var(--line);
}
.review-cta.has {
  background: linear-gradient(120deg, #eef2df, #f6efe0);
  border-color: var(--sage);
  box-shadow: 0 10px 30px -18px rgba(94,110,64,.6);
}
.review-cta.none { background: var(--card); }
.review-cta .rc-icon { font-size: 30px; line-height: 1; }
.review-cta .rc-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.review-cta .rc-title { font-family: 'Cormorant Garamond', serif; font-size: 26px; line-height: 1.1; color: var(--ink); }
.review-cta .rc-sub { font-size: 13.5px; color: var(--ink-soft); }
.review-cta.none .rc-sub { color: var(--muted); }
.review-cta .rc-count {
  font-family: 'Cormorant Garamond', serif; font-size: 40px; line-height: 1;
  min-width: 52px; text-align: center; color: var(--moss);
}
.review-cta.has .rc-count { color: var(--danger); }
.review-cta .rc-go {
  background: var(--ink); color: var(--cream); border-radius: 6px;
  padding: 10px 18px; font-size: 14px; white-space: nowrap;
}
.review-cta.has:hover .rc-go { background: var(--moss); }
.review-cta.none .rc-go { background: transparent; color: var(--muted); border: 1px solid var(--line-soft); }
@media (max-width: 560px) {
  .review-cta { flex-wrap: wrap; }
  .review-cta .rc-go { width: 100%; text-align: center; }
}

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 24px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px; }
.kpi.accent { background: linear-gradient(160deg, #f3efdf, var(--card)); border-color: var(--line-soft); }
.kpi-link { display: block; transition: border-color .15s, box-shadow .15s; }
.kpi-link:hover { border-color: var(--gold); box-shadow: 0 8px 22px -16px rgba(46,56,35,.5); }
.kpi-link .kpi-foot { color: var(--moss); }
.kpi-label { font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.kpi-value { font-family: 'Cormorant Garamond', serif; font-size: 38px; line-height: 1.1; margin: 6px 0 2px; color: var(--ink); }
.kpi-foot { font-size: 12.5px; color: var(--sage); }

/* ---------- panels ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px; margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h2 { font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 24px; }
.link { color: var(--moss); font-size: 13px; }
.link:hover { text-decoration: underline; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }

/* ---------- chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar { width: 100%; background: linear-gradient(180deg, var(--sage), var(--moss)); border-radius: 3px 3px 0 0; min-height: 2px; transition: opacity .2s; }
.bar-col:hover .bar { opacity: .75; }
.bar-x { font-size: 10px; color: var(--muted); margin-top: 6px; transform: rotate(-30deg); white-space: nowrap; }

/* ---------- status list ---------- */
.status-list { display: flex; flex-direction: column; gap: 2px; }
.status-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 6px; }
.status-row:hover { background: var(--panel); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-name { flex: 1; }
.status-count { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--ink); }

/* ---------- tables ---------- */
.table, .mini-table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; letter-spacing: .04em; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.mini-table td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
.mini-table tr:last-child td { border-bottom: none; }
.clickable { cursor: pointer; }
.clickable:hover { background: var(--panel); }
.num { text-align: right; }
.strong { font-weight: 600; }
.big { font-size: 18px; }
.mono { font-family: 'Cormorant Garamond', serif; font-size: 18px; color: var(--moss); }
.nowrap { white-space: nowrap; }
.rank { color: var(--gold); font-family: 'Cormorant Garamond', serif; font-size: 18px; width: 24px; }
.cust-name { font-weight: 500; }
.cust-sub { font-size: 12.5px; color: var(--muted); }
.table tfoot td { padding: 12px 10px; border-top: 2px solid var(--line); }
.empty { color: var(--muted); text-align: center; padding: 30px; }

/* ---------- slip thumbnail (ในตารางออเดอร์) ---------- */
.slip-cell { width: 60px; }
.slip-thumb {
  width: 46px; height: 46px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line-soft); display: block; background: var(--panel);
}
a.slip-thumb:hover { border-color: var(--moss); }
.slip-thumb-pdf {
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif; font-size: 13px; letter-spacing: .05em;
  color: var(--danger); background: #f7e7e2; border-color: #e6c3b8;
}
.slip-none { color: var(--line-soft); }

/* ---------- click-to-contact (tel: / mailto:) ---------- */
.contact-link { color: var(--moss); }
.contact-link:hover { text-decoration: underline; }

/* ---------- pills ---------- */
.pill {
  display: inline-block; font-size: 12.5px; padding: 3px 11px; border-radius: 40px;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.pill.big { font-size: 14px; padding: 5px 14px; vertical-align: middle; margin-left: 10px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 40px; font-size: 14px; color: var(--ink-soft); }
.tabs a:hover { background: var(--panel); }
.tabs a.on { background: var(--ink); color: var(--cream); }
.search { display: flex; gap: 8px; }
.search input { width: 320px; max-width: 60vw; }

/* ---------- filter bar (ค้นหา + ช่วงวันที่) ---------- */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar > input[name="q"] { width: 300px; max-width: 60vw; }
.filter-bar .date-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filter-bar .date-field input { width: auto; }
.clear-link { font-size: 13px; color: var(--danger); }
.clear-link:hover { text-decoration: underline; }

/* ---------- date range (หน้ารายงาน) ---------- */
.range-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.range-bar label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.range-bar input { width: auto; }
.range-quick { margin-left: auto; }
.range-quick .qlink { font-size: 13px; color: var(--moss); }
.range-quick .qlink:hover { text-decoration: underline; }

/* ---------- bulk action bar ---------- */
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin: -4px 0 14px; padding: 12px 16px; background: linear-gradient(120deg, #eef2df, #f6efe0);
  border: 1px solid var(--sage); border-radius: 8px; }
.bulk-count { font-size: 14px; color: var(--ink); }
.bulk-count b { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--moss); }
.bulk-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.bulk-actions .btn-primary { padding: 9px 16px; font-size: 14px; }
.check-cell { width: 34px; text-align: center; }
.check-cell input { width: 17px; height: 17px; accent-color: var(--moss); cursor: pointer; }
.orders-table tbody tr:hover .row-check { outline: 1px solid var(--line-soft); }

/* ---------- จัดการพนักงาน / สิทธิ์ ---------- */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.perm-grid label { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); font-weight: 400; }
.perm-grid input { width: 16px; height: 16px; accent-color: var(--moss); }
.perm-cell { font-size: 13px; color: var(--ink-soft); }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; font-family: inherit; font-size: 13px; padding: 0 0 0 10px; }
.link-danger:hover { text-decoration: underline; }

/* ---------- progress bar (สัดส่วนยอดขายในรายงาน) ---------- */
.prog { background: var(--panel); border-radius: 20px; height: 10px; overflow: hidden; }
.prog-fill { height: 100%; background: linear-gradient(90deg, var(--sage), var(--moss)); border-radius: 20px; }

/* ---------- pager ---------- */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.pager a { padding: 7px 12px; border: 1px solid var(--line-soft); border-radius: 5px; font-size: 14px; }
.pager a:hover { border-color: var(--moss); }
.pager a.on { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* ---------- detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv.col { flex-direction: column; gap: 4px; }
.kv.col p { margin: 0; line-height: 1.6; }

/* ---------- slip ---------- */
.slip-view { display: flex; flex-direction: column; gap: 10px; }
.slip-img { width: 100%; border: 1px solid var(--line); border-radius: 6px; display: block; }
.slip-meta { font-size: 12.5px; color: var(--muted); }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 4px 0 16px; position: relative; }
.timeline li:not(:last-child)::before { content: ''; position: absolute; left: 5px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 3px; flex-shrink: 0; z-index: 1; }
.tl-head { font-size: 15px; }
.tl-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tl-note { font-size: 13.5px; color: var(--ink-soft); margin-top: 4px; font-style: italic; }

/* ---------- products ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.product-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.product-img { aspect-ratio: 16/10; background: var(--panel); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-img .noimg { font-size: 40px; color: var(--line-soft); }
.product-body { padding: 16px 18px 18px; }
.product-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.product-title span:first-child { font-family: 'Cormorant Garamond', serif; font-size: 20px; letter-spacing: .04em; }
.product-title .kanji { font-family: 'Noto Serif JP', serif; color: var(--sage); font-size: 14px; }
.product-price { color: var(--moss); margin: 4px 0 12px; }
.product-price .soon { font-size: 12px; color: var(--gold); margin-left: 6px; }
.product-stats { display: flex; gap: 18px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
.product-stats div { display: flex; flex-direction: column; gap: 2px; }
.stock-form { margin-top: 14px; }
.stock-row { display: flex; gap: 8px; margin-top: 6px; }
.stock-row input { width: 100px; }
.low-stock { color: var(--danger); font-size: 12.5px; margin-top: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-nav { flex-direction: row; margin-top: 0; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: none; display: flex; align-items: center; gap: 12px; }
  .brand { border: none; padding: 0 12px 0 0; }
  .main { padding: 24px 20px 50px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .detail-grid { grid-template-columns: 1fr; }
}
