:root {
  --bg: #f6f6f4; --card: #fff; --text: #1d1d1b; --muted: #6b6a66; --line: #e3e2dc;
  --accent: #1f6fd1; --accent-text: #fff; --danger: #b42318;
  --red-bg: #fdecec; --red: #a32d2d; --violet-bg: #eeedfe; --violet: #3c3489;
  --green-bg: #eaf3de; --green: #27500a; --blue-bg: #e6f1fb; --blue: #0c447c;
  --yellow-bg: #faeeda; --yellow: #633806; --orange-bg: #faece7; --orange: #712b13;
  --gray-bg: #f1efe8; --gray: #444441;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --card: #20201f; --text: #ecebe6; --muted: #a3a29c; --line: #34332f;
    --accent: #4a90e2; --red-bg: #501313; --red: #f7c1c1; --violet-bg: #26215c; --violet: #cecbf6;
    --green-bg: #173404; --green: #c0dd97; --blue-bg: #042c53; --blue: #b5d4f4;
    --yellow-bg: #412402; --yellow: #fac775; --orange-bg: #4a1b0c; --orange: #f5c4b3;
    --gray-bg: #2c2c2a; --gray: #d3d1c7;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "IBM Plex Sans Thai", "Sarabun", system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px 48px; }
header.top { display: flex; align-items: center; gap: 12px; padding: 14px 0; flex-wrap: wrap; }
header.top .brand { font-weight: 600; font-size: 18px; color: var(--text); }
header.top nav { display: flex; gap: 14px; flex: 1; }
header.top nav a { color: var(--muted); }
header.top form { display: flex; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=email], input[type=tel], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
textarea { min-height: 90px; resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 6px 0 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--muted); }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .num { font-size: 24px; font-weight: 600; }
h2.section { font-size: 14px; font-weight: 500; color: var(--muted); margin: 18px 0 6px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--text); }
.row:first-child { border-top: none; }
.row:hover { background: var(--bg); text-decoration: none; }
.row .no { font-size: 12px; color: var(--muted); width: 72px; flex-shrink: 0; }
.row .main { flex: 1; min-width: 0; }
.row .main .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .main .s { font-size: 13px; color: var(--muted); }
.row .when { font-size: 13px; color: var(--muted); white-space: nowrap; }
.empty { padding: 16px; color: var(--muted); }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 8px; white-space: nowrap; }
.b-red { background: var(--red-bg); color: var(--red); } .b-violet { background: var(--violet-bg); color: var(--violet); }
.b-green { background: var(--green-bg); color: var(--green); } .b-blue { background: var(--blue-bg); color: var(--blue); }
.b-yellow { background: var(--yellow-bg); color: var(--yellow); } .b-orange { background: var(--orange-bg); color: var(--orange); }
.b-gray { background: var(--gray-bg); color: var(--gray); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: 13px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field.full { grid-column: 1 / -1; }
.job-head h1 { font-size: 22px; margin: 4px 0; font-weight: 600; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; font-size: 14px; }
.meta .k { color: var(--muted); font-size: 12px; }
.status-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.status-bar button { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 4px 12px; cursor: pointer; font-size: 14px; }
.status-bar button.current { outline: 2px solid var(--text); }
.timeline .ev { padding: 10px 0; border-top: 1px solid var(--line); }
.timeline .ev:first-child { border-top: none; }
.timeline .ev .h { font-size: 12px; color: var(--muted); }
.timeline .ev .b { white-space: pre-wrap; word-break: break-word; }
.timeline .ev.status .b, .timeline .ev.created .b { color: var(--muted); font-size: 14px; }
.timeline .ev.email_in { border-left: 3px solid var(--accent); padding-left: 10px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.thumbs img { height: 90px; border-radius: 6px; border: 1px solid var(--line); }
.flash { background: var(--yellow-bg); color: var(--yellow); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
  .row .no { width: auto; }
  .row { flex-wrap: wrap; }
  header.top nav { order: 3; width: 100%; }
}

/* list + case layout (IBM-support style) */
.wrap.wide { max-width: 1400px; }
h1.page { font-size: 26px; font-weight: 400; margin: 6px 0 14px; }
.today { background: var(--blue-bg); color: var(--blue); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.today a { color: var(--blue); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; }
.panel .count { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.filters { display: grid; grid-template-columns: 1.2fr 1fr 1.3fr 1.3fr 1.5fr auto; gap: 10px; margin-bottom: 12px; }
.filters select, .filters input { border-width: 0 0 1px; border-radius: 0; background: var(--bg); }
.tablewrap { overflow-x: auto; }
table.jobs { width: 100%; border-collapse: collapse; font-size: 14px; }
table.jobs th { background: var(--gray-bg); text-align: left; font-weight: 600; padding: 10px; white-space: nowrap; font-size: 13px; }
table.jobs th a { color: var(--text); }
table.jobs td { padding: 10px; border-top: 1px solid var(--line); vertical-align: top; }
table.jobs td.title { min-width: 180px; max-width: 260px; }
table.jobs tr:hover td { background: var(--bg); }
.sub { font-size: 12px; color: var(--muted); }
.nowrap { white-space: nowrap; } .center { text-align: center; }
.crumbs { font-size: 14px; color: var(--muted); margin: 4px 0 2px; }
.case { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.case-title { font-size: 22px; font-weight: 400; margin: 10px 0 16px; }
.box, .side-box { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; margin-bottom: 12px; }
.box > summary, .side-box > summary, .box-h { font-weight: 600; font-size: 14px; cursor: pointer; margin-bottom: 10px; list-style: none; }
.box > summary::after, .side-box > summary::after { content: "⌃"; float: right; color: var(--muted); }
details:not([open]) > summary::after { content: "⌄"; }
details:not([open]) > summary { margin-bottom: 0; }
.k { font-size: 12px; color: var(--muted); }
.clamp { white-space: pre-wrap; word-break: break-word; max-height: 7.8em; overflow: hidden; }
.clamp.open { max-height: none; }
a.more { display: block; text-align: right; font-size: 14px; margin-top: 4px; }
.note-form textarea { min-height: 70px; }
.note-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.note-actions .hint { flex: 1; }
.hint { font-size: 12px; color: var(--muted); }
.hist-tools { display: grid; grid-template-columns: 1fr 180px auto; gap: 8px; margin: 14px 0 6px; }
.daysep { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 14px 0 4px; }
.daysep::before, .daysep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.ev { display: flex; gap: 12px; padding: 10px 0; }
.av { width: 38px; height: 38px; border-radius: 50%; background: var(--gray-bg); color: var(--gray); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.av.cust { background: var(--blue-bg); color: var(--blue); }
.ev-body { min-width: 0; flex: 1; font-size: 14px; }
.ev-body .when { font-size: 12px; color: var(--muted); }
.ev-body .text { margin-top: 2px; }
.status-big { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-top: 2px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.d-red { background: #e24b4a; } .d-violet { background: #7f77dd; } .d-green { background: #639922; } .d-blue { background: #378add; }
.d-yellow { background: #ba7517; } .d-orange { background: #d85a30; } .d-gray { background: #5f5e5a; }
.info { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; font-size: 14px; }
.info .full { grid-column: 1 / -1; }
.file { font-size: 14px; padding: 3px 0; word-break: break-all; }
.closeform { margin-top: 10px; }
.side-box select#act { margin-top: 4px; }
@media (max-width: 900px) {
  .case { grid-template-columns: 1fr; }
  .case-side { order: -1; }
  .filters { grid-template-columns: 1fr 1fr; }
}

/* v3: top bar, language switch, multi-select filters, toolbar, print */
body { font-family: "IBM Plex Sans", "IBM Plex Sans Thai", system-ui, sans-serif; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.topbar-in { display: flex; align-items: center; gap: 18px; padding: 10px 16px; flex-wrap: wrap; }
.topbar .brand { font-weight: 600; font-size: 18px; color: var(--text); }
.topbar .brand span { font-weight: 400; color: var(--muted); }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { color: var(--text); }
.topsearch input { width: 280px; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 13px; }
.lang a { padding: 6px 10px; color: var(--muted); }
.lang a.on { background: var(--text); color: var(--bg); }
.lang a:hover { text-decoration: none; }
.filters { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; }
details.ms { position: relative; }
details.ms > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line); background: var(--bg); padding: 8px 10px; min-height: 38px; }
details.ms > summary::-webkit-details-marker { display: none; }
details.ms > summary .ms-label { flex: 1; color: var(--muted); }
details.ms > summary::after { content: "⌄"; color: var(--muted); }
details.ms[open] > summary::after { content: "⌃"; }
.chip-n { background: var(--text); color: var(--bg); border-radius: 12px; padding: 0 8px; font-size: 13px; }
.chip-n a { color: var(--bg); margin-left: 4px; }
.ms-list { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 320px; overflow: auto; padding: 6px 0; min-width: 240px; }
.ms-list.right { left: auto; right: 0; }
.ms-list label { display: flex; gap: 10px; align-items: center; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.ms-list label:hover { background: var(--bg); }
.ms-list input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--text); }
.ms-actions { padding: 6px 12px; text-align: right; border-top: 1px solid var(--line); margin-top: 4px; }
.toolbar { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.toolbar input[type=search] { width: 220px; }
.icon { background: none; border: 0; font-size: 18px; color: var(--text); cursor: pointer; padding: 6px 8px; border-radius: 6px; line-height: 1; }
.icon:hover { background: var(--bg); text-decoration: none; }
details.cols > summary { border: 0; background: none; padding: 6px 8px; min-height: 0; }
details.cols > summary::after { content: none; }
@media (max-width: 900px) { .topsearch input { width: 100%; } .topsearch { order: 5; width: 100%; } .filters { grid-template-columns: 1fr 1fr; } }
@media print {
  .topbar, .filters, .crumbs, .today, .note-form, .hist-tools, .case-side select, .closeform { display: none !important; }
  body { background: #fff; color: #000; } .panel, .box, .side-box { border: 0; }
}
table.jobs td[data-col="customer"], table.jobs td[data-col="product"] { min-width: 150px; }

/* open-a-job form, IBM "Open a case" layout */
.ocase { display: grid; grid-template-columns: 170px minmax(0, 520px) minmax(0, 1fr); gap: 28px; align-items: start;
  background: var(--card); border: 1px solid var(--line); padding: 24px 24px 32px; }
.ocase-nav { position: sticky; top: 16px; display: flex; flex-direction: column; border-left: 2px solid var(--line); }
.ocase-nav a { color: var(--muted); padding: 10px 12px; margin-left: -2px; border-left: 3px solid transparent; font-size: 15px; }
.ocase-nav a.on { color: var(--text); border-left-color: var(--accent); }
.ocase-nav a:hover { text-decoration: none; color: var(--text); }
.ocase-main section { padding-bottom: 28px; scroll-margin-top: 16px; }
.ocase-main h2 { font-size: 20px; font-weight: 400; margin: 0 0 16px; }
.ocase .field { margin-bottom: 16px; }
.ocase .field > label { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: block; }
.ocase .field input[type=text], .ocase .field input[type=email], .ocase .field input[type=tel],
.ocase .field input[type=datetime-local], .ocase .field select, .ocase .field textarea {
  border-width: 0 0 1px; border-radius: 0; background: var(--bg); padding: 10px 12px; }
.ocase label.radio { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); margin: 8px 0; cursor: pointer; }
.ocase label.radio input { width: 17px; height: 17px; accent-color: var(--text); margin: 0; }
.ocase label.counter { display: flex; justify-content: space-between; }
.ocase .contact { display: grid; grid-template-columns: 1fr 110px; gap: 16px; }
.ocase-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; border-top: 1px solid var(--line); padding-top: 28px; }
.btn.outline { border-color: var(--accent); color: var(--accent); background: transparent; border-radius: 0; padding: 12px 16px; }
.btn.primary.wide { border-radius: 0; padding: 12px 16px; justify-content: flex-start; }
.ocase-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 20px; }
.side-panel { border-bottom: 1px solid var(--line); padding-bottom: 14px; font-size: 14px; }
.side-panel h3 { font-size: 17px; font-weight: 400; margin: 0 0 10px; }
.side-panel.tips ul { padding-left: 18px; color: var(--muted); }
.side-panel.tips li { margin-bottom: 6px; }
.tpl { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }
.linkbtn:hover { color: var(--danger); }
@media (max-width: 1000px) {
  .ocase { grid-template-columns: 1fr; padding: 16px; }
  .ocase-nav { display: none; }
  .ocase-side { position: static; order: -1; }
}

/* accounts: login pages (IBMid style), user menu, internal notes, customer home */
body.authpage { background: var(--card); display: flex; flex-direction: column; min-height: 100vh; }
.authbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 32px; border-bottom: 1px solid var(--line); }
.authbar .brand { font-weight: 600; font-size: 18px; } .authbar .brand span { font-weight: 400; color: var(--muted); }
.authmain { flex: 1; padding: 40px 16px; }
.authbox { max-width: 430px; margin: 0 0 0 max(16px, calc(50% - 560px)); }
.authbox h1 { font-size: 28px; font-weight: 400; margin: 0 0 6px; }
.authbox h2 { font-size: 20px; font-weight: 400; }
.authbox .muted { color: var(--muted); font-size: 14px; }
.authbox .small { font-size: 13px; }
.authbox label.k { display: block; margin: 22px 0 6px; font-size: 12px; }
.authbox input.big { width: 100%; padding: 12px; border: 0; border-bottom: 1px solid var(--muted); background: var(--bg); font-size: 15px; }
.authbox input.big:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.btn.block { width: 100%; justify-content: space-between; border-radius: 0; padding: 12px 16px; margin-top: 16px; }
.authbox label.radio { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; }
.authbox hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0 12px; }
.authfoot { background: #161616; color: #c6c6c6; font-size: 13px; padding: 14px 32px; }
.lockicon { font-size: 48px; }
.steps li { margin-bottom: 12px; }
.qr svg { display: block; margin: 10px 0; background: #fff; padding: 6px; }
.usermenu { position: relative; }
.usermenu > summary { list-style: none; width: 34px; height: 34px; border-radius: 50%; background: var(--gray-bg); color: var(--gray);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; cursor: pointer; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu .ms-list { width: 260px; left: auto; right: 0; }
.usermenu .ms-list a { display: block; padding: 8px 12px; color: var(--text); font-size: 14px; }
.usermenu .ms-list a:hover { background: var(--bg); text-decoration: none; }
.um-head { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.vis-toggle { display: flex; gap: 18px; margin-bottom: 6px; }
.vis-toggle label.radio { display: flex; gap: 6px; align-items: center; font-size: 14px; cursor: pointer; }
.ev.internal { background: var(--yellow-bg); border-radius: 6px; padding: 10px; }
.addmember { display: flex; gap: 6px; margin-top: 8px; }
.inline { display: inline; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
code.copy { user-select: all; word-break: break-all; }
p.lead { font-size: 30px; font-weight: 300; margin: 0 0 18px; }
.cards3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--card); margin-bottom: 22px; }
.card3 { padding: 16px; border-left: 1px solid var(--line); color: var(--text); display: flex; flex-direction: column; gap: 6px; min-height: 110px; }
.card3:first-child { border-left: 0; }
.card3:hover { background: var(--bg); text-decoration: none; }
.card3 span { color: var(--muted); font-size: 14px; }
@media (max-width: 700px) { .cards3, .grid4 { grid-template-columns: 1fr; } .card3 { border-left: 0; border-top: 1px solid var(--line); } }

/* monospace blocks for commands / logs, solution box */
pre.code { font-family: Consolas, "IBM Plex Mono", Menlo, "DejaVu Sans Mono", monospace; font-size: 13px; line-height: 1.5;
  background: var(--gray-bg); color: var(--text); border-radius: 2px; padding: 12px 14px; margin: 8px 0;
  overflow: auto; max-height: 460px; white-space: pre; tab-size: 8; }
pre.code code { font: inherit; }
.ptext { white-space: pre-wrap; word-break: break-word; }
.clamp { max-height: 18em; }
.clamp .ptext + .ptext { margin-top: 6px; }
.box.sol { border-left: 3px solid #24a148; }
.sol-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sol-clear, .markform { text-align: right; }
.markform .linkbtn { font-size: 12px; color: var(--muted); }
.markform .linkbtn:hover { color: #24a148; }
.note-tools { text-align: right; margin-bottom: 2px; }
.note-tools .linkbtn { font-family: Consolas, "IBM Plex Mono", monospace; font-size: 12px; }
.stockuse { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.stockuse .su-row { display: grid; grid-template-columns: 60px 1fr 1fr; gap: 6px; }

/* app switcher (openticket / openstock / website) */
.appmenu { position: relative; }
.appmenu > summary { list-style: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 6px 8px; border-radius: 8px; color: var(--muted); }
.appmenu > summary::-webkit-details-marker { display: none; }
.appmenu > summary:hover, .appmenu[open] > summary { background: var(--bg); color: var(--text); }
.appmenu .ms-list { width: 280px; left: 0; right: auto; padding: 6px; }
.appmenu .ms-list a { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.appmenu .ms-list a:hover { background: var(--bg); text-decoration: none; }
.appmenu .ms-list a.on { background: var(--blue-bg); }
.appmenu .ms-list a span { font-size: 13px; color: var(--muted); }
.topbar nav a.xapp { color: var(--muted); }
.appmenu > summary::after { content: none !important; }
.usermenu > summary::after { content: none !important; }

/* show / hide password */
.pwwrap { position: relative; }
.pwwrap input.big { padding-right: 46px; }
.pweye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 6px;
  color: var(--muted); cursor: pointer; border-radius: 6px; line-height: 0; }
.pweye:hover, .pweye:focus-visible { color: var(--text); background: var(--line); }
.pweye .x { display: none; }
.pweye.on .x { display: inline; }
