/* tiwanon.shop — admin back office */
:root {
  --brand: #1B7F3B; --brand-600: #166C32; --brand-50: #EEF7F1; --brand-100: #DCEFE3;
  --ink: #17201B; --ink-2: #222D27; --ink-3: #2E3A33;
  --text: #1F2823; --muted: #6A756F; --line: #E3E9E5; --line-2: #EEF2EF;
  --bg: #F4F6F5; --card: #fff;
  --green: #138a52; --green-bg: #e6f6ee; --red: #c62f3c; --red-bg: #fdecee; --orange: #b85c00; --orange-bg: #fff3e3;
  --blue: #1d64c8; --blue-bg: #e9f1fd; --purple: #7a3fc4; --purple-bg: #f2ebfc; --teal: #0d8584; --teal-bg: #e3f6f5;
  --indigo: #4146b8; --indigo-bg: #ecedfb; --gray: #5f5562; --gray-bg: #f0ecef;
  --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgba(23, 32, 27, .05), 0 1px 8px rgba(23, 32, 27, .04);
  --sb-w: 248px;
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.55; color: var(--text); background: var(--bg); }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.break { word-break: break-all; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.upper { text-transform: uppercase; }
.neg { color: var(--red); } .pos { color: var(--green); }
kbd { font: 600 11px/1 var(--font); background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 2px 5px; color: var(--ink); }
.ic { flex-shrink: 0; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------------------------------------------------------- sidebar */
.sb { position: fixed; inset: 0 auto 0 0; width: var(--sb-w); background: var(--ink); color: #eadbe5; display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease; }
.sb-brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; color: #fff; text-decoration: none !important; }
.sb-brand b { display: block; font-size: 15.5px; letter-spacing: .01em; }
.sb-brand small { display: block; color: #A9B4AD; font-size: 12px; }
.logo-dot { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 19px; box-shadow: 0 4px 14px rgba(27, 127, 59, .45); }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent; }
.sb-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7E8A83; padding: 14px 10px 6px; }
.sb-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: #DCE3DE; font-size: 14px; text-decoration: none; margin: 1px 0; }
.sb-nav a:hover { background: var(--ink-2); color: #fff; }
.sb-nav a.on { background: linear-gradient(90deg, rgba(27, 127, 59, .26), rgba(27, 127, 59, .08)); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.sb-nav a span { flex: 1; }
.nb { font-style: normal; background: var(--brand); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; }
.sb-foot { padding: 12px 18px 18px; border-top: 1px solid var(--ink-2); }
.sb-foot a { color: #BCC6C0; font-size: 13px; }
.sb-backdrop { display: none; }

/* ---------------------------------------------------------------- top bar */
.main { margin-left: var(--sb-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.top { position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-title { font-size: 17px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--ink); cursor: pointer; position: relative; padding: 0; }
.icon-btn:hover { background: var(--line-2); text-decoration: none; }
.content { padding: 22px 24px 48px; flex: 1; max-width: 1480px; width: 100%; }
body.is-wide .content { max-width: none; }

.bell { position: relative; }
.bell-count { position: absolute; top: 2px; right: 1px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 36px rgba(23, 32, 27, .16); min-width: 220px; z-index: 50; overflow: hidden; }
.bell-dd { width: min(380px, calc(100vw - 24px)); }
.dd-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dd-list { max-height: 420px; overflow-y: auto; }
.dd-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line-2); color: var(--text); text-decoration: none !important; position: relative; }
.dd-item:hover { background: var(--brand-50); }
.dd-item.unread { background: #fff9fc; }
.dd-item.unread::before { content: ""; position: absolute; left: 5px; top: 16px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.dd-item b { display: block; font-size: 13.5px; font-weight: 600; }
.dd-item span { display: block; font-size: 12.5px; color: var(--muted); white-space: pre-line; max-height: 3.2em; overflow: hidden; }
.dd-item small { color: var(--muted); }
.dd-empty { padding: 24px; text-align: center; color: var(--muted); }
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 22px; font-size: 13.5px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--line-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.usermenu .dropdown a, .usermenu .dropdown button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 10px 14px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; text-decoration: none; }
.usermenu .dropdown a:hover, .usermenu .dropdown button:hover { background: var(--brand-50); }
.dd-meta { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- basics */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; min-width: 0; }
.card.flush { padding: 0; }
.card .pad, .pad { padding: 14px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card.flush > .card-head { margin-bottom: 0; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15.5px; font-weight: 600; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.card.highlight { border-color: var(--brand-100); background: linear-gradient(180deg, var(--brand-50), #fff 70%); }
.danger-zone { border-color: #f4d5d9; }
.stack > .card:last-child { margin-bottom: 0; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; margin: 0; }
.empty-state { text-align: center; padding: 48px; }
.pill { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--brand-50); color: var(--brand-600); font-size: 12px; font-weight: 600; }
.link { background: none; border: 0; padding: 0; color: var(--brand-600); font: inherit; font-size: 13.5px; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger, .danger { color: var(--red); }
.back { font-size: 13px; color: var(--muted); }
.h-big { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }
.row-wrap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row-wrap.tight { gap: 6px; margin: 0; }
.row-wrap.center { justify-content: center; }
.push { margin-left: auto; }

.grid-2, .grid-3, .grid-4, .grid-2-1 { display: grid; gap: 14px 16px; min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; gap: 18px; }
.grid-2-1 > .card, .grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
section.grid-2, div.grid-2 + div.grid-2 { margin-top: 0; }
.grid-2-1 + .grid-2, .grid-2-1 + .grid-3, .grid-2 + .grid-3, .kpis + .grid-2-1 { margin-top: 18px; }
.content > .grid-2, .content > .grid-3, .content > .grid-2-1 { margin-bottom: 18px; }
.span-2 { grid-column: span 2; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: 500 14px/1 var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { border-color: #d7c8d2; background: #fcfafb; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(27, 127, 59, .25); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-3); border-color: var(--ink-3); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #a92531; }
.btn-danger-ghost { color: var(--red); border-color: #f2cfd4; }
.btn-danger-ghost:hover { background: var(--red-bg); border-color: var(--red); }
.btn-line { background: #06c755; border-color: #06c755; color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 50px; font-size: 16.5px; font-weight: 600; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; white-space: nowrap; line-height: 1.5; }
.b-gray { background: var(--gray-bg); color: var(--gray); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-orange { background: var(--orange-bg); color: var(--orange); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.b-teal { background: var(--teal-bg); color: var(--teal); }
.b-indigo { background: var(--indigo-bg); color: var(--indigo); }
.b-magenta { background: var(--brand-50); color: var(--brand-600); }
.badge.soft { font-weight: 500; font-size: 11.5px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--gray); flex-shrink: 0; }
.d-gray { background: #a89ca6; } .d-green { background: var(--green); } .d-red { background: var(--red); } .d-orange { background: #e8890c; }
.d-blue { background: var(--blue); } .d-purple { background: var(--purple); } .d-teal { background: var(--teal); } .d-indigo { background: var(--indigo); }

/* ---------------------------------------------------------------- alerts */
.alert { display: flex; gap: 8px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert.ok { background: var(--green-bg); color: #0d6a3e; border-color: #c4ead6; }
.alert.err { background: var(--red-bg); color: #9b1f2a; border-color: #f4c9ce; }
.alert.warn { background: var(--orange-bg); color: #8a4500; border-color: #f7dcb7; }
.callout { background: var(--line-2); border: 1px dashed #dccfd8; border-radius: 10px; padding: 12px 14px; margin: 4px 0 16px; }
.callout code { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }
.copy-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.copy-row code { font-size: 13.5px; padding: 5px 9px; word-break: break-all; }
.note-box { background: #fffaf0; border: 1px solid #f3e3c5; border-radius: 9px; padding: 9px 12px; margin: 8px 0; font-size: 13.5px; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink); }
.help { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=tel], input[type=url], input[type=date], input[type=datetime-local], input[type=time], input:not([type]), select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: #fff; border: 1px solid #ddd2da; border-radius: 9px; padding: 8px 11px; min-height: 38px; width: 100%; min-width: 0; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; line-height: 1.5; }
select[multiple] { padding: 4px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27, 127, 59, .14); }
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; vertical-align: -3px; }
.field.check { flex-direction: row; margin-bottom: 8px; }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; font-size: 14px; }
.field.check .help { margin-left: 24px; }
.check-inline { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; font-size: 13.5px; }
.input-group { display: flex; gap: 0; }
.input-group > input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; }
.input-group > .btn, .input-group > select { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; width: auto; }
.w-xs { width: 70px !important; } .w-sm { width: 110px !important; } .w-md { width: 150px !important; }
.form-narrow { max-width: 860px; }
.form-narrow.sm { max-width: 480px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.toggles .field.check { margin-bottom: 6px; }
.sticky-save { position: sticky; top: 76px; z-index: 5; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(246, 243, 245, 0), var(--bg) 40%); padding: 16px 0 6px; display: flex; justify-content: flex-end; }
.count-hint { font-size: 11.5px; color: var(--muted); align-self: flex-end; margin-top: -2px; }
.count-hint.over { color: var(--orange); }

/* ---------------------------------------------------------------- filters */
.filters { display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; }
.filters .field { margin: 0; min-width: 140px; }
.filters .field.grow { flex: 1 1 240px; }
.filters .field.btns { flex-direction: row; gap: 6px; min-width: 0; }
.inline-filters { padding: 0; margin-bottom: 10px; }
.tabs-inline { display: flex; gap: 4px; flex-wrap: wrap; background: #ece5ea; padding: 4px; border-radius: 11px; }
.tabs-inline a, .tabs-inline button { padding: 6px 13px; border-radius: 8px; color: var(--ink); font: 500 13.5px var(--font); border: 0; background: none; cursor: pointer; text-decoration: none !important; display: inline-flex; gap: 6px; align-items: center; }
.tabs-inline a:hover, .tabs-inline button:hover { background: rgba(255, 255, 255, .6); }
.tabs-inline .on { background: #fff; box-shadow: 0 1px 3px rgba(23, 32, 27, .1); color: var(--brand-600); }
.tabs-inline.sub { margin-bottom: 14px; display: inline-flex; }
.bulk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.bulk-bar select { width: auto; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fcfafb; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fdfafc; }
.table.compact td, .table.compact th { padding: 8px 10px; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.is-off td { opacity: .6; }
.table input:not([type=checkbox]), .table select { min-height: 32px; padding: 5px 8px; font-size: 13.5px; }
/* stock page: withdraw / receive in one line per item */
.stock-act { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.table .stock-act input[type=number] { width: 64px; }
.table .stock-act select { width: auto; max-width: 150px; }
.table .stock-act input[type=text] { width: 140px; }
.table .stock-act input.stock-cost { width: 76px; text-align: right; }
.row-link { cursor: pointer; }
.w-check { width: 36px; }
.item-cell { display: flex; gap: 12px; align-items: flex-start; min-width: 220px; }
.item-cell img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--line-2); flex-shrink: 0; border: 1px solid var(--line); }
.icon-ph { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--brand-50); color: var(--brand-600); font-size: 18px; flex-shrink: 0; }
.custom-text { margin-top: 6px; background: var(--brand-50); border-left: 3px solid var(--brand); padding: 6px 10px; border-radius: 0 7px 7px 0; font-size: 13px; }
.products-table .qe { width: 96px; text-align: right; }
.qe.saving { border-color: #e8b86c; }
.qe.saved { border-color: var(--green); box-shadow: 0 0 0 3px rgba(19, 138, 82, .12); }
.qe.error { border-color: var(--red); }
.qe.warn { background: var(--orange-bg); }
.code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; background: var(--ink); color: #fff; padding: 3px 8px; border-radius: 6px; letter-spacing: .04em; text-decoration: none !important; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #d9cdd5; border-radius: 22px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.pager { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pager a, .pager b, .pager span { min-width: 34px; height: 34px; padding: 0 9px; display: inline-grid; place-items: center; border-radius: 8px; font-size: 13.5px; }
.pager a { border: 1px solid var(--line); color: var(--ink); background: #fff; text-decoration: none; }
.pager a:hover { border-color: var(--brand); color: var(--brand-600); }
.pager b { background: var(--ink); color: #fff; }
.pager .pager-info, .pager-info { margin-right: auto; color: var(--muted); font-size: 13px; padding: 0; place-items: start; }

/* ---------------------------------------------------------------- dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.small-kpis { grid-template-columns: repeat(2, minmax(0, 220px)); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; }
.kpi.link:hover { border-color: var(--brand-100); }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-val { font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; line-height: 1.25; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi.accent { background: linear-gradient(135deg, var(--ink) 0%, #1F4A30 100%); border-color: var(--ink); }
.kpi.accent .kpi-label, .kpi.accent .kpi-sub { color: #C7D0CA; }
.kpi.accent .kpi-val { color: #fff; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { font: 12.5px var(--font); fill: var(--muted); }
.chart .axis.strong { fill: var(--brand-600); font-weight: 700; }
.chart .bar { fill: #B9DFC6; transition: fill .12s; }
.chart .bar.today { fill: var(--brand); }
.chart g:hover .bar { fill: var(--brand-600); }
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list a { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line-2); color: var(--text); text-decoration: none; }
.status-list a:hover { background: var(--brand-50); }
.status-list b { margin-left: auto; font-size: 15px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list img { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; background: var(--line-2); }
.mini-list a { flex: 1; color: var(--text); min-width: 0; }
.mini-list small { display: block; color: var(--muted); }
.mini-list.text a { display: block; }

/* ---------------------------------------------------------------- order view */
.totals { border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; align-items: stretch; margin-left: auto; max-width: 420px; }
.totals > div { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand { font-size: 18px; font-weight: 700; color: var(--ink); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 4px; }
.dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dl.cols { grid-template-columns: 110px 1fr 110px 1fr; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { display: flex; gap: 12px; padding: 0 0 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { margin-top: 6px; }
.timeline div { font-size: 13.5px; }

/* ---------------------------------------------------------------- product form */
.repeater .rep-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.rep-row { display: grid; gap: 8px; align-items: start; }
.rep-row.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) 36px; }
.opt-group { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fcfafb; display: block; }
.opt-head { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 8px; margin-bottom: 8px; }
.opt-head input { font-weight: 600; }
.opt-val { grid-template-columns: 1fr 1fr 100px 36px; padding-left: 14px; border-left: 2px solid var(--brand-100); }
.faq-row { grid-template-columns: 1fr 36px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.faq-row .grid-2 { grid-column: 1; gap: 8px; }
.faq-row .grid-2 + .grid-2 { grid-row: 2; }
.faq-row > .icon-btn { grid-column: 2; grid-row: 1; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.img-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; display: flex; flex-direction: column; gap: 6px; position: relative; cursor: grab; }
.img-card:first-child { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-100); }
.img-card:first-child::after { content: "รูปหลัก"; position: absolute; top: 12px; left: 12px; background: var(--brand); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 5px; }
.img-card.dragging { opacity: .4; }
.img-card.over { border-style: dashed; border-color: var(--brand); }
.img-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: var(--line-2); }
.img-card input:not([type=checkbox]) { min-height: 30px; padding: 4px 8px; font-size: 12.5px; }
.img-card .grip { position: absolute; top: 12px; right: 12px; background: rgba(255, 255, 255, .9); border-radius: 6px; padding: 2px; display: grid; }
.img-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.img-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.preview-img { max-height: 160px; border-radius: 9px; border: 1px solid var(--line); display: block; margin-bottom: 6px; }

/* ---------------------------------------------------------------- marketing */
.banner-thumb { width: 120px; height: 52px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.theme-sw { display: inline-block; width: 22px; height: 22px; border-radius: 6px; vertical-align: middle; border: 1px solid rgba(0, 0, 0, .08); }
.t-magenta { background: var(--brand); } .t-ink { background: var(--ink); } .t-gold { background: linear-gradient(135deg, #e9c46a, #b8862b); } .t-light { background: #f8f1f5; }
.theme-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-pick label { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; cursor: pointer; font-size: 13.5px; }
.theme-pick input { position: absolute; opacity: 0; }
.theme-pick input:checked + .theme-sw { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand); }
.pick-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; margin: 8px 0 14px; }
.pick-list.tall { max-height: 560px; }
.pick { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.pick:hover { background: var(--brand-50); }
.pick img { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; background: var(--line-2); }
.pick span { flex: 1; font-size: 14px; }
.pick small { display: block; color: var(--muted); }
.pick.is-off { opacity: .55; }

/* ---------------------------------------------------------------- reviews / inbox */
.review { display: grid; grid-template-columns: 20px 48px 1fr auto; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); align-items: start; }
.review.pending { background: #fffbf5; }
.review img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.review p { margin: 6px 0; }
.review-actions { display: flex; gap: 6px; }
.stars { color: #f0a500; letter-spacing: 1px; margin-right: 6px; }
.stars .off { color: #e2d9df; }
.msg { border-bottom: 1px solid var(--line-2); }
.msg summary { display: grid; grid-template-columns: 10px auto 1fr auto; gap: 12px; align-items: center; padding: 13px 18px; cursor: pointer; list-style: none; }
.msg summary::-webkit-details-marker { display: none; }
.msg summary:hover { background: #fdfafc; }
.msg .dot { background: transparent; }
.msg.unread .dot { background: var(--brand); }
.msg.unread b { color: var(--ink); }
.msg-subj { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.msg-body { padding: 4px 18px 16px 40px; }
.msg-text { background: var(--line-2); border-radius: 10px; padding: 12px 14px; white-space: normal; }
.app-card .app-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.app-card .app-actions select, .app-card .app-actions input[name=admin_note] { width: auto; flex: 1 1 200px; }

/* ---------------------------------------------------------------- POS */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
.pos-left { min-width: 0; }
.pos-search { position: relative; margin-bottom: 10px; }
.pos-search .ic { position: absolute; left: 14px; top: 14px; color: var(--muted); }
.pos-search input { height: 50px; padding-left: 44px; font-size: 16px; border-radius: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.chip { flex-shrink: 0; border: 1px solid var(--line); background: #fff; border-radius: 18px; padding: 5px 13px; font: 500 13px var(--font); cursor: pointer; color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pos-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; text-align: left; cursor: pointer; font: inherit; color: var(--text); display: flex; flex-direction: column; gap: 6px; transition: border-color .1s, transform .1s, box-shadow .1s; position: relative; }
.pos-item:hover, .pos-item.sel { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27, 127, 59, .12); }
.pos-item:active { transform: scale(.98); }
.pos-item img, .pos-item .ph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--line-2); }
.pos-item b { font-size: 13.5px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.pos-item .pr { font-weight: 700; color: var(--brand-600); font-size: 15px; }
.pos-item .pr s { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.pos-item .st { font-size: 11.5px; color: var(--muted); }
.pos-item .st.low { color: var(--orange); font-weight: 600; }
.pos-item .tag { position: absolute; top: 12px; left: 12px; }
.kbd-help { margin-top: 12px; }
.pos-right { position: sticky; top: 76px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 92px); overflow-y: auto; }
.pos-right > * { flex-shrink: 0; }
.pos-cart-head { display: flex; justify-content: space-between; align-items: center; }
.pos-cart-head h2 { font-size: 16px; display: flex; gap: 8px; align-items: center; }
.pos-lines { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.pos-lines .empty { padding: 18px; font-size: 13.5px; }
.pos-line { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; }
.pos-line .nm { font-size: 13.5px; font-weight: 500; }
.pos-line .op { font-size: 12px; color: var(--muted); grid-column: 1 / -1; margin-top: -2px; }
.pos-line .lt { font-weight: 700; text-align: right; }
.pos-line .ctrl { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
.pos-line .ctrl input.price { width: 96px; min-height: 30px; padding: 3px 8px; text-align: right; }
.pos-line .ctrl .x { margin-left: auto; }
.qty-step { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty-step button { width: 30px; border: 0; background: var(--line-2); font-size: 16px; cursor: pointer; color: var(--ink); }
.qty-step input { width: 46px; border: 0 !important; border-radius: 0 !important; text-align: center; min-height: 30px !important; padding: 2px !important; box-shadow: none !important; -moz-appearance: textfield; }
.qty-step input::-webkit-outer-spin-button, .qty-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pos-box { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.pos-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.pos-row label { font-size: 13.5px; white-space: nowrap; }
.pos-row .input-group { max-width: 180px; }
.pos-row .input-group select { min-width: 58px; }
.pos-row.two { display: grid; grid-template-columns: 1fr 1fr; }
.pos-totals { background: var(--line-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.pos-totals > div { display: flex; justify-content: space-between; }
.pos-totals .grand { font-size: 24px; font-weight: 700; color: var(--ink); }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pay-btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; font: 500 12.5px var(--font); cursor: pointer; color: var(--ink); }
.pay-btn.on { border-color: var(--brand); background: var(--brand-50); color: var(--brand-600); box-shadow: 0 0 0 2px var(--brand-100); }
.pay-panel { display: flex; flex-direction: column; gap: 8px; }
.pay-panel > label { font-size: 13px; font-weight: 500; }
.pay-panel #posCash { height: 46px; font-size: 20px; font-weight: 600; text-align: right; }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px; font: 500 13px var(--font); cursor: pointer; min-width: 56px; }
.quick-cash button:hover { border-color: var(--brand); }
.change { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.change b { font-size: 22px; color: var(--green); }
.change.short b { color: var(--red); }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; }
.qr-box img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pos-mobile-bar { display: none; }
.print-frame { position: fixed; width: 0; height: 0; border: 0; left: -9999px; }
.modal { position: fixed; inset: 0; background: rgba(23, 32, 27, .5); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 16px; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; position: relative; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal-card.center { text-align: center; }
.modal-card h3 { font-size: 17px; margin: 0 36px 12px 0; }
.modal-card.center h3 { margin: 6px 0; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; }
.opt-block { margin-bottom: 12px; }
.opt-block > b { display: block; font-size: 13.5px; margin-bottom: 6px; }
.opt-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.opt-choices label { border: 1px solid var(--line); border-radius: 9px; padding: 6px 11px; cursor: pointer; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.opt-choices label:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.opt-choices input { position: absolute; opacity: 0; }
.done-icon { width: 72px; height: 72px; margin: 4px auto 6px; border-radius: 50%; background: var(--green-bg); color: var(--green); display: grid; place-items: center; }

/* ---------------------------------------------------------------- login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, rgba(27, 127, 59, .25), transparent 60%), var(--ink); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.login-card h1 { font-size: 22px; margin: 18px 0 14px; color: var(--ink); }
.login-brand { display: flex; gap: 10px; align-items: center; }
.login-brand b { display: block; color: var(--ink); }
.login-brand small { color: var(--muted); }

/* ---------------------------------------------------------------- responsive */
.only-m { display: none !important; }
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
  .sticky-save { position: static; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 960px) {
  .sb { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  body.sb-open .sb { transform: none; }
  body.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(23, 32, 27, .45); z-index: 35; }
  .main { margin-left: 0; }
  .only-m { display: inline-grid !important; }
  .hide-m { display: none !important; }
  .top { padding: 0 12px; }
  .content { padding: 16px 16px 90px; }
  .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
  .sticky-save { position: static; }
  .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-right { position: fixed; inset: auto 0 0 0; top: auto; max-height: 88vh; border-radius: 16px 16px 0 0; z-index: 60; transform: translateY(105%); transition: transform .2s; }
  body.pos-cart-open .pos-right { transform: none; }
  .pos-mobile-bar { display: block !important; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 55; height: 52px; border: 0; border-radius: 14px; background: var(--brand); color: #fff; font: 600 16px var(--font); box-shadow: 0 8px 24px rgba(27, 127, 59, .4); }
  .kbd-help { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-val { font-size: 20px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .card { padding: 14px; }
  .filters .field { min-width: calc(50% - 6px); flex: 1 1 calc(50% - 6px); }
  .filters .field.grow { flex-basis: 100%; }
  .dl, .dl.cols { grid-template-columns: 100px 1fr; }
  .rep-row.grid-4 { grid-template-columns: 1fr 1fr 36px; }
  .rep-row.grid-4 > input:nth-child(3), .rep-row.grid-4 > input:nth-child(4) { grid-row: 2; }
  .rep-row.grid-4 > .icon-btn { grid-row: 1; grid-column: 3; }
  .opt-val { grid-template-columns: 1fr 1fr 70px 30px; padding-left: 6px; }
  .review { grid-template-columns: 20px 40px 1fr; }
  .review-actions { grid-column: 3; }
  .msg summary { grid-template-columns: 10px 1fr auto; }
  .msg-subj { grid-column: 2 / -1; grid-row: 2; }
  .msg-body { padding-left: 18px; }
  .h-big { font-size: 19px; }
  .pos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table th, .table td { padding: 9px 10px; }
  .top-title { font-size: 15.5px; }
}
@media print {
  .sb, .top, .actions, .btn { display: none !important; }
  .main { margin: 0; }
}

.logo-dot svg{width:100%;height:100%;display:block}
.steps-list code{font-size:12.5px;background:#fff;border:1px solid var(--line);border-radius:5px;padding:1px 6px}
.steps-list .copy-row{margin:6px 0}
/* notification channels page */
.check-chip{display:inline-flex;align-items:center;gap:6px;padding:7px 12px;border:1px solid var(--line);border-radius:999px;background:#fff;cursor:pointer;font-size:13.5px}
.check-chip input{accent-color:var(--brand)}
.ch-dot{display:inline-block;width:10px;height:10px;border-radius:50%}
details.guide{background:var(--line-2);border:1px dashed #dccfd8;border-radius:10px;padding:10px 14px}
details.guide summary{cursor:pointer;font-weight:600}
details.guide ol{margin:8px 0 6px;padding-left:20px;line-height:1.85}
details.guide code{background:#fff;border:1px solid var(--line);border-radius:5px;padding:1px 6px;font-size:12.5px}
h3.sub{font-size:14px;margin:16px 0 8px}
.target-list{display:grid;gap:8px;margin-bottom:10px}
.target{display:flex;gap:10px;align-items:flex-start;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:#fff;cursor:pointer}
.target input{margin-top:4px;accent-color:var(--brand)}
.target>span{flex:1;min-width:0;word-break:break-all}
.target:has(input:checked){border-color:var(--brand);background:var(--brand-50)}
.btn-google{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:42px;border:1px solid #dadce0;border-radius:10px;background:#fff;color:#1f1f1f;font-weight:600;text-decoration:none}
.btn-google:hover{background:#f8f9fa}
.or-divider{display:flex;align-items:center;gap:10px;margin:14px 0;color:var(--muted);font-size:12.5px}
.or-divider::before,.or-divider::after{content:"";flex:1;height:1px;background:var(--line)}
