/* thai */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cy_gIfWMuQ5Q.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
/* vietnamese */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cy_gIZmMuQ5Q.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cy_gIZ2MuQ5Q.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cy_gIaWMu.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* thai */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W__XJnvUD7dzB2KdNodVkI.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
/* vietnamese */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W__XJnvUD7dzB2Kb9odVkI.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W__XJnvUD7dzB2KbtodVkI.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W__XJnvUD7dzB2KYNod.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* thai */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Ck_kIfWMuQ5Q.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
/* vietnamese */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Ck_kIZmMuQ5Q.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Ck_kIZ2MuQ5Q.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Ck_kIaWMu.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* thai */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cv_4IfWMuQ5Q.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
/* vietnamese */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cv_4IZmMuQ5Q.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cv_4IZ2MuQ5Q.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2Cv_4IaWMu.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* thai */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2C2_8IfWMuQ5Q.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
/* vietnamese */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2C2_8IZmMuQ5Q.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2C2_8IZ2MuQ5Q.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Prompt';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../assets/fonts/google/prompt_v12_-W_8XJnvUD7dzB2C2_8IaWMu.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =========================================================================
    JS SYSTEM & TECH CO., LTD. theme
   ธีมกลางของทุกหน้าจอ (โหลดเป็นไฟล์สุดท้ายใน index.php)
   ปรับเฉพาะหน้าตา: สี ตัวอักษร ความหนาแน่น ตาราง ฟอร์ม ปุ่ม แท็บ modal
   ไม่แตะ id / class ที่ JS ใช้งาน
   ========================================================================= */

:root {
    /* ค่าจริงมาจากธีม (assets/css/fm-theme.css + สีแบรนด์บริษัท) — ค่าหลัง , คือค่าเดิมเมื่อไม่มีธีม */
    --erp-navy: #0b1b33;
    --erp-primary: var(--fm-pri, #0f766e);
    --erp-primary-600: var(--fm-pri-d, #0d655e);
    --erp-primary-50: var(--fm-pri-50, #e9f3f2);
    --erp-accent: var(--fm-pri-300, #87bbb7);
    --erp-bg: var(--fm-bg, #f3f5f9);
    --erp-surface: var(--fm-surface, #ffffff);
    --erp-surface-2: var(--fm-surface-2, #f8fafc);
    --erp-border: var(--fm-line, #e3e8ef);
    --erp-border-strong: var(--fm-line-3, #cfd7e3);
    --erp-text: var(--fm-ink, #1a2433);
    --erp-text-2: var(--fm-ink-3, #475467);
    --erp-muted: var(--fm-mute, #667085);
    --erp-success: #12b76a;
    --erp-warning: #f79009;
    --erp-danger: #f04438;
    --erp-radius: 8px;
    --erp-radius-sm: 6px;
    --erp-font: 'Noto Sans Thai', 'Prompt', 'Segoe UI', Tahoma, sans-serif;
}

/* ---------- พื้นหลังและตัวอักษร ---------- */
html body {
    background: var(--erp-bg);
    color: var(--erp-text);
    font-family: var(--erp-font);
    font-size: 13.5px;
}

html body .main-menu a,
html body .header-navbar a,
html body .main-menu a:hover,
html body .header-navbar a:hover {
    text-decoration: none;
}

html body .app-content .content-wrapper {
    padding: 1.25rem 1.5rem 2rem;
}

html body h1, html body h2, html body h3, html body h4, html body h5, html body h6 {
    font-family: var(--erp-font);
    color: var(--erp-navy);
}

/* ---------- หัวหน้าจอ (Page header) ---------- */
html body .content-header {
    align-items: center;
    margin-bottom: .75rem;
}

html body .content-header .content-header-left {
    margin-bottom: .5rem !important;
}

html body .content-header-title {
    position: relative;
    padding-left: 14px;
    font-size: 1.25rem !important;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--erp-navy);
}

html body .content-header-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 15%;
    bottom: 15%;
    width: 4px;
    border-radius: 2px;
    background: var(--erp-accent);
}

html body .content-header .breadcrumb-wrapper br {
    display: none;
}

/* ---------- Card = Panel ---------- */
html body .card {
    border: 1px solid var(--erp-border);
    border-radius: 10px;
    box-shadow: none;
    margin-bottom: 1rem;
}

html body .card .card-header {
    padding: .75rem 1.25rem;
    background: var(--erp-surface);
    border-bottom: 1px solid var(--fm-line-2, #eef1f5);
    border-radius: 10px 10px 0 0;
}

html body .card .card-header .card-title,
html body .card .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--erp-navy);
}

html body .card .card-body {
    padding: 1.25rem;
}

/* ---------- แท็บแบบ ERP ---------- */
html body .nav.nav-tabs {
    border-bottom: 1px solid var(--erp-border);
    gap: 2px;
}

html body .nav.nav-tabs .nav-item .nav-link {
    position: relative;
    padding: .6rem 1rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--erp-text-2);
    font-weight: 500;
}

html body .nav.nav-tabs .nav-item .nav-link:hover {
    color: var(--erp-primary);
    background: var(--erp-primary-50);
}

html body .nav.nav-tabs .nav-item .nav-link.active {
    color: var(--erp-primary);
    background: transparent;
    box-shadow: inset 0 -2px 0 var(--erp-primary);
}

/* ---------- ฟอร์ม ---------- */
html body label,
html body .form-group label,
html body .col-form-label {
    margin-bottom: .3rem;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--erp-text-2);
}

html body .form-control,
html body .custom-select,
html body select.form-control {
    height: calc(1.5em + .9rem + 2px);
    padding: .45rem .75rem;
    font-size: 13.5px;
    color: var(--erp-text);
    border: 1px solid var(--erp-border-strong);
    border-radius: var(--erp-radius-sm);
    background-color: var(--fm-surface, #fff);
    transition: border-color .15s, box-shadow .15s;
}

html body textarea.form-control {
    height: auto;
}

html body .form-control:focus,
html body .custom-select:focus {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 3px rgba(var(--fm-pri-rgb, 31, 95, 191), .15);
}

html body .form-control[readonly],
html body .form-control:disabled {
    background-color: var(--erp-surface-2);
    color: var(--erp-text-2);
}

html body .form-control::placeholder {
    color: var(--fm-faint, #98a2b3);
}

html body .form-group {
    margin-bottom: .9rem;
}

html body .input-group-text {
    border-color: var(--erp-border-strong);
    background: var(--erp-surface-2);
    color: var(--erp-text-2);
}

/* ---------- ปุ่ม ---------- */
html body .btn {
    padding: .45rem 1rem;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--erp-radius-sm);
    box-shadow: none !important;
}

html body .btn-sm {
    padding: .25rem .6rem;
    font-size: 12.5px;
}

html body .btn-primary,
html body .btn-info {
    background-color: var(--erp-primary) !important;
    border-color: var(--erp-primary) !important;
    color: #fff !important;
}

html body .btn-primary:hover,
html body .btn-info:hover {
    background-color: var(--erp-primary-600) !important;
    border-color: var(--erp-primary-600) !important;
}

html body .btn-outline-primary,
html body .btn-outline-info {
    color: var(--erp-primary) !important;
    border-color: var(--erp-border-strong) !important;
    background: var(--fm-surface, #fff) !important;
}

html body .btn-outline-primary:hover,
html body .btn-outline-info:hover {
    color: var(--erp-primary) !important;
    border-color: var(--erp-primary) !important;
    background: var(--erp-primary-50) !important;
}

html body .btn-success {
    background-color: var(--erp-success) !important;
    border-color: var(--erp-success) !important;
}

html body .btn-danger {
    background-color: var(--erp-danger) !important;
    border-color: var(--erp-danger) !important;
}

html body .btn-warning {
    background-color: var(--erp-warning) !important;
    border-color: var(--erp-warning) !important;
    color: #fff !important;
}

html body .btn-secondary,
html body .btn-light {
    color: var(--erp-text) !important;
    background: var(--fm-surface, #fff) !important;
    border-color: var(--erp-border-strong) !important;
}

html body .btn-secondary:hover,
html body .btn-light:hover {
    background: var(--erp-surface-2) !important;
}

html body .btn-group > .btn + .btn {
    margin-left: -1px;
}

/* ---------- ตารางข้อมูล ---------- */
html body .table {
    color: var(--erp-text);
    font-size: 13px;
}

html body .table thead th,
html body table.dataTable thead th {
    padding: .6rem .75rem;
    background: var(--erp-surface-2);
    border-top: 0;
    border-bottom: 1px solid var(--erp-border) !important;
    color: var(--erp-text-2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
    vertical-align: middle;
}

html body .table td,
html body table.dataTable tbody td {
    padding: .5rem .75rem;
    border-top: 1px solid var(--fm-line-2, #eef1f5);
    vertical-align: middle;
}

html body .table-bordered,
html body .table-bordered td,
html body .table-bordered th {
    border-color: var(--erp-border) !important;
}

html body .table-striped tbody tr:nth-of-type(odd),
html body table.dataTable.stripe tbody tr.odd {
    background-color: var(--erp-stripe, #fafbfd);
}

html body .table-hover tbody tr:hover,
html body table.dataTable tbody tr:hover {
    background-color: var(--erp-primary-50) !important;
}

html body .table-responsive {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
}

html body .table-responsive > .table {
    margin-bottom: 0;
}

/* ---------- ตารางมาตรฐานเดียวกันทั้งโปรแกรม (แบบตารางรายการใบสั่งขาย) ----------
   ครอบทุกตารางในพื้นที่เนื้อหา (.app-content) รวมถึงตารางที่ใช้ thead-light/thead-dark ของธีมเดิม (หัวเทาน้ำเงิน #98a4b8)
   และตารางที่หน้าต่าง ๆ ตั้งสไตล์เอง — selector มี :not() หลายตัวเพื่อให้ชนะสไตล์เฉพาะหน้าโดยไม่ต้องใช้ !important กับ padding
   ยกเว้น: ปฏิทิน/ตัวเลือกวันที่ (pickadate, datetimepicker, daterangepicker, jQuery UI), easyui treegrid */
html body .app-content table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > thead > tr > th,
html body .modal table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > thead > tr > th {
    padding: var(--erp-th-pad, .65rem .75rem);
    background-color: var(--erp-th-bg, var(--fm-surface-2, #f8fafc)) !important;
    background-image: none;
    color: var(--erp-th-color, #1d2939) !important;
    font-size: var(--erp-th-size, 12.5px) !important;
    font-weight: 600 !important;
    letter-spacing: var(--erp-th-ls, .01em);
    text-transform: var(--erp-th-tt, none);
    white-space: nowrap;
    vertical-align: middle;
    border-top: 0 !important;
    border-bottom: 1px solid var(--erp-border) !important;
    border-left-color: var(--fm-line-2, #eef1f5) !important;
    border-right-color: var(--fm-line-2, #eef1f5) !important;
}

html body .app-content table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > tbody > tr > td,
html body .modal table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > tbody > tr > td {
    color: var(--erp-text);
    font-size: 13px;
    vertical-align: middle;
    border-top: 1px solid var(--fm-line-2, #eef1f5);
    border-left-color: var(--fm-line-2, #eef1f5);
    border-right-color: var(--fm-line-2, #eef1f5);
}

/* แถวสรุป/ท้ายตาราง */
html body .app-content table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar) > tfoot > tr > th,
html body .app-content table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar) > tfoot > tr > td {
    background-color: var(--fm-surface-2, #f8fafc);
    color: var(--erp-navy);
    font-weight: 600;
    border-top: 1px solid var(--erp-border);
}

/* แถวสลับสีและแถวที่เมาส์ชี้ — เหมือนกันทุกตาราง */
html body .app-content .table-striped > tbody > tr:nth-of-type(odd),
html body .app-content table.dataTable.stripe > tbody > tr.odd { background-color: var(--erp-stripe, #fafbfd); }
html body .app-content .table-striped > tbody > tr:nth-of-type(even) { background-color: var(--fm-surface, #fff); }
html body .app-content table.table-hover > tbody > tr:hover,
html body .app-content table.dataTable > tbody > tr:hover { background-color: var(--erp-primary-50) !important; }

/* ลูกศรเรียงลำดับของ DataTables: สีอ่อน ไม่แย่งสายตา ตัวที่กำลังเรียงเป็นสีหลัก */
html body table.dataTable thead .sorting::before, html body table.dataTable thead .sorting::after,
html body table.dataTable thead .sorting_asc::before, html body table.dataTable thead .sorting_asc::after,
html body table.dataTable thead .sorting_desc::before, html body table.dataTable thead .sorting_desc::after { color: var(--fm-faint, #98a2b3); opacity: .55; }
html body table.dataTable thead .sorting_asc::before,
html body table.dataTable thead .sorting_desc::after { color: var(--erp-primary); opacity: 1; }

/* กรอบตาราง: มุมโค้งเมื่อห่อด้วย table-responsive / dataTables_scroll */
html body .app-content .dataTables_wrapper .dataTables_scroll {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    overflow: hidden;
}
html body .app-content .dataTables_wrapper .dataTables_scroll table.dataTable { margin: 0 !important; }

/* DataTables controls */
html body .dataTables_wrapper .dataTables_length select,
html body .dataTables_wrapper .dataTables_filter input {
    height: 32px;
    padding: .25rem .5rem;
    border: 1px solid var(--erp-border-strong);
    border-radius: var(--erp-radius-sm);
    font-size: 13px;
}

html body .dataTables_wrapper .dataTables_info {
    font-size: 12.5px;
    color: var(--erp-muted);
}

html body .dataTables_wrapper .dt-buttons .btn,
html body .dataTables_wrapper .dt-buttons .dt-button {
    padding: .3rem .8rem;
    font-size: 12.5px;
    color: var(--erp-text) !important;
    background: var(--fm-surface, #fff) !important;
    border: 1px solid var(--erp-border-strong) !important;
}

html body .dataTables_wrapper .dt-buttons .btn:hover,
html body .dataTables_wrapper .dt-buttons .dt-button:hover {
    background: var(--erp-surface-2) !important;
}

html body .page-item .page-link {
    margin: 0 2px;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius-sm) !important;
    color: var(--erp-text-2);
    font-size: 12.5px;
}

html body .page-item.active .page-link {
    background-color: var(--erp-primary);
    border-color: var(--erp-primary);
    color: #fff;
}

/* ---------- สถานะ (Badge) ---------- */
html body .badge {
    padding: .3em .7em;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .01em;
}

html body .badge-success { background: #ecfdf3; color: #027a48; box-shadow: inset 0 0 0 1px #abefc6; }
html body .badge-warning { background: #fffaeb; color: #b54708; box-shadow: inset 0 0 0 1px #fedf89; }
html body .badge-danger  { background: #fef3f2; color: #b42318; box-shadow: inset 0 0 0 1px #fecdca; }
html body .badge-info,
html body .badge-primary { background: var(--erp-primary-50); color: var(--erp-primary-600); box-shadow: inset 0 0 0 1px var(--fm-pri-200, #c3d6f2); }
html body .badge-secondary { background: var(--fm-hover, #f2f4f7); color: var(--fm-ink-2, #344054); box-shadow: inset 0 0 0 1px var(--fm-line, #e4e7ec); }

/* ---------- Modal = หน้าต่างเอกสาร ---------- */
html body .modal-content {
    border: 0;
    border-radius: 10px;
    box-shadow: 0 24px 48px -12px rgba(16, 24, 40, .25);
    overflow: hidden;
}

html body .modal-header {
    padding: .9rem 1.15rem;
    background: var(--erp-surface);
    border-bottom: 1px solid var(--erp-border);
}

html body .modal-header .modal-title,
html body .modal-header h1, html body .modal-header h2, html body .modal-header h3,
html body .modal-header h4, html body .modal-header h5 {
    color: var(--erp-text);
    font-size: 1.05rem;
    font-weight: 600;
}

html body .modal-header .close {
    color: var(--erp-text-2);
    opacity: .85;
    text-shadow: none;
}

html body .modal-header .close:hover {
    opacity: 1;
}

html body .modal-body {
    padding: 1.25rem;
}

html body .modal-footer {
    padding: .75rem 1.25rem;
    background: var(--erp-surface-2);
    border-top: 1px solid var(--erp-border);
}

html body .modal-backdrop.show {
    opacity: .45;
}

/* ---------- SweetAlert ---------- */
html body .swal2-popup {
    border-radius: 10px;
    font-family: var(--erp-font);
}

html body .swal2-styled.swal2-confirm {
    background-color: var(--erp-primary) !important;
    border-radius: var(--erp-radius-sm) !important;
}

/* ---------- Dropdown ---------- */
html body .dropdown-menu {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    box-shadow: 0 12px 24px -8px rgba(16, 24, 40, .18);
}

html body .dropdown-item {
    padding: .5rem 1rem;
    font-size: 13px;
}

html body .dropdown-item:hover {
    background: var(--erp-primary-50);
    color: var(--erp-primary);
}

/* ---------- Footer = แถบสถานะ ---------- */
html body footer.erp-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 1.5rem;
    background: var(--fm-surface, #fff);
    border-top: 1px solid var(--erp-border);
    font-size: 12px;
    color: var(--erp-muted);
    white-space: nowrap;
}

html body footer.erp-statusbar .erp-sb-group {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    overflow: hidden;
}

html body footer.erp-statusbar .erp-sb-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

html body footer.erp-statusbar b {
    font-weight: 600;
    color: var(--erp-text);
}

html body footer.erp-statusbar .erp-sb-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--erp-success);
    box-shadow: 0 0 0 3px rgba(18, 183, 106, .15);
}

/* ---------- Scrollbar ---------- */
html body ::-webkit-scrollbar { width: 10px; height: 10px; }
html body ::-webkit-scrollbar-thumb { background: #cfd7e3; border-radius: 6px; border: 2px solid var(--erp-bg); }
html body ::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
    html body .app-content .content-wrapper {
        padding: 1rem .75rem 1.5rem;
    }

    html body .card .card-body {
        padding: 1rem;
    }

    html body footer.erp-statusbar .erp-sb-hide-sm {
        display: none;
    }
}

/* ---------- DataTables: กว้างเต็มกรอบ ----------
   components.css ตั้ง .dataTables_wrapper table{display:block} เมื่อจอ <= 1500px (เพื่อเลื่อนแนวนอน)
   ทำให้ตารางไม่ยืดเต็มกรอบ เหลือช่องว่างด้านขวา
   - ตารางที่ใช้ Responsive (dtr-*) ซ่อนคอลัมน์ที่ไม่พอที่เองอยู่แล้ว → display:table
   - ตารางอื่น: app/wh_menu/nt-paging.js ครอบด้วย .nt-dt-scroll (กล่องเลื่อนแนวนอนแทนตัวตาราง) → display:table ได้เช่นกัน */
html body .dataTables_wrapper .nt-dt-scroll {
    width: 100%;
    overflow-x: auto;
}

html body .dataTables_wrapper table.dataTable.dtr-column,
html body .dataTables_wrapper table.dataTable.dtr-inline,
html body .dataTables_wrapper .nt-dt-scroll > table.dataTable {
    display: table;
    width: 100% !important;
}

/* Sidebar presentation. Widths and responsive behavior remain owned by the theme. */
html body .main-menu.menu-dark {
    /* Friendly Me shell: แถบเมนูพื้นขาว แยกจากพื้นที่ทำงาน (#f3f5f9) ด้วยเส้น 1px */
    --sb-bg: var(--fm-surface, #ffffff);
    --sb-text: var(--fm-ink-2, #344054);
    --sb-strong: var(--fm-ink, #101828);
    --sb-muted: var(--fm-mute, #667085);
    --sb-faint: var(--fm-faint, #98a2b3);
    --sb-hover: var(--fm-hover, #f2f4f7);
    --sb-line: var(--fm-line, #e3e8ef);
    --sb-accent: var(--fm-pri, #0f766e);
    --sb-active-bg: var(--fm-pri-50, #e9f3f2);
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-line);
    box-shadow: none;
    font-family: 'Prompt', 'Segoe UI', Tahoma, sans-serif;
}

html body .main-menu.menu-dark .main-menu-content {
    padding: 0 0 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--fm-line-3, #d0d5dd) transparent;
}

html body .main-menu.menu-dark .navigation {
    padding-top: 6px;
    background: transparent;
    font-family: inherit;
}

/* Workspace heading and search share the same alignment as the navigation. */
.nt-sidebar-tools {
    margin: 0 12px 4px;
    padding: 14px 0 12px;
    border-bottom: 1px solid var(--sb-line);
}

/* หัวข้อ "WORKSPACE / เมนูการทำงาน" ซ้ำกับตัวแถบเมนูเอง — ซ่อนไว้ ให้ช่องค้นหาขึ้นบนสุด */
html body .main-menu .nt-sidebar-tools .nt-sidebar-heading {
    display: none;
}

.nt-sidebar-heading {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 17px;
}

.nt-sidebar-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    height: 34px;
    border: 1px solid var(--fm-pri-200, #c3dddb);
    border-radius: 10px;
    background: var(--fm-pri-50, #e9f3f2);
    color: var(--fm-pri-300, #87bbb7);
    font-size: 17px;
}

.nt-sidebar-heading-text {
    min-width: 0;
}

.nt-sidebar-eyebrow,
.nt-sidebar-title {
    display: block;
}

.nt-sidebar-eyebrow {
    margin-bottom: 3px;
    color: var(--sb-muted);
    font-size: 9px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: .16em;
}

.nt-sidebar-title {
    color: var(--fm-ink, #f1f5fb);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.nt-sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--fm-line-3, #d0d5dd);
    border-radius: 8px;
    background: var(--fm-surface, #fff);
    color: var(--sb-muted);
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.nt-sidebar-search:hover {
    border-color: var(--fm-line-3, #b8c3d3);
}

.nt-sidebar-search:focus-within {
    border-color: var(--sb-accent);
    background: var(--fm-surface, #fff);
    box-shadow: 0 0 0 3px rgba(var(--fm-pri-rgb, 15, 118, 110), .14);
}

.nt-sidebar-search > i {
    flex: 0 0 auto;
    font-size: 15px;
}

html body .main-menu .nt-sidebar-search input {
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0;
    border: 0;
    outline: 0;
    box-shadow: none;
    background: transparent;
    color: var(--sb-strong);
    font: inherit;
    font-size: 13px;
    appearance: none;
}

.nt-sidebar-search input::placeholder {
    color: var(--sb-muted);
    opacity: 1;
}

.nt-sidebar-search input::-webkit-search-cancel-button {
    appearance: none;
}

.nt-sidebar-search button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 26px;
    height: 28px;
    margin-right: -5px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--sb-muted);
    cursor: pointer;
}

.nt-sidebar-search button:hover {
    background: var(--sb-hover);
    color: var(--sb-strong);
}

.nt-sidebar-search button[hidden],
.nt-sidebar-empty[hidden] {
    display: none;
}

/* Section labels stay intact so saved layouts and permission identifiers work. */
html body .main-menu.menu-dark .navigation .navigation-header.nt-foldable {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    margin: 6px 8px 2px;
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--fm-ink-3, #475467);
    font-size: 12.5px;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    user-select: none;
    transition: color .15s, background .15s;
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-foldable:hover {
    background: var(--sb-hover);
    color: var(--sb-strong);
}

html body .main-menu.menu-dark .navigation .navigation-header .nt-sec-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--sb-faint);
    font-size: 16px;
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-foldable > span {
    position: relative;
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 15px;
    font-size: 13px;
    font-weight: 500;
    white-space: normal;
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-foldable > span::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 2px;
    width: 5px;
    height: 5px;
    margin-top: -4px;
    border-right: 1.5px solid var(--sb-faint);
    border-bottom: 1.5px solid var(--sb-faint);
    transform: rotate(45deg);
    transition: transform .15s;
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-folded > span::after {
    margin-top: -3px;
    transform: rotate(-45deg);
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-section-active {
    color: var(--sb-strong);
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-section-active .nt-sec-ic {
    color: var(--sb-accent);
}

html body .main-menu.menu-dark .navigation > li.nt-fold-hide {
    display: none !important;
}

/* Rows use a stable icon column and give long Thai labels room to wrap. */
html body .main-menu.menu-dark .navigation > li,
html body .main-menu.menu-dark .navigation > li.open,
html body .main-menu.menu-dark .navigation li.active {
    border-left: 0;
    background: transparent;
}

html body .main-menu.menu-dark .navigation > li > a {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 36px;
    margin: 1px 8px 1px 18px;
    padding: 7px 10px !important;
    border-radius: 6px;
    color: var(--sb-text);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    transition: background .15s, color .15s;
}

html body .main-menu.menu-dark .navigation > li > a > i {
    top: 0;
    flex: 0 0 18px;
    width: 18px;
    margin: 0 10px 0 0;
    color: var(--sb-muted);
    font-size: 16px;
    text-align: center;
}

html body .main-menu.menu-dark .navigation > li > a > i::before {
    font-size: inherit;
}

html body .main-menu.menu-dark .navigation .menu-title {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
}

html body .main-menu.menu-dark .navigation > li:hover > a,
html body .main-menu.menu-dark .navigation > li.hover > a,
html body .main-menu.menu-dark .navigation > li.open > a {
    background: var(--sb-hover);
    color: var(--sb-strong);
}

html body .main-menu.menu-dark .navigation > li.active:not(.has-sub) > a {
    background: var(--sb-active-bg);
    color: var(--sb-accent);
    font-weight: 500;
    box-shadow: none;
}

html body .main-menu.menu-dark .navigation > li:hover > a > i,
html body .main-menu.menu-dark .navigation > li.open > a > i {
    color: var(--sb-text);
}

html body .main-menu.menu-dark .navigation > li.active > a > i {
    color: var(--sb-accent);
}

/* รหัสเมนู (CUS, CRM ...) ยังอยู่ใน DOM ให้ช่องค้นหาเมนูหาเจอ แต่ไม่แสดงเป็นป้าย */
html body .main-menu.menu-dark .navigation .erp-code {
    display: none;
}

html body .main-menu.menu-dark .navigation li.has-sub > a {
    padding-right: 25px !important;
}

html body .main-menu.menu-dark .navigation li.has-sub > a::after {
    top: 50% !important;
    right: 12px !important;
    margin-top: -9px;
    color: var(--sb-muted);
}

/* Nested groups retain the theme's accordion behavior. */
html body .main-menu.menu-dark .navigation > li .menu-content {
    position: relative;
    margin: 5px 0 8px;
    background: transparent;
}

html body .main-menu.menu-dark .navigation > li .menu-content::before {
    content: '';
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 37px;
    width: 1px;
    background: var(--sb-line);
}

html body .main-menu.menu-dark .navigation > li .menu-content li > a,
html body .main-menu.menu-dark .navigation > li.open .menu-content li > a,
html body .main-menu.menu-dark .navigation > li.open .menu-content li.active > a {
    display: block;
    margin: 1px 8px 1px 56px;
    padding: 6px 10px !important;
    border-radius: 6px;
    background: transparent;
    color: var(--sb-text);
    font-size: 13px;
    line-height: 1.5;
    white-space: normal;
}

html body .main-menu.menu-dark .navigation > li .menu-content li > a:hover {
    background: var(--sb-hover);
    color: var(--sb-strong);
}

html body .main-menu.menu-dark .navigation > li .menu-content li.active > a {
    background: var(--sb-active-bg);
    color: var(--sb-accent);
    font-weight: 500;
    box-shadow: none;
}

html body .main-menu.menu-dark .navigation a:focus-visible,
html body .main-menu.menu-dark .navigation .navigation-header:focus-visible,
.nt-sidebar-search button:focus-visible {
    outline: 2px solid var(--sb-accent);
    outline-offset: -2px;
}

/* Search reveals matching rows without changing the user's saved folds. */
html body .main-menu.menu-dark.nt-menu-searching .navigation > li.nt-fold-hide:not(.nt-search-hide) {
    display: block !important;
}

html body .main-menu.menu-dark.nt-menu-searching .navigation .menu-content {
    display: block !important;
}

html body .main-menu.menu-dark.nt-menu-searching .navigation li.nt-search-hide {
    display: none !important;
}

html body .main-menu.menu-dark.nt-menu-searching .navigation .navigation-header > span::after {
    margin-top: -4px;
    transform: rotate(45deg);
}

html body .main-menu.menu-dark.nt-menu-searching .navigation .navigation-header {
    cursor: default;
}

.nt-sidebar-empty {
    padding: 30px 15px;
    color: var(--sb-text);
    text-align: center;
}

.nt-sidebar-empty > i,
.nt-sidebar-empty > span,
.nt-sidebar-empty > small {
    display: block;
}

.nt-sidebar-empty > i {
    margin-bottom: 12px;
    color: var(--sb-muted);
    font-size: 23px;
}

.nt-sidebar-empty > span {
    font-size: 12px;
}

.nt-sidebar-empty > small {
    margin-top: 6px;
    color: var(--sb-muted);
    font-size: 10px;
}

/* The 60px rail expands on hover through the existing menu controller. */
body.menu-collapsed .main-menu.menu-dark:not(.expanded) .nt-sidebar-tools {
    margin: 0 8px 8px;
    padding: 16px 0 12px;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .nt-sidebar-heading {
    justify-content: center;
    margin: 0;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .nt-sidebar-heading-text,
body.menu-collapsed .main-menu.menu-dark:not(.expanded) .nt-sidebar-search,
body.menu-collapsed .main-menu.menu-dark:not(.expanded) .nt-sidebar-empty,
body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation .erp-code,
body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation > li > a > .menu-title,
body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation .navigation-header > span,
body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation .navigation-header .nt-sec-ic {
    display: none;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation > li.nt-fold-hide:not(.nt-search-hide) {
    display: block !important;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation > li .menu-content {
    display: none !important;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation > li > a {
    justify-content: center;
    min-height: 40px;
    margin: 3px 8px;
    padding: 10px 0 !important;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation > li > a > i {
    margin: 0;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation .navigation-header.nt-foldable {
    justify-content: center;
    min-height: 12px;
    margin: 8px 18px;
    padding: 0;
}

body.menu-collapsed .main-menu.menu-dark:not(.expanded) .navigation .navigation-header .feather.icon-minus {
    color: var(--fm-faint, #c0c8d4);
    font-size: 12px;
}

html body .main-menu.menu-dark .main-menu-content::-webkit-scrollbar {
    width: 5px;
}

html body .main-menu.menu-dark .main-menu-content::-webkit-scrollbar-thumb,
html body .main-menu.menu-dark .ps__thumb-y {
    border-radius: 4px;
    background: var(--fm-line-3, #d0d5dd);
}

@media (prefers-reduced-motion: reduce) {
    html body .main-menu.menu-dark .navigation *,
    .nt-sidebar-search {
        animation: none !important;
        transition: none !important;
    }
}

/* =========================================================================
   Friendly Me — หน้าแรก (สรุปงานวันนี้)
   ใช้ตัวแปรสีจาก erp-theme.css (--erp-*) · แผงสีขาว เส้นขอบ 1px ไม่มีเงา
   ========================================================================= */

.fmh {
    --fmh-ink: var(--erp-text, #1a2433);
    --fmh-ink-2: var(--erp-text-2, #475467);
    --fmh-mute: var(--erp-muted, #667085);
    --fmh-line: var(--erp-border, #e3e8ef);
    --fmh-line-2: #eef1f5;
    --fmh-pri: var(--erp-primary, var(--fm-pri, #0f766e));
    --fmh-pri-d: var(--erp-primary-600, var(--fm-pri-d, #0d655e));
    --fmh-pri-50: var(--erp-primary-50, #e9f3f2);
    --fmh-green: #067647;
    --fmh-red: #b42318;
    --fmh-amber: #b54708;
    color: var(--fmh-ink);
    padding: 4px 0 28px;
    font-variant-numeric: tabular-nums;
}
.fmh ::selection { background: var(--fm-pri-200, #c3dddb); color: var(--fmh-ink); }
.fmh a { color: inherit; text-decoration: none; }
.fmh .fmh-muted { color: var(--fmh-mute); font-weight: 400; }

/* ---------- หัวหน้า ---------- */
.fmh-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.fmh-title h1 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 0; color: var(--fmh-ink); letter-spacing: -.01em; }
.fmh-title p { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0 0; font-size: 13px; color: var(--fmh-ink-2); }
.fmh-dot { width: 3px; height: 3px; border-radius: 50%; background: #98a2b3; }

.fmh-search { position: relative; flex: 0 1 340px; }
.fmh-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--fmh-mute); font-size: 15px; pointer-events: none; }
.fmh-search input { width: 100%; height: 38px; padding: 0 36px 0 36px; border: 1px solid var(--erp-border-strong, var(--fm-line-3, #cfd7e3)); border-radius: 8px;
                    background: var(--fm-surface, #fff); font: inherit; font-size: 14px; color: var(--fmh-ink); outline: none; transition: border-color .15s, box-shadow .15s; }
.fmh-search input::placeholder { color: #8a94a6; }
.fmh-search input:hover { border-color: #b8c3d3; }
.fmh-search input:focus { border-color: var(--fmh-pri); box-shadow: 0 0 0 3px rgba(var(--fm-pri-rgb, 31, 95, 191), .14); }
.fmh-search input::-webkit-search-cancel-button { display: none; }
.fmh-search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font: 600 11px/1 inherit; color: var(--fmh-mute);
                  background: var(--fm-hover, #f2f4f7); border: 1px solid var(--fmh-line); border-radius: 4px; padding: 3px 6px; box-shadow: none; }
.fmh-search input:focus ~ kbd { display: none; }
.fmh-results { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; background: var(--fm-surface, #fff); border: 1px solid var(--fmh-line);
               border-radius: 10px; padding: 6px; box-shadow: 0 12px 28px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .08); }
.fmh-hit { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.fmh-hit i { color: var(--fmh-mute); font-size: 15px; width: 16px; }
.fmh-hit span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmh-hit small { font-size: 12px; color: var(--fmh-mute); white-space: nowrap; }
.fmh-hit:hover, .fmh-hit.is-cur { background: var(--fmh-pri-50); }
.fmh-hit.is-cur i, .fmh-hit:hover i { color: var(--fmh-pri); }
.fmh-nohit { padding: 10px; font-size: 13px; color: var(--fmh-mute); }

/* ---------- โครง ---------- */
.fmh-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.fmh-grid.fmh-solo { grid-template-columns: minmax(0, 720px); }
.fmh-col { display: grid; gap: 16px; min-width: 0; }

.fmh-panel { background: var(--fm-surface, #fff); border: 1px solid var(--fmh-line); border-radius: 10px; min-width: 0; }
.fmh-ph { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px 11px; border-bottom: 1px solid var(--fmh-line-2); }
.fmh-ph h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 600; color: var(--fmh-ink); line-height: 1.4; }
.fmh-more { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 500; color: var(--fmh-pri) !important;
            border-radius: 6px; padding: 2px 4px; margin-right: -4px; white-space: nowrap; }
.fmh-more i { font-size: 14px; transition: transform .15s; }
.fmh-more:hover { background: var(--fmh-pri-50); }
.fmh-more:hover i { transform: translateX(2px); }
.fmh-count { font-size: 12px; font-weight: 600; color: #fff; background: var(--fmh-red); border-radius: 99px; min-width: 22px; height: 20px;
             line-height: 20px; padding: 0 7px; text-align: center; }

/* ---------- ยอดขาย ---------- */
.fmh-sales { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 8px 24px; padding: 16px 16px 14px; }
.fmh-l, .fmh-dl dt { display: block; font-size: 12.5px; color: var(--fmh-mute); font-weight: 400; }
.fmh-big b { display: block; font-size: 32px; font-weight: 600; line-height: 1.2; letter-spacing: -.015em; color: var(--fmh-ink); margin: 2px 0 2px; min-height: 38px; }
.fmh-big b small, .fmh-dl dd small { font-size: .55em; font-weight: 500; color: var(--fmh-mute); letter-spacing: 0; }
.fmh-delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; min-height: 18px; }
.fmh-delta i { font-size: 14px; }
.fmh-delta.up { color: var(--fmh-green); }
.fmh-delta.down { color: var(--fmh-red); }
.fmh-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--fmh-line-2); }
.fmh-dl > div:last-child { grid-column: 1 / -1; }
.fmh-dl dd { margin: 1px 0 0; font-size: 16px; font-weight: 600; color: var(--fmh-ink); min-height: 22px; }
.fmh-dl .fmh-delta { font-size: 12px; }

.fmh-chart { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; min-height: 196px; }
.fmh-axis { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 22px; font-size: 11px; color: var(--fmh-mute); text-align: right; }
.fmh-axis span { line-height: 1; transform: translateY(-50%); }
.fmh-axis span:last-child { transform: translateY(50%); }
.fmh-bars { position: relative; display: flex; align-items: stretch; gap: 6px; padding-bottom: 22px;
            background: linear-gradient(var(--fmh-line-2), var(--fmh-line-2)) 0 0 / 100% 1px no-repeat,
                        linear-gradient(var(--fmh-line-2), var(--fmh-line-2)) 0 calc(50% - 11px) / 100% 1px no-repeat,
                        linear-gradient(var(--fmh-line), var(--fmh-line)) 0 calc(100% - 22px) / 100% 1px no-repeat; }
.fmh-bar { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; cursor: default; }
.fmh-bar i { display: block; background: var(--fm-pri-200, #b9cff0); border-radius: 3px 3px 0 0; transition: background .15s; }
.fmh-bar:hover i { background: var(--fm-pri-300, #8fb2e6); }
.fmh-bar.is-today i { background: var(--fmh-pri); }
.fmh-bar span { position: absolute; left: 50%; bottom: -21px; transform: translateX(-50%); font-size: 11px; line-height: 18px; color: var(--fmh-mute); white-space: nowrap; }
.fmh-bar.is-wk span { color: var(--fm-faint, #98a2b3); }
.fmh-bar.is-today span { color: var(--fmh-pri); font-weight: 600; }
.fmh-bar:focus-visible { outline: 2px solid var(--fmh-pri); outline-offset: 2px; border-radius: 3px; }
.fmh-tip { position: absolute; z-index: 5; top: 0; left: 50%; transform: translate(-50%, 4px); display: flex; flex-direction: column; gap: 1px;
           padding: 7px 10px; border-radius: 6px; background: #101828; color: #fff; font-style: normal; white-space: nowrap; pointer-events: none;
           box-shadow: 0 8px 16px -6px rgba(16, 24, 40, .35); opacity: 0; transition: opacity .12s, transform .12s; }
.fmh-tip small { font-size: 11.5px; color: #c4cbd6; line-height: 1.35; }
.fmh-tip b { font-size: 14px; font-weight: 600; line-height: 1.3; }
.fmh-bar:nth-child(-n+3) .fmh-tip { left: 0; transform: translate(0, 4px); }
.fmh-bar.tip-l .fmh-tip { left: auto; right: 0; transform: translate(0, 4px); }
.fmh-bar:hover .fmh-tip, .fmh-bar:focus-visible .fmh-tip { opacity: 1; transform: translate(-50%, 0); }
.fmh-bar:nth-child(-n+3):hover .fmh-tip, .fmh-bar:nth-child(-n+3):focus-visible .fmh-tip,
.fmh-bar.tip-l:hover .fmh-tip, .fmh-bar.tip-l:focus-visible .fmh-tip { transform: translate(0, 0); }

/* ---------- รายการ (อนุมัติ / สินค้าใกล้หมด) ---------- */
.fmh-list { padding: 4px 0; }
.fmh-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--fmh-line-2); min-height: 56px; }
.fmh-row:first-child { border-top: 0; }
a.fmh-row { transition: background .12s; }
a.fmh-row:hover { background: var(--fm-surface-2, #f8fafc); }
.fmh-rt { flex: 1; min-width: 0; }
.fmh-rt b, .fmh-rt > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmh-rt b { font-size: 13.5px; font-weight: 500; color: var(--fmh-ink); }
.fmh-rt > span { font-size: 12px; color: var(--fmh-mute); margin-top: 1px; }
.fmh-rv { text-align: right; white-space: nowrap; }
.fmh-rv b { display: block; font-size: 13.5px; font-weight: 600; color: var(--fmh-ink); }
.fmh-rv span { display: block; font-size: 12px; color: var(--fmh-mute); }
.fmh-type { flex: 0 0 76px; font-size: 11.5px; font-weight: 500; color: var(--fmh-ink-2); background: var(--fm-hover, #f2f4f7); border-radius: 5px; padding: 2px 6px;
            text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmh-rest { display: block; padding: 10px 16px; border-top: 1px solid var(--fmh-line-2); font-size: 13px; font-weight: 500; color: var(--fmh-pri) !important; text-align: center; }
.fmh-rest:hover { background: var(--fmh-pri-50); }

.fmh-sub { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 2px; }
.fmh-tag { font-size: 12px; font-weight: 500; border-radius: 5px; padding: 2px 8px; }
.fmh-tag.is-red { color: var(--fmh-red); background: #fef3f2; }
.fmh-tag.is-amber { color: var(--fmh-amber); background: #fffaeb; }
.fmh-qty { text-align: right; white-space: nowrap; font-size: 12px; color: var(--fmh-mute); }
.fmh-qty b { font-size: 15px; font-weight: 600; margin-right: 3px; }
.fmh-qty.is-red b { color: var(--fmh-red); }
.fmh-qty.is-amber b { color: var(--fmh-amber); }

/* ---------- ออเดอร์ (ขั้นตอนต่อกัน) ---------- */
/* แถบขั้นตอนเดียว แบ่งช่องด้วยเส้นบาง (ไม่ซ้อนการ์ดในแผง) */
.fmh-flow { display: flex; align-items: stretch; }
.fmh-step { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 14px 16px;
            border-left: 1px solid var(--fmh-line-2); transition: background .15s; }
.fmh-step:first-of-type { border-left: 0; }
a.fmh-step[href]:hover { background: var(--fm-surface-2, #f8fafc); }
a.fmh-step[href]:hover span { color: var(--fmh-pri); }
.fmh-step span { font-size: 12.5px; color: var(--fmh-ink-2); line-height: 1.35; }
.fmh-step b { font-size: 24px; font-weight: 600; line-height: 1.1; color: var(--fmh-ink); min-height: 26px; }
.fmh-step.is-zero b { color: var(--fm-faint, #98a2b3); }
.fmh-arrow { position: relative; z-index: 1; align-self: center; flex: 0 0 0; width: 0; color: #b8c3d3; font-size: 14px; transform: translateX(-7px);
             background: var(--fm-surface, #fff); border-radius: 50%; }
.fmh-note { display: flex; align-items: center; gap: 6px; margin: 0 16px 14px; padding: 8px 12px; border-radius: 8px; background: #fffaeb;
            color: var(--fmh-amber) !important; font-size: 13px; border: 1px solid #fedf89; }
.fmh-note b { font-weight: 600; }
.fmh-note .fmh-muted { margin-left: auto; color: var(--fmh-amber); text-decoration: underline; text-underline-offset: 3px; }
.fmh-note[hidden] { display: none; }

/* ---------- ทางลัด ---------- */
.fmh-links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 12px; }
.fmh-link { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent;
            font-size: 13.5px; color: var(--fmh-ink); line-height: 1.3; transition: background .12s, border-color .12s; }
.fmh-link i { flex: 0 0 auto; font-size: 16px; color: var(--fmh-pri); }
.fmh-link > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fmh-link:hover { background: var(--fm-surface-2, #f8fafc); border-color: var(--fmh-line); }
.fmh-link .nw { display: inline; white-space: nowrap; }

/* ---------- สถานะว่าง / ผิดพลาด / กำลังโหลด ---------- */
.fmh-empty { display: flex; align-items: center; gap: 12px; padding: 18px 16px; }
.fmh-empty > i { flex: 0 0 auto; font-size: 20px; color: var(--fmh-green); }
.fmh-empty.is-err > i { color: var(--fmh-red); }
.fmh-empty.is-info > i { color: var(--fmh-mute); }
.fmh-empty > div { flex: 1; min-width: 0; }
.fmh-empty b { display: block; font-size: 13.5px; font-weight: 500; color: var(--fmh-ink); }
.fmh-empty span { display: block; font-size: 12.5px; color: var(--fmh-mute); margin-top: 1px; }
.fmh-btn { flex: 0 0 auto; height: 32px; padding: 0 12px; border: 1px solid var(--erp-border-strong, var(--fm-line-3, #cfd7e3)); border-radius: 6px; background: var(--fm-surface, #fff);
           font: inherit; font-size: 13px; font-weight: 500; color: var(--fmh-ink); cursor: pointer; display: inline-flex; align-items: center; text-decoration: none; }
.fmh-empty .fmh-btn { margin-top: 8px; }
.fmh-btn:hover { background: var(--fm-surface-2, #f8fafc); }
.fmh-skel { display: grid; gap: 10px; padding: 14px 16px; width: 100%; align-self: start; }
.fmh-chart > .fmh-skel { grid-column: 1 / -1; }
.fmh-skel i { display: block; height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--fm-hover, #f2f4f7) 0%, #e8ecf1 50%, var(--fm-hover, #f2f4f7) 100%) 0 0 / 200% 100%;
              animation: fmhShimmer 1.3s ease-in-out infinite; }
.fmh-skel i:nth-child(2) { width: 82%; }
.fmh-skel i:nth-child(3) { width: 64%; }
@keyframes fmhShimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.fmh a:focus-visible, .fmh button:focus-visible, .fmh-search input:focus-visible { outline: 2px solid var(--fmh-pri); outline-offset: 2px; }
.fmh-search input:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
    .fmh-skel i { animation: none; }
    .fmh *, .fmh *::before { transition: none !important; }
}

/* ---------- จอแคบ ---------- */
@media (max-width: 1199.98px) {
    .fmh-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
    .fmh-head { flex-direction: column; align-items: stretch; }
    .fmh-search { flex-basis: auto; }
    .fmh-sales { grid-template-columns: minmax(0, 1fr); }
    .fmh-chart { min-height: 170px; }
    .fmh-flow { display: grid; grid-template-columns: 1fr 1fr; }
    .fmh-arrow { display: none; }
    .fmh-step:nth-of-type(odd) { border-left: 0; }
    .fmh-step:nth-of-type(n+3) { border-top: 1px solid var(--fmh-line-2); }
    .fmh-dot { display: none; }
    .fmh-title p { flex-direction: column; align-items: flex-start; gap: 2px; }
    .fmh-type { flex-basis: 60px; }
    .fmh-rt .nw { display: inline; white-space: nowrap; }
    .fmh-rt b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
@media (max-width: 420px) {
    .fmh-links { grid-template-columns: 1fr; }
    .fmh-bars { gap: 3px; }
    .fmh-bar:not(.is-today):nth-child(odd) span { visibility: hidden; }
}

/*
 * ธีมของระบบ Friendly Me (DESIGN.md)
 * - สีหลัก: --fm-pri-base มาจาก (1) สีส่วนตัวของผู้ใช้ html[data-accent] (2) สีแบรนด์บริษัท <style id="fm-brand"> (3) ค่าเริ่มต้นด้านล่าง
 * - โหมด: html[data-mode="dark"] สลับชุดสีพื้น/ตัวอักษร/เส้น
 * ไฟล์ CSS อื่นเรียกใช้ผ่าน var(--fm-*, ค่าเดิม) จึงหน้าตาเหมือนเดิมเมื่อไม่มีธีม
 * โหลดเป็นไฟล์ CSS สุดท้ายใน index.php
 */

/* ---------- ค่าเริ่มต้น (Navy · Slate · White · Teal / โหมดสว่าง) ---------- */
:root {
    /* แบรนด์: Teal เป็นสีทำงานหลัก, Navy สำหรับหัวเรื่อง/พื้นที่เข้ม, Slate สำหรับตัวอักษรรอง */
    --fm-teal: #0f766e;
    --fm-navy: #0b1b33;
    --fm-navy-2: #132846;
    --fm-slate: #475467;

    --fm-pri-base: #0f766e;
    --fm-pri: #0f766e;
    --fm-pri-d: #0d655e;
    --fm-pri-50: #e9f3f2;
    --fm-pri-200: #c3dddb;
    --fm-pri-300: #87bbb7;
    --fm-pri-rgb: 15, 118, 110;

    --fm-bg: #f3f5f9;
    --fm-surface: #ffffff;
    --fm-surface-2: #f8fafc;
    --fm-hover: #f2f4f7;
    --fm-ink: #101828;
    --fm-ink-2: #344054;
    --fm-ink-3: #475467;
    --fm-mute: #667085;
    --fm-faint: #98a2b3;
    --fm-line: #e3e8ef;
    --fm-line-2: #eef1f5;
    --fm-line-3: #cfd7e3;
    --fm-focus: rgba(var(--fm-pri-rgb), .18);

    /* สถานะ (ใช้เฉพาะการรายงานสถานะ) */
    --fm-ok: #067647;
    --fm-ok-bg: #ecfdf3;
    --fm-ok-line: #abefc6;
    --fm-warn: #b54708;
    --fm-warn-bg: #fffaeb;
    --fm-warn-line: #fedf89;
    --fm-bad: #b42318;
    --fm-bad-bg: #fef3f2;
    --fm-bad-line: #fecdca;
    --fm-info: #0e7090;
    --fm-info-bg: #ecf6fa;
    --fm-info-line: #c8e6ef;
}

/* ---------- สีหลักสำเร็จรูป (ผู้ใช้เลือกเอง) ---------- */
html[data-accent="teal"] {
    --fm-pri-base: #0f766e; --fm-pri: #0f766e; --fm-pri-d: #0d655e; --fm-pri-50: #e9f3f2; --fm-pri-200: #c3dddb; --fm-pri-300: #87bbb7; --fm-pri-rgb: 15, 118, 110;
}
html[data-accent="navy"] {
    --fm-pri-base: #1e3a5f; --fm-pri: #1e3a5f; --fm-pri-d: #172c49; --fm-pri-50: #eef2f7; --fm-pri-200: #cdd8e6; --fm-pri-300: #9db1c9; --fm-pri-rgb: 30, 58, 95;
}
html[data-accent="blue"] {
    --fm-pri-base: #1f5fbf; --fm-pri: #1f5fbf; --fm-pri-d: #1a52a6; --fm-pri-50: #eaf1fb; --fm-pri-200: #c9d9f2; --fm-pri-300: #8fb2e6; --fm-pri-rgb: 31, 95, 191;
}
html[data-accent="green"] {
    --fm-pri-base: #0f7b5f; --fm-pri: #0f7b5f; --fm-pri-d: #0d6851; --fm-pri-50: #e8f4f0; --fm-pri-200: #c3ded7; --fm-pri-300: #87bdaf; --fm-pri-rgb: 15, 123, 95;
}
html[data-accent="violet"] {
    --fm-pri-base: #6941c6; --fm-pri: #6941c6; --fm-pri-d: #5937a8; --fm-pri-50: #f1ecfa; --fm-pri-200: #dad0f1; --fm-pri-300: #b4a0e3; --fm-pri-rgb: 105, 65, 198;
}
html[data-accent="graphite"] {
    --fm-pri-base: #344054; --fm-pri: #344054; --fm-pri-d: #1d2939; --fm-pri-50: #eef0f3; --fm-pri-200: #cdd0d5; --fm-pri-300: #9aa0aa; --fm-pri-rgb: 52, 64, 84;
}

/* ---------- โหมดมืด ---------- */
html[data-mode="dark"] {
    color-scheme: dark;
    --fm-bg: #0b1220;
    --fm-surface: #111a2a;
    --fm-surface-2: #162235;
    --fm-hover: #1d2b40;
    --fm-ink: #e8eef6;
    --fm-ink-2: #cfd8e5;
    --fm-ink-3: #b3bfd0;
    --fm-mute: #8b98ab;
    --fm-faint: #69778b;
    --fm-line: #26344a;
    --fm-line-2: #1e2a3c;
    --fm-line-3: #35455e;
    --fm-ok: #4ade9b;
    --fm-ok-bg: rgba(18, 183, 106, .14);
    --fm-ok-line: rgba(18, 183, 106, .35);
    --fm-warn: #fdb357;
    --fm-warn-bg: rgba(247, 144, 9, .14);
    --fm-warn-line: rgba(247, 144, 9, .35);
    --fm-bad: #f97066;
    --fm-bad-bg: rgba(240, 68, 56, .14);
    --fm-bad-line: rgba(240, 68, 56, .35);
    --fm-info: #67d3f0;
    --fm-info-bg: rgba(14, 112, 144, .18);
    --fm-info-line: rgba(14, 112, 144, .4);
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
    /* สีหลักในโหมดมืด: สว่างขึ้นเล็กน้อยให้อ่านบนพื้นเข้มได้ / พื้นอ่อนของสีหลักกลายเป็นพื้นเข้มอมสี */
    html[data-mode="dark"] {
        --fm-pri: color-mix(in srgb, var(--fm-pri-base) 78%, #ffffff);
        --fm-pri-d: var(--fm-pri-base);
        --fm-pri-50: color-mix(in srgb, var(--fm-pri-base) 22%, #111a2a);
        --fm-pri-200: color-mix(in srgb, var(--fm-pri-base) 45%, #111a2a);
        --fm-pri-300: color-mix(in srgb, var(--fm-pri-base) 70%, #111a2a);
        --fm-navy: #e8eef6;
    }
}

/* ตัวแปรของแต่ละส่วนที่ตั้งค่าคงที่ไว้ (เมนูซ้ายกำหนดไว้ที่ .main-menu จึงต้องทับที่ตัวเดียวกัน) */
html[data-mode="dark"] body .main-menu.menu-dark {
    --sb-bg: var(--fm-surface);
    --sb-text: var(--fm-ink-2);
    --sb-strong: var(--fm-ink);
    --sb-muted: var(--fm-mute);
    --sb-faint: var(--fm-faint);
    --sb-hover: var(--fm-hover);
    --sb-line: var(--fm-line);
}
html[data-mode="dark"] .fmh { --fmh-line-2: var(--fm-line-2); }
html[data-mode="dark"] #pos-page { --pos-ink: var(--fm-ink); --pos-mute: var(--fm-mute); --pos-line: var(--fm-line); --pos-soft: var(--fm-hover); }

/* =====================================================================
   โหมดมืด: ส่วนประกอบของธีม Vuexy / Bootstrap ที่กำหนดสีตายตัว
   ===================================================================== */
html[data-mode="dark"] body,
html[data-mode="dark"] body .app-content,
html[data-mode="dark"] body .content-wrapper,
html[data-mode="dark"] body .app-content .content-wrapper { background-color: var(--fm-bg) !important; color: var(--fm-ink-3); }
html[data-mode="dark"] body h1, html[data-mode="dark"] body h2, html[data-mode="dark"] body h3,
html[data-mode="dark"] body h4, html[data-mode="dark"] body h5, html[data-mode="dark"] body h6,
html[data-mode="dark"] body .content-header-title, html[data-mode="dark"] body .card-title,
html[data-mode="dark"] body label, html[data-mode="dark"] body .col-form-label, html[data-mode="dark"] body b,
html[data-mode="dark"] body strong { color: var(--fm-ink); }
html[data-mode="dark"] body .text-muted, html[data-mode="dark"] body small.text-muted { color: var(--fm-mute) !important; }
html[data-mode="dark"] body .text-dark, html[data-mode="dark"] body .text-black { color: var(--fm-ink) !important; }
html[data-mode="dark"] body .app-content a:not([class]) { color: var(--fm-pri); }
html[data-mode="dark"] body hr { border-color: var(--fm-line); }

/* พื้นผิว */
html[data-mode="dark"] body .card,
html[data-mode="dark"] body .card .card-header,
html[data-mode="dark"] body .card .card-footer,
html[data-mode="dark"] body .modal-content,
html[data-mode="dark"] body .modal-header,
html[data-mode="dark"] body .modal-footer,
html[data-mode="dark"] body .dropdown-menu,
html[data-mode="dark"] body .popover,
html[data-mode="dark"] body .list-group-item,
html[data-mode="dark"] body .bg-white,
html[data-mode="dark"] body .swal2-popup,
html[data-mode="dark"] body .ui-autocomplete,
html[data-mode="dark"] body .ui-widget-content { background-color: var(--fm-surface) !important; border-color: var(--fm-line) !important; color: var(--fm-ink-3); }
html[data-mode="dark"] body .bg-light, html[data-mode="dark"] body .table .thead-light th,
html[data-mode="dark"] body .bg-lighten-5 { background-color: var(--fm-surface-2) !important; }
html[data-mode="dark"] body .swal2-title, html[data-mode="dark"] body .swal2-html-container,
html[data-mode="dark"] body .swal2-content { color: var(--fm-ink) !important; }
html[data-mode="dark"] body .modal-header .close, html[data-mode="dark"] body .close { color: var(--fm-ink-2); text-shadow: none; }
html[data-mode="dark"] body .dropdown-item { color: var(--fm-ink-2); }
html[data-mode="dark"] body .dropdown-item:hover, html[data-mode="dark"] body .dropdown-item:focus { background-color: var(--fm-hover); color: var(--fm-ink); }
html[data-mode="dark"] body .dropdown-divider { border-color: var(--fm-line); }
html[data-mode="dark"] body .modal-backdrop.show { opacity: .7; }

/* แถบบน / เมนูซ้าย / แถบล่าง */
html[data-mode="dark"] body .header-navbar,
html[data-mode="dark"] body .header-navbar .navbar-container,
html[data-mode="dark"] body .header-navbar .navbar-header,
html[data-mode="dark"] body .footer,
html[data-mode="dark"] body .erp-statusbar { background-color: var(--fm-surface) !important; color: var(--fm-ink-3); }
/* เมนูซ้ายใช้ --sb-bg ของธีม (ธีมกำหนดได้เอง) แยกจากพื้นผิวการ์ด */
html[data-mode="dark"] body .main-menu,
html[data-mode="dark"] body .main-menu .main-menu-content { background-color: var(--sb-bg, var(--fm-surface)) !important; color: var(--fm-ink-3); }
html[data-mode="dark"] body .header-navbar { box-shadow: 0 1px 0 var(--fm-line) !important; }
html[data-mode="dark"] body .header-navbar .navbar-header { box-shadow: inset -1px 0 0 var(--fm-line), 0 1px 0 var(--fm-line) !important; }
html[data-mode="dark"] body .header-navbar .nav-link, html[data-mode="dark"] body .header-navbar .user-name,
html[data-mode="dark"] body .header-navbar .brand-text, html[data-mode="dark"] body .erp-clock b { color: var(--fm-ink) !important; }
html[data-mode="dark"] body .header-navbar .navbar-header .navbar-brand .brand-text { color: var(--fm-ink); }
html[data-mode="dark"] body .header-navbar .user-role, html[data-mode="dark"] body .header-navbar .brand-subtitle { color: var(--fm-mute) !important; }
html[data-mode="dark"] body .main-menu { border-right: 1px solid var(--fm-line); }
html[data-mode="dark"] body .footer, html[data-mode="dark"] body .erp-statusbar { border-top: 1px solid var(--fm-line) !important; }
html[data-mode="dark"] body .brand-logo-circle img, html[data-mode="dark"] body .lg-brand-logo { background: #ffffff; border-radius: 6px; padding: 2px; }

/* ฟอร์ม */
html[data-mode="dark"] body .form-control,
html[data-mode="dark"] body .custom-select,
html[data-mode="dark"] body select,
html[data-mode="dark"] body textarea,
html[data-mode="dark"] body input[type="text"], html[data-mode="dark"] body input[type="number"],
html[data-mode="dark"] body input[type="search"], html[data-mode="dark"] body input[type="date"],
html[data-mode="dark"] body input[type="email"], html[data-mode="dark"] body input[type="password"],
html[data-mode="dark"] body input[type="tel"],
html[data-mode="dark"] body .input-group-text,
html[data-mode="dark"] body .select2-container--default .select2-selection,
html[data-mode="dark"] body .select2-dropdown,
html[data-mode="dark"] body .select2-search__field { background-color: var(--fm-surface-2) !important; border-color: var(--fm-line-3) !important; color: var(--fm-ink) !important; }
html[data-mode="dark"] body .form-control:disabled, html[data-mode="dark"] body .form-control[readonly] { background-color: var(--fm-hover) !important; color: var(--fm-mute) !important; }
html[data-mode="dark"] body .form-control::placeholder, html[data-mode="dark"] body input::placeholder { color: var(--fm-faint) !important; }
html[data-mode="dark"] body .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--fm-ink) !important; }
html[data-mode="dark"] body .select2-results__option { color: var(--fm-ink-2); }
html[data-mode="dark"] body .select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--fm-pri) !important; color: #fff !important; }

/* ตาราง */
html[data-mode="dark"] body .table,
html[data-mode="dark"] body table.dataTable,
html[data-mode="dark"] body .table th,
html[data-mode="dark"] body .table td,
html[data-mode="dark"] body table.dataTable thead th,
html[data-mode="dark"] body table.dataTable tbody td { color: var(--fm-ink-3); border-color: var(--fm-line) !important; background-color: transparent; }
html[data-mode="dark"] body .table thead th, html[data-mode="dark"] body table.dataTable thead th,
html[data-mode="dark"] body .app-content table > thead > tr > th, html[data-mode="dark"] body .modal table > thead > tr > th { background-color: var(--fm-surface-2) !important; color: var(--fm-ink-2) !important; }
html[data-mode="dark"] body .app-content table > tbody > tr > td, html[data-mode="dark"] body .modal table > tbody > tr > td { background-color: var(--fm-surface); color: var(--fm-ink-3); }
html[data-mode="dark"] body .app-content .table-striped > tbody > tr:nth-of-type(even) > td,
html[data-mode="dark"] body .app-content table.dataTable.stripe > tbody > tr.odd > td { background-color: var(--fm-surface-2) !important; }
html[data-mode="dark"] body .app-content table.dataTable > tbody > tr:hover > td,
html[data-mode="dark"] body .table-hover tbody tr:hover > td { background-color: var(--fm-hover) !important; }
html[data-mode="dark"] body .app-content table > tfoot > tr > td { background-color: var(--fm-surface-2) !important; color: var(--fm-ink); }
html[data-mode="dark"] body .dataTables_wrapper .dataTables_info, html[data-mode="dark"] body .dataTables_wrapper label { color: var(--fm-mute); }

/* ปุ่ม แท็บ หน้า ป้าย */
html[data-mode="dark"] body .btn-light, html[data-mode="dark"] body .btn-outline-secondary,
html[data-mode="dark"] body .btn-secondary, html[data-mode="dark"] body .dt-button { background-color: var(--fm-surface-2) !important; border-color: var(--fm-line-3) !important; color: var(--fm-ink-2) !important; }
html[data-mode="dark"] body .btn-light:hover, html[data-mode="dark"] body .btn-outline-secondary:hover { background-color: var(--fm-hover) !important; }
html[data-mode="dark"] body .nav.nav-tabs { border-color: var(--fm-line); }
html[data-mode="dark"] body .nav.nav-tabs .nav-link { color: var(--fm-mute); background: transparent; }
html[data-mode="dark"] body .nav.nav-tabs .nav-link.active { color: var(--fm-pri); background: transparent; }
html[data-mode="dark"] body .page-item .page-link { background-color: var(--fm-surface); border-color: var(--fm-line); color: var(--fm-ink-2); }
html[data-mode="dark"] body .page-item.active .page-link { background-color: var(--fm-pri); border-color: var(--fm-pri); color: #fff; }
html[data-mode="dark"] body .badge-secondary, html[data-mode="dark"] body .badge-light { background: var(--fm-hover) !important; color: var(--fm-ink-2) !important; box-shadow: none !important; }
html[data-mode="dark"] body .badge-success { background: rgba(18, 183, 106, .16) !important; color: #4ade9b !important; box-shadow: none !important; }
html[data-mode="dark"] body .badge-warning, html[data-mode="dark"] body .fmh-tag.is-amber { background: rgba(247, 144, 9, .16) !important; color: #fdb357 !important; box-shadow: none !important; }
html[data-mode="dark"] body .badge-danger, html[data-mode="dark"] body .fmh-tag.is-red { background: rgba(240, 68, 56, .16) !important; color: #f97066 !important; box-shadow: none !important; }
html[data-mode="dark"] body .alert { background-color: var(--fm-surface-2); border-color: var(--fm-line); color: var(--fm-ink-2); }

/* หน้าแรก: ป้ายและกล่องแจ้งที่ใช้พื้นอ่อน */
html[data-mode="dark"] .fmh .fmh-type { background: var(--fm-hover); color: var(--fm-ink-2); }
html[data-mode="dark"] .fmh .fmh-note { background: rgba(247, 144, 9, .12); border-color: rgba(247, 144, 9, .35); color: #fdb357; }
html[data-mode="dark"] .fmh .fmh-tip { background: #e7eaf0; color: #101828; }
html[data-mode="dark"] .fmh .fmh-tip small { color: #475467; }
html[data-mode="dark"] .fmh .fmh-skel { background: var(--fm-hover); }

/* แถบเลื่อน */
html[data-mode="dark"] body ::-webkit-scrollbar-thumb { background: var(--fm-line-3); border-color: var(--fm-bg); }
html[data-mode="dark"] body ::-webkit-scrollbar-track { background: var(--fm-bg); }

/* =====================================================================
   หน้าต่างตั้งค่าธีม (assets/js/fm-theme.js)
   ===================================================================== */
.fmt-ov { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(16, 24, 40, .5); }
.fmt-dlg { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; background: var(--fm-surface); color: var(--fm-ink-3); border: 1px solid var(--fm-line);
           border-radius: 12px; box-shadow: 0 24px 48px -12px rgba(16, 24, 40, .3); font-family: 'Prompt', 'Segoe UI', sans-serif; }
.fmt-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--fm-line-2); }
.fmt-h h3 { margin: 0; font-size: 17px; font-weight: 600; color: var(--fm-ink); }
.fmt-h p { margin: 2px 0 0; font-size: 12.5px; color: var(--fm-mute); }
.fmt-x { width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--fm-mute); font-size: 22px; line-height: 1; cursor: pointer; }
.fmt-x:hover { background: var(--fm-hover); color: var(--fm-ink); }
.fmt-b { padding: 6px 20px 18px; }
.fmt-sec { padding-top: 14px; }
.fmt-sec + .fmt-sec { margin-top: 14px; border-top: 1px solid var(--fm-line-2); }
.fmt-lb { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--fm-ink); }
.fmt-lb small { display: block; font-weight: 400; color: var(--fm-mute); font-size: 12px; margin-top: 1px; }
.fmt-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border: 1px solid var(--fm-line); border-radius: 8px; background: var(--fm-surface-2); }
.fmt-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border: 0; border-radius: 6px; background: transparent;
                  font: inherit; font-size: 13px; color: var(--fm-ink-2); cursor: pointer; }
.fmt-seg button:hover { background: var(--fm-hover); }
.fmt-seg button.on { background: var(--fm-pri); color: #fff; font-weight: 500; }
.fmt-sw { display: flex; flex-wrap: wrap; gap: 8px; }
.fmt-sw button { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 8px; border: 1px solid var(--fm-line); border-radius: 8px;
                 background: var(--fm-surface); font: inherit; font-size: 13px; color: var(--fm-ink-2); cursor: pointer; }
.fmt-sw button:hover { border-color: var(--fm-line-3); background: var(--fm-surface-2); }
.fmt-sw button.on { border-color: var(--fm-pri); box-shadow: inset 0 0 0 1px var(--fm-pri); color: var(--fm-ink); font-weight: 500; }
.fmt-sw i.dot { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 18px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); font-style: normal; }
.fmt-brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fmt-brand input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--fm-line-3); border-radius: 8px; background: var(--fm-surface); cursor: pointer; }
.fmt-brand code { font-size: 12.5px; color: var(--fm-ink-2); background: var(--fm-hover); padding: 3px 8px; border-radius: 6px; }
.fmt-btn { height: 36px; padding: 0 14px; border: 1px solid var(--fm-line-3); border-radius: 8px; background: var(--fm-surface); font: inherit; font-size: 13px; font-weight: 500;
           color: var(--fm-ink-2); cursor: pointer; }
.fmt-btn:hover { background: var(--fm-surface-2); }
.fmt-btn.pri { background: var(--fm-pri); border-color: var(--fm-pri); color: #fff; }
.fmt-btn.pri:hover { background: var(--fm-pri-d); }
.fmt-btn:disabled { opacity: .55; cursor: not-allowed; }
.fmt-msg { margin-top: 8px; font-size: 12.5px; color: var(--fm-mute); min-height: 18px; }
.fmt-msg.err { color: #d92d20; }
.fmt-msg.ok { color: #067647; }
html[data-mode="dark"] .fmt-msg.ok { color: #4ade9b; }
.fmt-seg button:focus-visible, .fmt-sw button:focus-visible, .fmt-btn:focus-visible, .fmt-x:focus-visible { outline: 2px solid var(--fm-pri); outline-offset: 2px; }

/* =========================================================================
   Friendly Me — Enterprise UI layer (2026-12)
   Design direction: Modern Enterprise SaaS · Premium Minimal · Navy / Slate /
   White / Teal. Loaded last, so it is the single source of truth for shared
   components. Every colour comes from --fm-* tokens in fm-theme.css; no new
   hard-coded palette. Existing ids/classes used by JavaScript are untouched.
   ========================================================================= */

:root {
    --fm-font: 'Noto Sans Thai', 'Prompt', 'Segoe UI', Tahoma, sans-serif;
    --fm-r-xs: 6px;
    --fm-r-sm: 8px;
    --fm-r-md: 10px;
    --fm-r-lg: 12px;
    --fm-r-xl: 16px;
    --fm-ease: cubic-bezier(.2, .8, .2, 1);
    --fm-dur: .18s;
    --fm-shadow-pop: 0 18px 40px -16px rgba(11, 27, 51, .28), 0 4px 10px -6px rgba(11, 27, 51, .12);
    --fm-shadow-drawer: -24px 0 60px -24px rgba(11, 27, 51, .35);
    --fm-header-h: 4rem;
}

/* ---------- Typography foundation ---------- */
html body,
html body .main-menu,
html body .header-navbar,
html body .modal,
html body .erp,
html body .fmh,
html body .app-content {
    font-family: var(--fm-font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

html body h1, html body h2, html body h3, html body h4, html body h5, html body h6 {
    font-family: var(--fm-font);
    letter-spacing: -.01em;
}

html body .btn,
html body .form-control,
html body .custom-select,
html body .dropdown-menu,
html body input,
html body select,
html body textarea {
    font-family: var(--fm-font);
}

/* ---------- Page header standard ---------- */
html body .app-content .content-header {
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-top: .15rem;
}

html body .app-content .content-header-title {
    position: relative;
    padding-left: 0 !important;
    font-size: 1.4rem !important;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -.015em;
    color: var(--fm-ink);
}

html body .app-content .content-header-title::before {
    display: none !important;
}

html body .app-content .content-header .breadcrumb-wrapper,
html body .app-content .breadcrumb {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--fm-mute);
}

html body .app-content .breadcrumb-item + .breadcrumb-item::before {
    color: var(--fm-faint);
}

/* ---------- Surfaces ---------- */
html body .card {
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-lg);
    background: var(--fm-surface);
    box-shadow: none;
}

html body .card .card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: .8rem 1rem;
    background: var(--fm-surface);
    border-bottom: 1px solid var(--fm-line-2);
    border-radius: var(--fm-r-lg) var(--fm-r-lg) 0 0;
}

html body .card .card-header .card-title,
html body .card .card-title {
    margin: 0;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--fm-ink);
}

html body .card .card-body {
    padding: 1rem;
}

html body .card .card-footer {
    background: var(--fm-surface);
    border-top: 1px solid var(--fm-line-2);
}

/* ---------- Buttons ---------- */
html body .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--fm-r-sm);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    box-shadow: none !important;
    transition: background-color var(--fm-dur) var(--fm-ease), border-color var(--fm-dur) var(--fm-ease), color var(--fm-dur) var(--fm-ease), transform var(--fm-dur) var(--fm-ease);
}

html body .btn:active {
    transform: translateY(1px);
}

html body .btn-sm {
    height: 30px;
    padding: 0 11px;
    font-size: 12.5px;
}

html body .btn-lg {
    height: 40px;
    padding: 0 18px;
    font-size: 14px;
}

html body .btn i {
    font-size: 14px;
    line-height: 1;
}

html body .btn-primary,
html body .btn-info {
    background: var(--fm-pri) !important;
    border-color: var(--fm-pri) !important;
    color: #fff !important;
}

html body .btn-primary:hover,
html body .btn-info:hover,
html body .btn-primary:focus,
html body .btn-info:focus {
    background: var(--fm-pri-d) !important;
    border-color: var(--fm-pri-d) !important;
}

html body .btn-outline-primary,
html body .btn-outline-info {
    background: var(--fm-surface) !important;
    border-color: var(--fm-line-3) !important;
    color: var(--fm-ink-2) !important;
}

html body .btn-outline-primary:hover,
html body .btn-outline-info:hover {
    border-color: var(--fm-pri) !important;
    background: var(--fm-pri-50) !important;
    color: var(--fm-pri) !important;
}

html body .btn-secondary,
html body .btn-light,
html body .btn-outline-secondary {
    background: var(--fm-surface) !important;
    border-color: var(--fm-line-3) !important;
    color: var(--fm-ink-2) !important;
}

html body .btn-secondary:hover,
html body .btn-light:hover,
html body .btn-outline-secondary:hover {
    background: var(--fm-hover) !important;
    color: var(--fm-ink) !important;
}

html body .btn-success {
    background: var(--fm-ok) !important;
    border-color: var(--fm-ok) !important;
    color: #fff !important;
}

html body .btn-danger {
    background: var(--fm-bad) !important;
    border-color: var(--fm-bad) !important;
    color: #fff !important;
}

html body .btn-outline-danger {
    background: var(--fm-surface) !important;
    border-color: var(--fm-line-3) !important;
    color: var(--fm-bad) !important;
}

html body .btn-outline-danger:hover {
    background: var(--fm-bad-bg) !important;
    border-color: var(--fm-bad) !important;
}

html body .btn-warning {
    background: var(--fm-warn) !important;
    border-color: var(--fm-warn) !important;
    color: #fff !important;
}

html body .btn:disabled,
html body .btn.disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

html body .btn.is-loading {
    pointer-events: none;
    opacity: .75;
}

html body .btn.is-loading::before {
    content: '';
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: fmspin .7s linear infinite;
}

/* ---------- Form controls ---------- */
html body .form-control,
html body .custom-select,
html body select.form-control {
    height: 36px;
    padding: .4rem .7rem;
    border: 1px solid var(--fm-line-3);
    border-radius: var(--fm-r-sm);
    background-color: var(--fm-surface);
    color: var(--fm-ink);
    font-size: 13px;
    transition: border-color var(--fm-dur), box-shadow var(--fm-dur), background-color var(--fm-dur);
}

html body .form-control:hover,
html body .custom-select:hover {
    border-color: #b8c3d3;
}

html body .form-control:focus,
html body .custom-select:focus,
html body select.form-control:focus {
    border-color: var(--fm-pri);
    box-shadow: 0 0 0 3px var(--fm-focus);
    background-color: var(--fm-surface);
    color: var(--fm-ink);
}

html body .form-control::placeholder {
    color: var(--fm-faint);
}

html body .form-control:disabled,
html body .form-control[readonly] {
    background: var(--fm-surface-2);
    color: var(--fm-mute);
    border-color: var(--fm-line);
}

html body .input-group-text {
    border-color: var(--fm-line-3);
    background: var(--fm-surface-2);
    color: var(--fm-mute);
}

html body .form-group label,
html body label {
    color: var(--fm-ink-2);
    font-size: 12.5px;
    font-weight: 500;
}

html body .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--fm-pri);
    border-color: var(--fm-pri);
}

html body .custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: 0 0 0 3px var(--fm-focus);
}

html body input[type="checkbox"],
html body input[type="radio"] {
    accent-color: var(--fm-pri);
}

/* ---------- Tables (shared standard) ---------- */
html body .app-content table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > thead > tr > th,
html body .modal table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > thead > tr > th {
    background: var(--erp-th-bg, var(--fm-surface-2)) !important;
    color: var(--erp-th-color, var(--fm-mute)) !important;
    font-size: var(--erp-th-size, 11px) !important;
    font-weight: 600 !important;
    letter-spacing: var(--erp-th-ls, .05em);
    text-transform: var(--erp-th-tt, uppercase);
    border-bottom: 1px solid var(--fm-line) !important;
    white-space: nowrap;
}

html body .app-content table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > tbody > tr > td,
html body .modal table:not(.picker__table):not(.table-condensed):not(.ui-datepicker-calendar):not(.calendar-table):not(.easyui-treegrid) > tbody > tr > td {
    border-top: 1px solid var(--fm-line-2);
    color: var(--fm-ink-2);
    font-size: 13px;
    vertical-align: middle;
}

html body .app-content table.dataTable > tbody > tr:hover > td,
html body .app-content .table-hover tbody tr:hover > td {
    background: var(--erp-row-hover, var(--fm-surface-2)) !important;
}

html body .app-content table > tbody > tr > td.r,
html body .app-content table > tbody > tr > td.num,
html body .app-content table > thead > tr > th.r {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

html body .table-responsive,
html body .dataTables_wrapper .dataTables_scroll {
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-md);
    background: var(--fm-surface);
}

/* Scrollable table with sticky header */
html body .fm-table-wrap {
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-md);
    background: var(--fm-surface);
}

html body .fm-table-wrap > table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

html body .fm-table-wrap > table > thead > th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--fm-surface-2) !important;
}

html body .fm-table-wrap > table > tbody > tr:first-child > td {
    border-top: 0;
}

/* ---------- Badges / tags ---------- */
html body .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: .32em .6em;
    border-radius: var(--fm-r-xs);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .01em;
    box-shadow: none !important;
}

html body .badge-success { background: var(--fm-ok-bg) !important; color: var(--fm-ok) !important; }
html body .badge-warning { background: var(--fm-warn-bg) !important; color: var(--fm-warn) !important; }
html body .badge-danger  { background: var(--fm-bad-bg) !important; color: var(--fm-bad) !important; }
html body .badge-info,
html body .badge-primary { background: var(--fm-pri-50) !important; color: var(--fm-pri) !important; }
html body .badge-secondary,
html body .badge-light { background: var(--fm-hover) !important; color: var(--fm-ink-2) !important; }

.fm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--fm-hover);
    color: var(--fm-ink-2);
}

.fm-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .85;
}

.fm-badge.ok { background: var(--fm-ok-bg); color: var(--fm-ok); }
.fm-badge.warn { background: var(--fm-warn-bg); color: var(--fm-warn); }
.fm-badge.bad { background: var(--fm-bad-bg); color: var(--fm-bad); }
.fm-badge.info { background: var(--fm-info-bg); color: var(--fm-info); }
.fm-badge.pri { background: var(--fm-pri-50); color: var(--fm-pri); }
.fm-badge.plain::before { display: none; }

/* ---------- Tabs / segmented control ---------- */
html body .nav.nav-tabs {
    gap: 4px;
    border-bottom: 1px solid var(--fm-line);
}

html body .nav.nav-tabs .nav-link {
    height: 38px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--fm-r-sm) var(--fm-r-sm) 0 0;
    color: var(--fm-mute);
    font-size: 13px;
    font-weight: 500;
}

html body .nav.nav-tabs .nav-link:hover {
    color: var(--fm-ink);
    background: var(--fm-hover);
}

html body .nav.nav-tabs .nav-link.active {
    color: var(--fm-pri);
    background: transparent;
    box-shadow: inset 0 -2px 0 var(--fm-pri);
}

.fm-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
}

.fm-tabs::-webkit-scrollbar { display: none; }

.fm-tabs > button,
.fm-tabs > a {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 13px;
    border: 0;
    border-radius: var(--fm-r-sm);
    background: transparent;
    color: var(--fm-mute);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--fm-dur), color var(--fm-dur);
}

.fm-tabs > button:hover,
.fm-tabs > a:hover {
    background: var(--fm-hover);
    color: var(--fm-ink);
    text-decoration: none;
}

.fm-tabs > button.on,
.fm-tabs > a.on {
    background: var(--fm-pri-50);
    color: var(--fm-pri);
    font-weight: 600;
}

.fm-tabs .n {
    min-width: 20px;
    height: 19px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--fm-surface);
    color: var(--fm-pri);
    font-size: 11px;
    font-weight: 600;
    line-height: 19px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.fm-seg {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-sm);
    background: var(--fm-surface-2);
}

.fm-seg > button {
    height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--fm-mute);
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
}

.fm-seg > button.on {
    background: var(--fm-surface);
    color: var(--fm-ink);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

/* ---------- Dropdown / tooltip / modal ---------- */
html body .dropdown-menu {
    padding: 6px;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-md);
    background: var(--fm-surface);
    box-shadow: var(--fm-shadow-pop);
}

html body .dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: var(--fm-r-xs);
    color: var(--fm-ink-2);
    font-size: 13px;
}

html body .dropdown-item:hover,
html body .dropdown-item:focus {
    background: var(--fm-hover);
    color: var(--fm-ink);
}

html body .dropdown-item i {
    color: var(--fm-mute);
    font-size: 15px;
}

html body .dropdown-divider {
    border-color: var(--fm-line-2);
}

/* Accessible tooltip (data-fm-tip) */
[data-fm-tip] {
    position: relative;
}

[data-fm-tip]::after {
    content: attr(data-fm-tip);
    position: absolute;
    z-index: 120;
    top: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, -4px);
    padding: 5px 9px;
    border-radius: 6px;
    background: #0b1b33;
    color: #fff;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .14s var(--fm-ease), transform .14s var(--fm-ease);
}

html[data-mode="dark"] [data-fm-tip]::after {
    background: #e8eef6;
    color: #0b1b33;
}

[data-fm-tip]:hover::after,
[data-fm-tip]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Modal */
html body .modal-content {
    border: 0;
    border-radius: var(--fm-r-lg);
    background: var(--fm-surface);
    box-shadow: 0 32px 64px -24px rgba(11, 27, 51, .4);
}

html body .modal-header {
    padding: .9rem 1.15rem;
    background: var(--fm-surface) !important;
    border-bottom: 1px solid var(--fm-line) !important;
}

html body .modal-header .modal-title {
    color: var(--fm-ink) !important;
    font-size: 15px;
    font-weight: 600;
}

html body .modal-header .close {
    color: var(--fm-mute) !important;
    text-shadow: none;
    opacity: .9;
}

html body .modal-header .close:hover { color: var(--fm-ink) !important; }

html body .modal-body { padding: 1.15rem; }

html body .modal-footer {
    padding: .8rem 1.15rem;
    background: var(--fm-surface-2);
    border-top: 1px solid var(--fm-line);
}

html body .modal-backdrop.show { opacity: .5; }

/* ---------- Toast ---------- */
.fm-toast-wrap {
    position: fixed;
    z-index: 2400;
    top: calc(var(--fm-header-h) + 12px);
    right: 18px;
    display: grid;
    gap: 8px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.fm-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--fm-line);
    border-left: 3px solid var(--fm-pri);
    border-radius: var(--fm-r-md);
    background: var(--fm-surface);
    color: var(--fm-ink-2);
    font-size: 13px;
    line-height: 1.45;
    box-shadow: var(--fm-shadow-pop);
    pointer-events: auto;
    animation: fmToastIn .22s var(--fm-ease);
}

.fm-toast > i {
    flex: 0 0 auto;
    margin-top: 1px;
    color: var(--fm-pri);
    font-size: 16px;
}

.fm-toast.ok { border-left-color: var(--fm-ok); }
.fm-toast.ok > i { color: var(--fm-ok); }
.fm-toast.warn { border-left-color: var(--fm-warn); }
.fm-toast.warn > i { color: var(--fm-warn); }
.fm-toast.bad { border-left-color: var(--fm-bad); }
.fm-toast.bad > i { color: var(--fm-bad); }
.fm-toast.out { animation: fmToastOut .18s var(--fm-ease) forwards; }

@keyframes fmToastIn {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: none; }
}

@keyframes fmToastOut {
    to { opacity: 0; transform: translateY(-4px); }
}

/* ---------- Drawer ---------- */
.fm-drawer-ov {
    position: fixed;
    inset: 0;
    z-index: 2060;
    background: rgba(11, 27, 51, .45);
    opacity: 0;
    transition: opacity .2s var(--fm-ease);
}

.fm-drawer-ov.is-open { opacity: 1; }

.fm-drawer {
    position: fixed;
    z-index: 2061;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    width: min(520px, 100vw);
    height: 100%;
    background: var(--fm-surface);
    border-left: 1px solid var(--fm-line);
    box-shadow: var(--fm-shadow-drawer);
    transform: translateX(100%);
    transition: transform .22s var(--fm-ease);
    font-family: var(--fm-font);
    color: var(--fm-ink-2);
}

.fm-drawer.is-open { transform: none; }
.fm-drawer.fm-drawer-lg { width: min(640px, 100vw); }

.fm-drawer-h {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--fm-line-2);
    background: var(--fm-surface);
}

.fm-drawer-h h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--fm-ink);
    line-height: 1.35;
}

.fm-drawer-h p {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--fm-mute);
}

.fm-drawer-x {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--fm-r-xs);
    background: transparent;
    color: var(--fm-mute);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.fm-drawer-x:hover { background: var(--fm-hover); color: var(--fm-ink); }

.fm-drawer-b {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px 18px;
}

.fm-drawer-f {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--fm-line-2);
    background: var(--fm-surface-2);
}

body.fm-drawer-lock { overflow: hidden; }

/* ---------- Loading, skeleton, empty ---------- */
.fm-skel {
    position: relative;
    overflow: hidden;
    border-radius: var(--fm-r-xs);
    background: var(--fm-hover);
}

.fm-skel::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    animation: fmShimmer 1.3s infinite;
}

html[data-mode="dark"] .fm-skel::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent);
}

@keyframes fmShimmer { to { transform: translateX(100%); } }

.fm-skel-line { height: 11px; margin-bottom: 9px; }
.fm-skel-line:nth-child(2) { width: 82%; }
.fm-skel-line:nth-child(3) { width: 64%; }

.fm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 40px 20px;
    text-align: center;
    color: var(--fm-mute);
}

.fm-empty > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
    border-radius: 50%;
    background: var(--fm-surface-2);
    color: var(--fm-faint);
    font-size: 20px;
}

.fm-empty b {
    color: var(--fm-ink);
    font-size: 14px;
    font-weight: 600;
}

.fm-empty span { font-size: 12.5px; }

@keyframes fmspin { to { transform: rotate(360deg); } }

/* ---------- Stat cards ---------- */
.fm-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.fm-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 14px 15px;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-lg);
    background: var(--fm-surface);
    text-align: left;
    font: inherit;
    cursor: default;
    transition: border-color var(--fm-dur), background var(--fm-dur);
}

button.fm-stat { cursor: pointer; }
button.fm-stat:hover { border-color: var(--fm-line-3); background: var(--fm-surface-2); }
button.fm-stat.on { border-color: var(--fm-pri); box-shadow: inset 0 0 0 1px var(--fm-pri); background: var(--fm-pri-50); }

.fm-stat-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: var(--fm-r-md);
    background: var(--fm-pri-50);
    color: var(--fm-pri);
    font-size: 17px;
}

.fm-stat.ok .fm-stat-ic { background: var(--fm-ok-bg); color: var(--fm-ok); }
.fm-stat.warn .fm-stat-ic { background: var(--fm-warn-bg); color: var(--fm-warn); }
.fm-stat.bad .fm-stat-ic { background: var(--fm-bad-bg); color: var(--fm-bad); }

.fm-stat-t {
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--fm-mute);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fm-stat-v {
    display: block;
    margin-top: 1px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--fm-ink);
    font-variant-numeric: tabular-nums;
}

.fm-stat-n {
    display: block;
    font-size: 11.5px;
    color: var(--fm-mute);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Filter toolbar ---------- */
.fm-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-md);
    background: var(--fm-surface);
    margin-bottom: 12px;
}

.fm-filters .fm-search {
    position: relative;
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 340px;
}

.fm-filters .fm-search > i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fm-mute);
    font-size: 14px;
    pointer-events: none;
}

.fm-filters .fm-search input {
    width: 100%;
    height: 34px;
    padding: 0 30px;
    border: 1px solid var(--fm-line-3);
    border-radius: var(--fm-r-sm);
    background: var(--fm-surface);
    color: var(--fm-ink);
    font: inherit;
    font-size: 13px;
}

.fm-filters .fm-search input:focus {
    outline: none;
    border-color: var(--fm-pri);
    box-shadow: 0 0 0 3px var(--fm-focus);
}

.fm-filters select,
.fm-filters input[type="date"] {
    height: 34px;
    min-width: 130px;
    padding: 0 8px;
    border: 1px solid var(--fm-line-3);
    border-radius: var(--fm-r-sm);
    background: var(--fm-surface);
    color: var(--fm-ink-2);
    font: inherit;
    font-size: 12.5px;
}

.fm-filters select:focus,
.fm-filters input[type="date"]:focus {
    outline: none;
    border-color: var(--fm-pri);
    box-shadow: 0 0 0 3px var(--fm-focus);
}

.fm-filters .fm-flabel {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--fm-mute);
    white-space: nowrap;
}

.fm-filters .fm-clear {
    height: 30px;
    padding: 0 9px;
    border: 0;
    border-radius: var(--fm-r-xs);
    background: transparent;
    color: var(--fm-mute);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.fm-filters .fm-clear:hover { background: var(--fm-hover); color: var(--fm-ink); }

/* ---------- Approval workspace ---------- */
.fm-apv {
    --apv-ink: var(--fm-ink);
    --apv-mute: var(--fm-mute);
    --apv-line: var(--fm-line);
    font-family: var(--fm-font);
    color: var(--fm-ink-2);
    font-variant-numeric: tabular-nums;
}

.fm-apv-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.fm-apv-head h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--fm-ink);
    letter-spacing: -.015em;
}

.fm-apv-head h2 i { color: var(--fm-pri); font-size: 19px; }

.fm-apv-head p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--fm-mute);
}

.fm-apv-panel {
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-lg);
    background: var(--fm-surface);
    overflow: hidden;
}

.fm-apv-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-bottom: 1px solid var(--fm-line-2);
}

.fm-apv-bar .fm-tabs { flex: 1 1 auto; }

.fm-apv-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.fm-apv-bulk {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--fm-line-2);
    background: var(--fm-pri-50);
    color: var(--fm-pri);
    font-size: 12.5px;
    font-weight: 500;
}

.fm-apv-bulk[hidden] { display: none; }

.fm-apv-table { border: 0; border-radius: 0; }
.fm-apv-table > table { font-size: 13px; }

.fm-apv-table > table > thead > th {
    padding: 9px 12px !important;
    font-size: 10.5px !important;
}

.fm-apv-table > table > tbody > tr > td {
    padding: 10px 12px !important;
    border-top: 1px solid var(--fm-line-2);
    vertical-align: middle;
}

.fm-apv-table > table > tbody > tr {
    cursor: pointer;
    transition: background var(--fm-dur);
}

.fm-apv-table > table > tbody > tr:hover > td { background: var(--fm-surface-2) !important; }
.fm-apv-table > table > tbody > tr.is-sel > td { background: var(--fm-pri-50) !important; }

.fm-apv-table .c { text-align: center; }
.fm-apv-table .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.fm-apv-doc {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.fm-apv-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: var(--fm-r-sm);
    background: var(--fm-surface-2);
    color: var(--fm-mute);
    font-size: 15px;
    border: 1px solid var(--fm-line-2);
}

.fm-apv-doc-t { min-width: 0; }
.fm-apv-doc-t b {
    display: block;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--fm-ink);
    font-size: 13px;
    font-weight: 500;
}
.fm-apv-doc-t small {
    display: block;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--fm-mute);
    font-size: 11.5px;
    margin-top: 1px;
}

.fm-apv-mono {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--fm-ink);
}

.fm-apv-amount {
    font-weight: 600;
    color: var(--fm-ink);
    white-space: nowrap;
}

.fm-apv-date { color: var(--fm-ink-3); white-space: nowrap; }

.fm-apv-age { white-space: nowrap; }
.fm-apv-age.warn { color: var(--fm-warn); font-weight: 600; }

.fm-apv-more {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--fm-r-xs);
    background: transparent;
    color: var(--fm-mute);
    cursor: pointer;
}

.fm-apv-more:hover { background: var(--fm-hover); color: var(--fm-ink); }

.fm-apv .fm-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-top: 1px solid var(--fm-line-2);
    font-size: 12.5px;
    color: var(--fm-mute);
}

/* Drawer content */
.fm-apv-doc-card {
    padding: 14px;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-md);
    background: var(--fm-surface-2);
}

.fm-apv-doc-card .t {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fm-apv-doc-card .t .fm-apv-ic {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
    background: var(--fm-surface);
    color: var(--fm-pri);
    border-color: var(--fm-line);
}

.fm-apv-doc-card .t b {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--fm-ink);
    line-height: 1.35;
}

.fm-apv-doc-card .t small {
    display: block;
    color: var(--fm-mute);
    font-size: 12px;
}

.fm-apv-amount-big {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--fm-line-3);
}

.fm-apv-amount-big span {
    display: block;
    font-size: 11.5px;
    color: var(--fm-mute);
}

.fm-apv-amount-big b {
    display: block;
    margin-top: 2px;
    font-size: 22px;
    font-weight: 600;
    color: var(--fm-ink);
    font-variant-numeric: tabular-nums;
}

.fm-apv-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin: 14px 0 0;
}

.fm-apv-meta dt {
    margin: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--fm-mute);
}

.fm-apv-meta dd {
    margin: 2px 0 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--fm-ink);
    overflow-wrap: anywhere;
}

.fm-apv-section-t {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 18px 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--fm-mute);
}

.fm-apv-note {
    padding: 10px 12px;
    border-radius: var(--fm-r-sm);
    background: var(--fm-surface-2);
    border: 1px solid var(--fm-line-2);
    color: var(--fm-ink-3);
    font-size: 12.5px;
    line-height: 1.55;
    white-space: pre-wrap;
}

/* ---------- Timeline ---------- */
.fm-tl {
    position: relative;
    display: grid;
    gap: 0;
    padding-left: 4px;
}

.fm-tl-item {
    position: relative;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 8px;
    padding-bottom: 18px;
}

.fm-tl-item:last-child { padding-bottom: 0; }

.fm-tl-item::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 20px;
    bottom: 0;
    width: 1px;
    background: var(--fm-line);
}

.fm-tl-item:last-child::before { display: none; }

.fm-tl-dot {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--fm-surface);
    border: 2px solid var(--fm-line-3);
    color: var(--fm-mute);
    font-size: 10px;
}

.fm-tl-item.ok .fm-tl-dot { border-color: var(--fm-ok); color: var(--fm-ok); }
.fm-tl-item.bad .fm-tl-dot { border-color: var(--fm-bad); color: var(--fm-bad); }
.fm-tl-item.cur .fm-tl-dot { border-color: var(--fm-warn); color: var(--fm-warn); background: var(--fm-warn-bg); }

.fm-tl-body b {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--fm-ink);
    line-height: 1.4;
}

.fm-tl-body span {
    display: block;
    margin-top: 1px;
    font-size: 11.5px;
    color: var(--fm-mute);
    line-height: 1.45;
}

.fm-tl-body em {
    display: block;
    margin-top: 5px;
    padding: 7px 9px;
    border-radius: var(--fm-r-xs);
    background: var(--fm-surface-2);
    border: 1px solid var(--fm-line-2);
    color: var(--fm-ink-3);
    font-style: normal;
    font-size: 12px;
}

/* ---------- Command palette ---------- */
.fm-cmd-ov {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 11vh 16px 16px;
    background: rgba(11, 27, 51, .48);
    animation: fmFadeIn .15s var(--fm-ease);
}

.fm-cmd {
    display: flex;
    flex-direction: column;
    width: min(640px, 100%);
    max-height: min(560px, 70vh);
    overflow: hidden;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-lg);
    background: var(--fm-surface);
    box-shadow: 0 40px 80px -24px rgba(11, 27, 51, .45);
    animation: fmPopIn .18s var(--fm-ease);
}

.fm-cmd-in {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 15px;
    border-bottom: 1px solid var(--fm-line-2);
}

.fm-cmd-in > i { color: var(--fm-mute); font-size: 17px; }

.fm-cmd-in input {
    flex: 1 1 auto;
    min-width: 0;
    height: 26px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--fm-ink);
    font: inherit;
    font-size: 15px;
}

.fm-cmd-in kbd,
.fm-cmd-foot kbd {
    padding: 2px 6px;
    border: 1px solid var(--fm-line);
    border-radius: 5px;
    background: var(--fm-surface-2);
    color: var(--fm-mute);
    font: 600 10.5px/1.5 var(--fm-font);
}

.fm-cmd-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 6px;
}

.fm-cmd-group {
    padding: 9px 10px 5px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--fm-faint);
}

.fm-cmd-it {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: var(--fm-r-sm);
    background: transparent;
    color: var(--fm-ink-2);
    font: inherit;
    font-size: 13.5px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.fm-cmd-it > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: var(--fm-r-xs);
    background: var(--fm-surface-2);
    color: var(--fm-mute);
    font-size: 14px;
}

.fm-cmd-it > span { flex: 1 1 auto; min-width: 0; }
.fm-cmd-it b { display: block; font-weight: 500; color: var(--fm-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-cmd-it small { display: block; font-size: 11.5px; color: var(--fm-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fm-cmd-it:hover,
.fm-cmd-it.is-cur {
    background: var(--fm-pri-50);
    text-decoration: none;
}

.fm-cmd-it.is-cur > i { background: var(--fm-surface); color: var(--fm-pri); }

.fm-cmd-empty {
    padding: 34px 16px;
    text-align: center;
    color: var(--fm-mute);
    font-size: 13px;
}

.fm-cmd-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 13px;
    border-top: 1px solid var(--fm-line-2);
    background: var(--fm-surface-2);
    color: var(--fm-mute);
    font-size: 11.5px;
}

.fm-cmd-foot > span { display: inline-flex; align-items: center; gap: 5px; }

@keyframes fmFadeIn { from { opacity: 0; } }
@keyframes fmPopIn { from { opacity: 0; transform: translateY(-6px) scale(.985); } }

/* ---------- Topbar additions ---------- */
.fm-top-search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    max-width: 380px;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--fm-line);
    border-radius: var(--fm-r-sm);
    background: var(--fm-surface-2);
    color: var(--fm-mute);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color var(--fm-dur), background var(--fm-dur);
}

.fm-top-search:hover {
    border-color: var(--fm-line-3);
    background: var(--fm-surface);
}

.fm-top-search i { font-size: 14px; }
.fm-top-search span { flex: 1 1 auto; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fm-top-search kbd {
    padding: 2px 5px;
    border: 1px solid var(--fm-line);
    border-radius: 4px;
    background: var(--fm-surface);
    color: var(--fm-faint);
    font: 600 10px/1.4 var(--fm-font);
}

.fm-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--fm-r-sm);
    background: transparent;
    color: var(--fm-mute);
    font-size: 16px;
    cursor: pointer;
    transition: background var(--fm-dur), color var(--fm-dur), border-color var(--fm-dur);
}

.fm-icon-btn:hover {
    background: var(--fm-hover);
    color: var(--fm-ink);
}

.fm-icon-btn:focus-visible {
    outline: 2px solid var(--fm-pri);
    outline-offset: 1px;
}

.fm-topbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    border-right: 1px solid var(--fm-line-2);
}

.fm-qa-menu { min-width: 230px; }

.fm-qa-menu .fm-qa-h {
    padding: 6px 10px 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--fm-faint);
}

/* ---------- Sidebar quick access ---------- */
.fm-quick-head {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin: 4px 8px 2px !important;
    padding: 6px 8px !important;
    color: var(--fm-mute) !important;
    font-size: 11px !important;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: default;
}

.fm-quick-head::after,
.fm-quick-head::before { display: none !important; }

.fm-quick-head .fm-quick-x {
    margin-left: auto;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--fm-faint);
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}

.fm-quick-head:hover .fm-quick-x { opacity: 1; }
.fm-quick-head .fm-quick-x:hover { background: var(--fm-hover); color: var(--fm-ink); }

.fm-quick-empty {
    margin: 2px 18px 6px;
    color: var(--fm-faint);
    font-size: 11.5px;
    line-height: 1.5;
}

html body #main-menu-navigation > li.fm-quick-row {
    position: relative;
}

html body #main-menu-navigation > li.fm-quick-row > a {
    padding-right: 34px !important;
}

.fm-star {
    position: absolute;
    z-index: 2;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--fm-faint);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
}

#main-menu-navigation > li:hover > .fm-star,
.fm-star.on { opacity: 1; }

.fm-star:hover { background: var(--fm-hover); color: var(--fm-ink); }
.fm-star.on { color: #d99a06; }
.fm-star.on:hover { color: #b54708; }

body.menu-collapsed .main-menu:not(.expanded) .fm-star,
body.menu-collapsed .main-menu:not(.expanded) .fm-quick-head,
body.menu-collapsed .main-menu:not(.expanded) .fm-quick-empty,
body.menu-collapsed .main-menu:not(.expanded) li.fm-quick-row {
    display: none !important;
}

/* Tooltip when the sidebar is collapsed to icons */
body.menu-collapsed .main-menu:not(.expanded) #main-menu-navigation > li > a[data-fm-tip]::after,
.main-menu.menu-collapsed #main-menu-navigation > li > a[data-fm-tip]::after {
    left: calc(100% + 10px);
    top: 50%;
    transform: translate(-4px, -50%);
}

body.menu-collapsed .main-menu:not(.expanded) #main-menu-navigation > li > a[data-fm-tip]:hover::after {
    transform: translate(0, -50%);
}

/* ---------- Sidebar polish ---------- */
html body .main-menu.menu-dark {
    border-right: 1px solid var(--fm-line);
    background: var(--fm-surface);
}

html body .main-menu.menu-dark .main-menu-content {
    background: var(--fm-surface);
}

html body .main-menu.menu-dark .navigation > li > a {
    min-height: 36px;
    border-radius: var(--fm-r-sm);
    font-size: 13px;
    color: var(--fm-ink-2);
}

html body .main-menu.menu-dark .navigation > li > a > i {
    color: var(--fm-mute);
}

html body .main-menu.menu-dark .navigation > li.active:not(.has-sub) > a,
html body .main-menu.menu-dark .navigation > li .menu-content li.active > a {
    background: var(--fm-pri-50);
    color: var(--fm-pri);
}

html body .main-menu.menu-dark .navigation > li.active > a > i {
    color: var(--fm-pri);
}

html body .main-menu.menu-dark .navigation-header.nt-foldable {
    color: var(--fm-ink-3);
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-section-active {
    color: var(--fm-ink);
}

html body .main-menu.menu-dark .navigation .navigation-header.nt-section-active .nt-sec-ic {
    color: var(--fm-pri);
}

/* ---------- Focus / motion / responsive ---------- */
html body a:focus-visible,
html body button:focus-visible,
html body [tabindex]:focus-visible,
.fm-tabs > button:focus-visible,
.fm-tabs > a:focus-visible,
.fm-seg > button:focus-visible,
.fm-icon-btn:focus-visible {
    outline: 2px solid var(--fm-pri);
    outline-offset: 2px;
}

html body .btn:focus-visible {
    outline: 2px solid var(--fm-pri);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    html body *,
    html body *::before,
    html body *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1199.98px) {
    .fm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    .fm-top-search { display: none !important; }
    .fm-topbar-actions { border-right: 0; }
}

@media (max-width: 767.98px) {
    .fm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .fm-stat { gap: 9px; padding: 11px 12px; }
    .fm-stat-ic { flex-basis: 32px; width: 32px; height: 32px; font-size: 15px; }
    .fm-stat-v { font-size: 19px; }
    .fm-apv-head h2 { font-size: 18px; }
    .fm-apv-doc-t b, .fm-apv-doc-t small { max-width: 180px; }
    .fm-drawer { width: 100vw; }
    .fm-drawer-b { padding: 14px; }
    .fm-drawer-h { padding: 14px; }
    .fm-drawer-f { padding: 10px 14px; }
    .fm-filters .fm-search { max-width: none; flex-basis: 100%; }
    .fm-cmd-ov { padding-top: 6vh; }
    .fm-apv-meta { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .fm-stats { grid-template-columns: 1fr 1fr; gap: 6px; }
    .fm-stat { padding: 10px; }
    .fm-stat-ic { display: none; }
    .fm-stat-t { font-size: 10.5px; }
    .fm-stat-v { font-size: 18px; }
}

@media print {
    .fm-drawer, .fm-drawer-ov, .fm-toast-wrap, .fm-cmd-ov { display: none !important; }
}

/* ---------- Sidebar quick access (favourites / recently used) ---------- */
.fm-quick {
    margin: 2px 8px 6px;
    padding: 4px 2px 6px;
    border-bottom: 1px solid var(--fm-line);
}

.fm-quick[hidden] { display: none !important; }

.fm-quick-list { display: grid; gap: 1px; }

.fm-quick-a {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 30px;
    padding: 5px 8px;
    border-radius: var(--fm-r-xs);
    color: var(--fm-ink-2);
    font-size: 12.5px;
    line-height: 1.35;
    text-decoration: none;
}

.fm-quick-a > i {
    flex: 0 0 auto;
    color: var(--fm-mute);
    font-size: 13px;
}

.fm-quick-a > span {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.fm-quick-a:hover {
    background: var(--fm-hover);
    color: var(--fm-ink);
    text-decoration: none;
}

.fm-quick-a:hover > i { color: var(--fm-pri); }

.nt-menu-searching .fm-quick { display: none; }

body.menu-collapsed .main-menu:not(.expanded) .fm-quick { display: none !important; }

#main-menu-navigation > li.nav-item { position: relative; }

@media (hover: none) {
    .fm-star { opacity: 1; }
}

/* ---------- Topbar quick controls ---------- */
.header-navbar .nav-item.fm-top-search-item {
    display: flex;
    align-items: center;
    padding-left: 14px;
}

.header-navbar .nav-item.fm-top-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 4rem;
    padding: 0 8px;
    border-right: 1px solid var(--fm-line-2);
}

.header-navbar .fm-top-actions .fm-icon-btn { color: var(--fm-mute); }
.header-navbar .fm-top-actions .fm-icon-btn:hover { color: var(--fm-ink); }

.header-navbar .fm-top-search {
    border-color: var(--fm-line);
    background: var(--fm-surface-2);
}

html[data-mode="dark"] .header-navbar .fm-top-search {
    background: var(--fm-surface-2);
}

.fm-topbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

@media (max-width: 991.98px) {
    .header-navbar .nav-item.fm-top-actions { display: none !important; }
}

/* ---------- Approval page: E.table wrapper polish ---------- */
.fm-apv-lead {
    margin: 0;
    font-size: 13px;
    color: var(--fm-mute);
    line-height: 1.5;
}

.fm-apv-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.fm-apv .fm-filters { margin: 10px 12px; }

.fm-apv .tw {
    max-width: 100%;
    overflow: auto;
    border: 0;
    border-radius: 0;
    background: var(--fm-surface);
}

.fm-apv .mt {
    width: 100%;
    margin: 0;
}

.fm-apv .mt > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 9px 12px !important;
    background: var(--fm-surface-2) !important;
}

.fm-apv .mt > tbody > tr > td {
    padding: 10px 12px !important;
    border-top: 1px solid var(--fm-line-2);
    vertical-align: middle;
}

.fm-apv .mt > tbody > tr { cursor: pointer; }
.fm-apv .mt > tbody > tr:hover > td { background: var(--fm-surface-2) !important; }
.fm-apv .mt > tbody > tr.is-sel > td { background: var(--fm-pri-50) !important; }

.fm-apv .pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-top: 1px solid var(--fm-line-2);
    color: var(--fm-mute);
    font-size: 12.5px;
}

.fm-apv .pager .btn { height: 28px; padding: 0 10px; font-size: 12px; }

.fm-apv .erp-empty {
    padding: 34px 16px;
    text-align: center;
    color: var(--fm-mute);
    font-size: 13px;
}

.fm-apv-bulk .btn:first-of-type { margin-left: auto; }

@media (max-width: 767.98px) {
    .fm-apv .fm-filters { margin: 8px; }
    .fm-apv .mt > tbody > tr > td,
    .fm-apv .mt > thead > tr > th { padding: 8px 9px !important; }
    .fm-apv .fm-apv-doc-t b,
    .fm-apv .fm-apv-doc-t small { max-width: 160px; }
}

/* Alerts (SweetAlert2) must sit above the detail drawer */
.swal2-container { z-index: 3000 !important; }

/* ---------- Goods Receipt (WMS) — compact grid for the 32-column document table ---------- */
html body .app-content #app-invoice-wrapper {
    max-width: 100%;
    overflow-x: auto;
}

html body .app-content #receiving_table > thead > tr > th {
    font-size: 10.5px !important;
    letter-spacing: 0;
    padding: 6px 6px !important;
    line-height: 1.35;
}

html body .app-content #receiving_table > tbody > tr > td {
    font-size: 12px;
    padding: 6px 6px;
    line-height: 1.4;
}

html body .app-content #receiving_table > tbody > tr > td img {
    max-width: 48px;
    max-height: 48px;
}

/*
 * Friendly Me Theme Engine — 4 themes + display settings + Theme Studio
 * Loaded after fm-ui.css. HTML attributes set pre-paint by api/_theme.php:
 *   data-theme   teal | mint | linear | executive
 *   data-mode    light | dark            (executive is always dark)
 *   data-density comfy | compact
 *   data-radius  sharp | medium | round
 *   data-font    s | m | l
 *   data-motion  on | off
 *   data-nav     expanded | collapsed
 *   data-brand-color  present when the company brand color is active
 */

/* Page titles: components.css styles .content .content-wrapper .content-header-title
   with #1b2942 + uppercase at higher specificity than per-theme rules. */
html[data-theme] body .content .content-wrapper .content-header-title {
    color: var(--fm-ink) !important;
    text-transform: none !important;
    letter-spacing: -.015em;
}

/* =========================================================================
   1. THEME 04 — CORPORATE TEAL (default; Compreo: solid teal, soft white cards)
   ========================================================================= */
html[data-theme="teal"][data-mode="light"] {
    --fm-pri-base: #12a594;
    --fm-pri: #12a594;
    --fm-pri-d: #0d8a7c;
    --fm-pri-50: #e3f5f1;
    --fm-pri-200: #c1eae4;
    --fm-pri-300: #86d8cd;
    --fm-pri-rgb: 18, 165, 148;
    --fm-bg: #f5f8fa;
    --fm-surface: #ffffff;
    --fm-surface-2: #f8fafc;
    --fm-hover: #f0f4f7;
    --fm-ink: #0f1f2e;
    --fm-ink-2: #263747;
    --fm-ink-3: #425466;
    --fm-mute: #66788a;
    --fm-faint: #94a3b3;
    --fm-line: #e5ebf1;
    --fm-line-2: #eef3f7;
    --fm-line-3: #cfdae5;
    --fm-r-sm: 8px;
    --fm-r-md: 12px;
    --fm-r-lg: 16px;
    --erp-radius: 12px;
    --erp-radius-sm: 8px;
    --erp-th-color: #425466;
    --erp-th-bg: #f8fafc;
    --erp-th-size: 12px;
    --erp-th-ls: .01em;
    --erp-th-tt: none;
    --erp-th-pad: .7rem .85rem;
    --erp-row-hover: #f6f9fb;
    --erp-stripe: #fafcfe;
}
html[data-theme="teal"][data-mode="dark"] { --fm-pri-base: #14b8a6; }

/* พื้นผิว: การ์ดขาวมุมโค้ง เงานุ่มแบบ Compreo */
html[data-theme="teal"][data-mode="light"] body .card {
    border: 1px solid var(--fm-line);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(16, 30, 46, .04), 0 12px 28px -22px rgba(16, 30, 46, .18);
}
html[data-theme="teal"][data-mode="light"] body .card .card-header {
    background: var(--fm-surface);
    border-bottom: 1px solid var(--fm-line-2);
    border-radius: 14px 14px 0 0;
}
html[data-theme="teal"][data-mode="light"] body .fmh-panel {
    border: 1px solid var(--fm-line);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(16, 30, 46, .04), 0 12px 28px -22px rgba(16, 30, 46, .2);
}
html[data-theme="teal"][data-mode="light"] body .fmh-ph { border-bottom-color: var(--fm-line-2); }
html[data-theme="teal"][data-mode="light"] body .fmh-big b { font-size: 32px; }
html[data-theme="teal"][data-mode="light"] body .fmh-link { border-radius: 10px; }
html[data-theme="teal"][data-mode="light"] body .fmh-link:hover { background: var(--fm-surface-2); border-color: var(--fm-line); }
html[data-theme="teal"][data-mode="light"] body .fmh-search input { border-radius: 10px; }
html[data-theme="teal"] body .fmh-tag { border-radius: 6px; }

/* ปุ่ม/ช่องกรอก: มุมโค้งปานกลางแบบ ERP */
html[data-theme="teal"] body .btn { border-radius: 8px; }
html[data-theme="teal"] body .btn-primary { box-shadow: 0 10px 20px -14px rgba(18, 165, 148, .7) !important; }
html[data-theme="teal"] body .form-control,
html[data-theme="teal"] body .custom-select { border-radius: 8px; }
html[data-theme="teal"][data-mode="light"] body .form-control:focus,
html[data-theme="teal"][data-mode="light"] body .custom-select:focus { border-color: var(--fm-pri); box-shadow: 0 0 0 3px rgba(var(--fm-pri-rgb), .14); }
html[data-theme="teal"][data-mode="light"] body .nav.nav-tabs .nav-item .nav-link { border-radius: 8px 8px 0 0; }
html[data-theme="teal"][data-mode="light"] body .table-responsive { border-radius: 12px; }
html[data-theme="teal"][data-mode="light"] body .app-content .table-striped > tbody > tr:nth-of-type(odd) { background-color: var(--erp-stripe); }
html[data-theme="teal"][data-mode="light"] body .badge { border-radius: 6px; }

/* หัวหน้า: ใหญ่ ไม่มีแถบสี */
html[data-theme="teal"] body .content-header-title { font-size: 1.45rem !important; letter-spacing: -.005em; }
html[data-theme="teal"] body .content-header-title::before { display: none; }
html[data-theme="teal"][data-mode="light"] body .content-header-title { color: var(--fm-ink); }

/* เชลล์: เมนูที่เลือกเป็นสีทีลทึบ ตัวอักษรขาว (แบบ Compreo) */
html[data-theme="teal"] body .main-menu.menu-dark {
    --sb-bg: #ffffff;
    --sb-line: #e5ebf1;
    --sb-hover: #f2f6f9;
    --sb-accent: var(--fm-pri-d);
    --sb-active-bg: var(--fm-pri-50);
    border-right-color: #e5ebf1;
}
html[data-theme="teal"][data-mode="light"] body .main-menu.menu-dark .navigation > li.active:not(.has-sub) > a {
    background: var(--fm-pri);
    color: #fff;
    box-shadow: 0 8px 18px -10px rgba(18, 165, 148, .65);
}
html[data-theme="teal"][data-mode="light"] body .main-menu.menu-dark .navigation > li.active > a > i { color: #fff; }
html[data-theme="teal"][data-mode="light"] body .main-menu.menu-dark .navigation > li.active > a::after { color: rgba(255, 255, 255, .85); }
html[data-theme="teal"][data-mode="light"] body .header-navbar.navbar { box-shadow: 0 1px 0 var(--fm-line); }
html[data-theme="teal"][data-mode="light"] body footer.erp-statusbar { background: #ffffff; border-top-color: var(--fm-line-2); }

/* =========================================================================
   2. THEME 01 — ENTERPRISE MINT  (Canon: pastel green, airy, pill controls)
   ========================================================================= */
html[data-theme="mint"][data-mode="light"] {
    --fm-pri-base: #10b981;
    --fm-pri: #10b981;
    --fm-pri-d: #0b8f63;
    --fm-pri-50: #e6f7ef;
    --fm-pri-200: #c5f0dd;
    --fm-pri-300: #8fe4c3;
    --fm-pri-rgb: 16, 185, 129;
    --fm-bg: #f2f6f3;
    --fm-surface: #ffffff;
    --fm-surface-2: #f6faf7;
    --fm-hover: #eef5f1;
    --fm-ink: #1c2b24;
    --fm-ink-2: #33463c;
    --fm-ink-3: #4a5e53;
    --fm-mute: #6b7f74;
    --fm-faint: #98aaa0;
    --fm-line: #e3ebe6;
    --fm-line-2: #eef4f0;
    --fm-line-3: #d2ded6;
    --fm-r-xs: 8px;
    --fm-r-sm: 12px;
    --fm-r-md: 16px;
    --fm-r-lg: 20px;
    --fm-r-xl: 24px;
    --erp-radius: 16px;
    --erp-radius-sm: 10px;
    --erp-th-color: #4a5e53;
    --erp-th-bg: #f4faf6;
    --erp-th-size: 12.5px;
    --erp-th-ls: .01em;
    --erp-th-tt: none;
    --erp-th-pad: .7rem .9rem;
    --erp-row-hover: #f3faf6;
    --erp-stripe: #fafdfb;
}
html[data-theme="mint"][data-mode="dark"] { --fm-pri-base: #34d399; }

/* พื้นผิว: การ์ดขาวมุมพอง เงาฟุ้งนุ่มแบบ Canon */
html[data-theme="mint"][data-mode="light"] body .card {
    border: 1px solid var(--fm-line);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(19, 41, 31, .04), 0 16px 36px -28px rgba(19, 41, 31, .3);
}
html[data-theme="mint"][data-mode="light"] body .card .card-header {
    background: var(--fm-surface);
    border-bottom: 1px solid var(--fm-line-2);
    border-radius: 16px 16px 0 0;
}
html[data-theme="mint"][data-mode="light"] body .fmh-panel {
    border: 1px solid var(--fm-line);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(19, 41, 31, .04), 0 16px 34px -26px rgba(19, 41, 31, .32);
}
html[data-theme="mint"][data-mode="light"] body .fmh-ph { border-bottom-color: var(--fm-line-2); padding: 14px 18px 12px; }
html[data-theme="mint"][data-mode="light"] body .fmh-big b { font-size: 34px; }
html[data-theme="mint"][data-mode="light"] body .fmh-link { border-radius: 12px; }
html[data-theme="mint"][data-mode="light"] body .fmh-link:hover { background: var(--fm-surface-2); border-color: var(--fm-line); }
html[data-theme="mint"][data-mode="light"] body .fmh-note { border-radius: 12px; }
html[data-theme="mint"][data-mode="light"] body .fmh-search input { border-radius: 999px; }
html[data-theme="mint"] body .fmh-tag,
html[data-theme="mint"] body .fmh-type { border-radius: 999px; }

/* ปุ่ม/ช่องกรอก: แคปซูลมนแบบ Canon */
html[data-theme="mint"] body .btn { border-radius: 999px; padding: .48rem 1.15rem; }
html[data-theme="mint"] body .btn-sm { padding: .24rem .8rem; }
html[data-theme="mint"] body .btn-primary { box-shadow: 0 10px 20px -12px rgba(16, 185, 129, .65) !important; }
html[data-theme="mint"] body .form-control,
html[data-theme="mint"] body .custom-select { border-radius: 10px; border-color: var(--fm-line-3); background-color: var(--fm-surface); }
html[data-theme="mint"][data-mode="light"] body .form-control:focus,
html[data-theme="mint"][data-mode="light"] body .custom-select:focus { border-color: var(--fm-pri); box-shadow: 0 0 0 4px rgba(var(--fm-pri-rgb), .14); }
html[data-theme="mint"][data-mode="light"] body .nav.nav-tabs { border-bottom: 0; }
html[data-theme="mint"][data-mode="light"] body .nav.nav-tabs .nav-item .nav-link { border-radius: 999px; padding: .45rem .95rem; }
html[data-theme="mint"][data-mode="light"] body .nav.nav-tabs .nav-item .nav-link:hover { background: var(--fm-surface-2); }
html[data-theme="mint"][data-mode="light"] body .nav.nav-tabs .nav-item .nav-link.active {
    background: var(--fm-pri-50);
    color: var(--fm-pri-d);
    box-shadow: none;
    font-weight: 600;
}
html[data-theme="mint"][data-mode="light"] body .badge { border-radius: 999px; }
html[data-theme="mint"][data-mode="light"] body .table-responsive { border-radius: 14px; }
html[data-theme="mint"][data-mode="light"] body .app-content .table-striped > tbody > tr:nth-of-type(odd) { background-color: var(--erp-stripe); }

/* หัวหน้า: ใหญ่ นุ่ม ไม่มีแถบสี */
html[data-theme="mint"] body .content-header-title { font-size: 1.5rem !important; letter-spacing: -.01em; }
html[data-theme="mint"] body .content-header-title::before { display: none; }
html[data-theme="mint"][data-mode="light"] body .content-header-title { color: var(--fm-ink); }

/* เชลล์ */
html[data-theme="mint"] body .main-menu.menu-dark {
    --sb-bg: #fbfdfc;
    --sb-line: #e3ebe6;
    --sb-hover: #f0f7f3;
    --sb-active-bg: var(--fm-pri-50);
    --sb-accent: var(--fm-pri-d);
    border-right-color: #e3ebe6;
}
html[data-theme="mint"] body .main-menu.menu-dark,
html[data-theme="mint"] body .main-menu.menu-dark .main-menu-content { background: #fbfdfc; }
html[data-theme="mint"] body .main-menu.menu-dark .navigation > li > a { border-radius: 10px; }
html[data-theme="mint"] body .main-menu.menu-dark .navigation > li.active:not(.has-sub) > a { background: #e6f7ef; color: #0b8f63; }
html[data-theme="mint"] body .main-menu.menu-dark .navigation > li.active > a > i { color: #0b8f63; }
html[data-theme="mint"][data-mode="light"] body .header-navbar.navbar { box-shadow: 0 1px 0 var(--fm-line); }
html[data-theme="mint"][data-mode="light"] body footer.erp-statusbar { background: #fbfdfc; border-top-color: var(--fm-line-2); }

/* =========================================================================
   3. THEME 02 — LINEAR MINIMAL  (dense, flat, hairline borders, tiny caps)
   ========================================================================= */
html[data-theme="linear"][data-mode="light"] {
    --fm-pri-base: #5e6ad2;
    --fm-pri: #5e6ad2;
    --fm-pri-d: #4f5abf;
    --fm-pri-50: #eef0fb;
    --fm-pri-200: #d2d6f5;
    --fm-pri-300: #a6ade9;
    --fm-pri-rgb: 94, 106, 210;
    --fm-bg: #fafafa;
    --fm-surface: #ffffff;
    --fm-surface-2: #fafafa;
    --fm-hover: #f4f4f5;
    --fm-ink: #18181b;
    --fm-ink-2: #27272a;
    --fm-ink-3: #3f3f46;
    --fm-mute: #71717a;
    --fm-faint: #a1a1aa;
    --fm-line: #e4e4e7;
    --fm-line-2: #f0f0f1;
    --fm-line-3: #d4d4d8;
    --fm-r-xs: 4px;
    --fm-r-sm: 6px;
    --fm-r-md: 7px;
    --fm-r-lg: 8px;
    --fm-r-xl: 10px;
    --erp-radius: 7px;
    --erp-radius-sm: 5px;
    --erp-th-color: #71717a;
    --erp-th-bg: #fafafa;
    --erp-th-size: 11px;
    --erp-th-pad: .5rem .65rem;
    --erp-th-ls: .07em;
    --erp-th-tt: uppercase;
    --erp-row-hover: #f6f6f7;
    --erp-stripe: #fbfbfc;
}
html[data-theme="linear"][data-mode="dark"] { --fm-pri-base: #818cf8; }

html[data-theme="linear"][data-mode="light"] body { font-size: 13px; }
html[data-theme="linear"][data-mode="light"] body .app-content .content-wrapper { padding: 1rem 1.25rem 1.5rem; }
html[data-theme="linear"][data-mode="light"] body .card {
    border: 1px solid var(--fm-line);
    border-radius: 7px;
    box-shadow: none;
    margin-bottom: .8rem;
}
html[data-theme="linear"][data-mode="light"] body .card .card-header {
    background: var(--fm-surface);
    border-bottom: 1px solid var(--fm-line-2);
    padding: .6rem 1rem;
}
html[data-theme="linear"][data-mode="light"] body .card .card-body { padding: 1rem; }
html[data-theme="linear"][data-mode="light"] body .fmh-panel {
    border: 1px solid var(--fm-line);
    border-radius: 7px;
    box-shadow: none;
}
html[data-theme="linear"][data-mode="light"] body .fmh-ph { padding: 10px 14px 9px; }
html[data-theme="linear"][data-mode="light"] body .fmh-big b { font-size: 26px; font-weight: 600; }
html[data-theme="linear"][data-mode="light"] body .fmh-step b { font-size: 20px; }
html[data-theme="linear"][data-mode="light"] body .fmh-link { border-radius: 5px; min-height: 38px; }
html[data-theme="linear"][data-mode="light"] body .fmh-search input { height: 34px; border-radius: 6px; font-size: 13px; }
html[data-theme="linear"][data-mode="light"] body .fmh-note { border-radius: 6px; }
html[data-theme="linear"][data-mode="light"] body .fmh-tag { border-radius: 4px; font-size: 11.5px; }

html[data-theme="linear"] body .btn { border-radius: 6px; letter-spacing: -.005em; padding: .4rem .9rem; }
html[data-theme="linear"] body .btn-primary { box-shadow: none !important; }
html[data-theme="linear"] body .form-control,
html[data-theme="linear"] body .custom-select { border-radius: 6px; border-color: var(--fm-line-3); }
html[data-theme="linear"][data-mode="light"] body .form-control:focus,
html[data-theme="linear"][data-mode="light"] body .custom-select:focus { border-color: var(--fm-pri); box-shadow: 0 0 0 3px rgba(var(--fm-pri-rgb), .13); }
html[data-theme="linear"][data-mode="light"] body .nav.nav-tabs .nav-item .nav-link { padding: .45rem .75rem; font-size: 12.5px; }
html[data-theme="linear"][data-mode="light"] body .table-responsive { border-radius: 6px; }
html[data-theme="linear"][data-mode="light"] body .app-content .table-striped > tbody > tr:nth-of-type(odd) { background-color: var(--erp-stripe); }
html[data-theme="linear"][data-mode="light"] body .app-content table > tbody > tr > td { font-size: 12.5px; }
html[data-theme="linear"][data-mode="light"] body .badge { border-radius: 4px; font-size: 11px; }

html[data-theme="linear"] body .content-header-title { font-size: 1.1rem !important; letter-spacing: -.01em; }
html[data-theme="linear"] body .content-header-title::before { display: none; }
html[data-theme="linear"] body .main-menu.menu-dark { box-shadow: none; }
html[data-theme="linear"] body .main-menu.menu-dark {
    --sb-bg: #fbfbfc;
    --sb-hover: #f2f2f3;
    --sb-active-bg: #ededf0;
    --sb-accent: #18181b;
    --sb-line: #e7e7ea;
    border-right-color: #e7e7ea;
}
html[data-theme="linear"] body .main-menu.menu-dark,
html[data-theme="linear"] body .main-menu.menu-dark .main-menu-content { background: #fbfbfc; }
html[data-theme="linear"] body .main-menu.menu-dark .navigation > li > a { border-radius: 6px; min-height: 32px; }
html[data-theme="linear"] body .main-menu.menu-dark .navigation > li.active > a,
html[data-theme="linear"] body .main-menu.menu-dark .navigation > li > a.active {
    background: #ededf0;
    color: #18181b;
    font-weight: 500;
}
html[data-theme="linear"] body .main-menu.menu-dark .navigation > li.active > a > i { color: #18181b; }
html[data-theme="linear"] body .header-navbar.navbar { box-shadow: none !important; border-bottom: 1px solid var(--fm-line); }
html[data-theme="linear"][data-mode="light"] body footer.erp-statusbar { background: #fafafa; border-top-color: var(--fm-line-2); font-size: 11.5px; }
html[data-theme="linear"] body .erp-kpi, html[data-theme="linear"] body .card.fmh-card { box-shadow: none; }

/* =========================================================================
   4. THEME 03 — EXECUTIVE DARK (always dark)
   ========================================================================= */
html[data-theme="executive"] {
    color-scheme: dark;
    --fm-pri-base: #3b82f6;
    --fm-pri: #3b82f6;
    --fm-pri-d: #2563eb;
    --fm-pri-50: #15264a;
    --fm-pri-200: #1e3f7d;
    --fm-pri-300: #60a5fa;
    --fm-pri-rgb: 59, 130, 246;
    --fm-bg: #050a14;
    --fm-surface: #0d1526;
    --fm-surface-2: #0a1120;
    --fm-hover: #172236;
    --fm-ink: #f3f6fb;
    --fm-ink-2: #dbe4f3;
    --fm-ink-3: #b7c4d8;
    --fm-mute: #8b9bb4;
    --fm-faint: #64748b;
    --fm-line: #1c2942;
    --fm-line-2: #141f33;
    --fm-line-3: #2b3b57;
    --fm-ok: #4ade80;
    --fm-ok-bg: rgba(34, 197, 94, .16);
    --fm-ok-line: rgba(34, 197, 94, .38);
    --fm-warn: #fbbf24;
    --fm-warn-bg: rgba(245, 158, 11, .16);
    --fm-warn-line: rgba(245, 158, 11, .38);
    --fm-bad: #f87171;
    --fm-bad-bg: rgba(239, 68, 68, .16);
    --fm-bad-line: rgba(239, 68, 68, .38);
    --fm-info: #38bdf8;
    --fm-info-bg: rgba(14, 165, 233, .16);
    --fm-info-line: rgba(14, 165, 233, .38);
    --fm-r-xs: 6px;
    --fm-r-sm: 8px;
    --fm-r-md: 10px;
    --fm-r-lg: 12px;
    --fm-r-xl: 16px;
    --erp-radius: 12px;
    --erp-radius-sm: 8px;
    --erp-th-color: #93a4bd;
    --erp-th-bg: #0b1424;
    --erp-th-size: 11.5px;
    --erp-th-ls: .04em;
    --erp-row-hover: #101d33;
    --erp-stripe: #0b1424;
}
html[data-theme="executive"] body .main-menu.menu-dark {
    --sb-bg: #0a111f;
    --sb-text: #b7c4d8;
    --sb-strong: #f3f6fb;
    --sb-muted: #8b9bb4;
    --sb-faint: #64748b;
    --sb-hover: #141f33;
    --sb-line: #1a2740;
    --sb-accent: #8ab8ff;
    --sb-active-bg: #16233c;
    border-right-color: #1a2740;
}
html[data-theme="executive"] body .main-menu.menu-dark,
html[data-theme="executive"] body .main-menu.menu-dark .main-menu-content { background: #0a111f; }
html[data-theme="executive"] body .main-menu.menu-dark .navigation > li.active:not(.has-sub) > a { background: #16233c; color: #8ab8ff; }
html[data-theme="executive"] body .main-menu.menu-dark .navigation > li.active > a > i { color: #8ab8ff; }
html[data-theme="executive"] body .header-navbar.navbar,
html[data-theme="executive"] body .header-navbar .navbar-container,
html[data-theme="executive"] body .header-navbar .navbar-header { background-color: #0a111f !important; }
html[data-theme="executive"] body .header-navbar.navbar { box-shadow: 0 1px 0 var(--fm-line) !important; }
html[data-theme="executive"] body .card {
    background: var(--fm-surface);
    border: 1px solid var(--fm-line);
    border-radius: 12px;
    box-shadow: 0 18px 44px -34px rgba(0, 0, 0, .95);
}
html[data-theme="executive"] body .card .card-header { background: transparent; border-bottom-color: var(--fm-line-2); }
html[data-theme="executive"] body .fmh-panel { background: var(--fm-surface); border-color: var(--fm-line); border-radius: 12px; }
html[data-theme="executive"] body .fmh-ph { border-bottom-color: var(--fm-line-2); }
html[data-theme="executive"] body .fmh-big b { color: var(--fm-ink); font-size: 30px; }
html[data-theme="executive"] body .fmh-step b { color: var(--fm-ink); }
html[data-theme="executive"] body .fmh-link:hover { background: #141f33; border-color: var(--fm-line); }
html[data-theme="executive"] body .fmh-search input { background: #0b1424; border-color: var(--fm-line-3); color: var(--fm-ink); }
html[data-theme="executive"] body .content-header-title { font-size: 1.55rem !important; color: var(--fm-ink); }
html[data-theme="executive"] body .content-header-title::before { display: none; }
html[data-theme="executive"] body .btn { border-radius: 10px; }
html[data-theme="executive"] body .btn-primary {
    background: #2563eb !important;
    border-color: #2563eb !important;
    box-shadow: 0 12px 26px -14px rgba(37, 99, 235, .85) !important;
}
html[data-theme="executive"] body .btn-secondary,
html[data-theme="executive"] body .btn-light {
    background: #0b1424 !important;
    border-color: var(--fm-line-3) !important;
    color: var(--fm-ink-2) !important;
}
html[data-theme="executive"] body .form-control,
html[data-theme="executive"] body .custom-select { background-color: #0b1424; border-color: var(--fm-line-3); }
html[data-theme="executive"] body .nav.nav-tabs .nav-item .nav-link { border-radius: 8px; }
html[data-theme="executive"] body .nav.nav-tabs .nav-item .nav-link.active {
    background: var(--fm-pri);
    color: #fff;
    box-shadow: none;
}
html[data-theme="executive"] body .app-content table:not(.picker__table):not(.table-condensed) > thead > tr > th { background: #0b1424 !important; color: #93a4bd !important; }
html[data-theme="executive"] body .app-content table > tbody > tr > td { color: #c9d5e8; border-top-color: #17233a; }
html[data-theme="executive"] body .app-content table.dataTable > tbody > tr:hover > td,
html[data-theme="executive"] body .app-content table.table-hover > tbody > tr:hover > td { background: #101d33 !important; }
html[data-theme="executive"] body .app-content .table-striped > tbody > tr:nth-of-type(odd) { background-color: #0b1424; }
html[data-theme="executive"] body .dataTables_wrapper .page-item .page-link { background: #0b1424; border-color: var(--fm-line-3); color: var(--fm-ink-2); }
html[data-theme="executive"] body .dataTables_wrapper .page-item.disabled .page-link { background: transparent; border-color: var(--fm-line); color: #5b6b86; }
html[data-theme="executive"] body .dataTables_wrapper .page-item.active .page-link { background: #2563eb; border-color: #2563eb; color: #fff; }
html[data-theme="executive"] body footer.erp-statusbar { background: #0a111f !important; border-top-color: #1a2740 !important; color: #8b9bb4; }
html[data-theme="executive"] body .fmh-tip { background: #16233c; color: #e2e8f0; }
html[data-theme="executive"] body .fmh-tip small { color: #94a3b8; }
html[data-theme="executive"] ::selection { background: rgba(59, 130, 246, .35); color: #f8fafc; }
html[data-theme="executive"] body .app-content::-webkit-scrollbar,
html[data-theme="executive"] body .ps__rail-y { background: transparent; }
html[data-theme="executive"] body .ps__thumb-y { background: #2b3b57; }
html[data-theme="executive"] body .custom-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%2394a3b8' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e");
}

/* Accent presets are chosen explicitly by the user, so they win over theme palettes. */
html[data-theme][data-accent="teal"] {
    --fm-pri-base: #0f766e; --fm-pri: #0f766e; --fm-pri-d: #0d655e; --fm-pri-50: #e9f3f2; --fm-pri-200: #c3dddb; --fm-pri-300: #87bbb7; --fm-pri-rgb: 15, 118, 110;
}
html[data-theme][data-accent="navy"] {
    --fm-pri-base: #1e3a5f; --fm-pri: #1e3a5f; --fm-pri-d: #172c49; --fm-pri-50: #eef2f7; --fm-pri-200: #cdd8e6; --fm-pri-300: #9db1c9; --fm-pri-rgb: 30, 58, 95;
}
html[data-theme][data-accent="blue"] {
    --fm-pri-base: #1f5fbf; --fm-pri: #1f5fbf; --fm-pri-d: #1a52a6; --fm-pri-50: #eaf1fb; --fm-pri-200: #c9d9f2; --fm-pri-300: #8fb2e6; --fm-pri-rgb: 31, 95, 191;
}
html[data-theme][data-accent="green"] {
    --fm-pri-base: #0f7b5f; --fm-pri: #0f7b5f; --fm-pri-d: #0d6851; --fm-pri-50: #e8f4f0; --fm-pri-200: #c3ded7; --fm-pri-300: #87bdaf; --fm-pri-rgb: 15, 123, 95;
}
html[data-theme][data-accent="violet"] {
    --fm-pri-base: #6941c6; --fm-pri: #6941c6; --fm-pri-d: #5937a8; --fm-pri-50: #f1ecfa; --fm-pri-200: #dad0f1; --fm-pri-300: #b4a0e3; --fm-pri-rgb: 105, 65, 198;
}
html[data-theme][data-accent="graphite"] {
    --fm-pri-base: #344054; --fm-pri: #344054; --fm-pri-d: #1d2939; --fm-pri-50: #eef0f3; --fm-pri-200: #cdd0d5; --fm-pri-300: #9aa0aa; --fm-pri-rgb: 52, 64, 84;
}

/* =========================================================================
   5. DISPLAY SETTINGS — density / radius / font scale / motion
   ========================================================================= */
html[data-density="compact"] body .app-content .content-wrapper { padding: 1rem 1.25rem 1.5rem; }
html[data-density="compact"] body .card { margin-bottom: .65rem; }
html[data-density="compact"] body .card .card-body { padding: .85rem 1rem; }
html[data-density="compact"] body .card .card-header { padding: .55rem 1rem; }
html[data-density="compact"] body .app-content table > thead > tr > th { padding: .4rem .5rem !important; }
html[data-density="compact"] body .app-content table > tbody > tr > td { padding: .35rem .5rem; }
html[data-density="compact"] body .form-group { margin-bottom: .65rem; }
html[data-density="compact"] body .form-control, html[data-density="compact"] body .custom-select { height: 32px; padding: .25rem .6rem; }
html[data-density="compact"] body .main-menu.menu-dark .navigation > li > a { min-height: 34px; }
html[data-density="compact"] body .erp-statusbar { display: none; }

html[data-radius="sharp"] {
    --fm-r-xs: 2px; --fm-r-sm: 3px; --fm-r-md: 4px; --fm-r-lg: 6px; --fm-r-xl: 8px;
    --erp-radius: 4px; --erp-radius-sm: 3px;
}
html[data-radius="sharp"] body .card,
html[data-radius="sharp"] body .btn,
html[data-radius="sharp"] body .form-control,
html[data-radius="sharp"] body .custom-select,
html[data-radius="sharp"] body .modal-content { border-radius: 4px !important; }
html[data-radius="round"] {
    --fm-r-xs: 8px; --fm-r-sm: 12px; --fm-r-md: 14px; --fm-r-lg: 18px; --fm-r-xl: 22px;
    --erp-radius: 16px; --erp-radius-sm: 10px;
}
html[data-radius="round"] body .card { border-radius: 16px !important; }
html[data-radius="round"] body .btn { border-radius: 10px !important; }
html[data-radius="round"] body .form-control,
html[data-radius="round"] body .custom-select { border-radius: 10px !important; }
html[data-radius="round"] body .modal-content { border-radius: 18px !important; }

html[data-font="s"] body .app-content { font-size: 12.5px; }
html[data-font="s"] body .app-content table > thead > tr > th { font-size: 10.5px !important; }
html[data-font="s"] body .app-content table > tbody > tr > td { font-size: 12px; }
html[data-font="s"] body .app-content .form-control, html[data-font="s"] body .app-content .custom-select { font-size: 12.5px; }
html[data-font="s"] body .app-content .content-header-title { font-size: 1.1rem !important; }
html[data-font="l"] body .app-content { font-size: 14.5px; }
html[data-font="l"] body .app-content table > thead > tr > th { font-size: 12px !important; }
html[data-font="l"] body .app-content table > tbody > tr > td { font-size: 14px; }
html[data-font="l"] body .app-content .form-control, html[data-font="l"] body .app-content .custom-select { font-size: 14.5px; }
html[data-font="l"] body .app-content .content-header-title { font-size: 1.35rem !important; }

html[data-motion="off"] body *,
html[data-motion="off"] body *::before,
html[data-motion="off"] body *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    scroll-behavior: auto !important;
}

/* Sidebar preference is applied by fm-theme.js with the app's existing
   menu-expanded / menu-collapsed body classes; nothing to override here. */

/* =========================================================================
   6. THEME STUDIO (window: ธีมและการแสดงผล)
   ========================================================================= */
.fmt-ov { backdrop-filter: blur(2px); }
.fmt-dlg.fms {
    max-width: 1020px;
    width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.fms-h { flex: 0 0 auto; }
.fms-h .fms-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fms-badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 999px;
             background: var(--fm-pri-50); color: var(--fm-pri-d); font-size: 11px; font-weight: 600; }
.fms-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 420px minmax(0, 1fr); }
.fms-left { min-height: 0; overflow: auto; padding: 4px 20px 18px; border-right: 1px solid var(--fm-line-2); }
.fms-right { min-height: 0; overflow: auto; background: var(--fm-surface-2); padding: 14px 18px 18px; }
.fms-sec { padding: 14px 0 2px; }
.fms-sec + .fms-sec { border-top: 1px solid var(--fm-line-2); }
.fms-lb { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px;
          font-size: 13px; font-weight: 600; color: var(--fm-ink); }
.fms-lb small { font-weight: 400; color: var(--fm-mute); font-size: 11.5px; }
.fms-gal { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fms-card { position: relative; text-align: left; padding: 0; border: 1px solid var(--fm-line); border-radius: 10px;
            background: var(--fm-surface); cursor: pointer; overflow: hidden; font: inherit; }
.fms-card:hover { border-color: var(--fm-line-3); }
.fms-card.on { border-color: var(--fm-pri); box-shadow: 0 0 0 2px var(--fm-pri-200, rgba(0,0,0,.08)); }
.fms-thumb { height: 86px; display: flex; padding: 8px; gap: 6px; position: relative; }
.fms-thumb .tl { width: 26%; border-radius: 4px; }
.fms-thumb .tr { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.fms-thumb .tr i { display: block; height: 8px; border-radius: 3px; }
.fms-thumb .tr .r2 { display: flex; gap: 5px; }
.fms-thumb .tr .r2 i { flex: 1; height: 24px; border-radius: 5px; }
.fms-th1 { background: #f2f6f3; }
.fms-th1 .tl { background: #fbfdfc; border: 1px solid #e3ebe6; border-radius: 6px; box-shadow: inset 3px 0 0 #10b981; }
.fms-th1 i { background: #e3ebe6; }
.fms-th1 .r2 i { border-radius: 8px; }
.fms-th1 .r2 i:first-child { background: #e6f7ef; }
.fms-th1 .r2 i:last-child { background: #fff; border: 1px solid #e3ebe6; }
.fms-th2 { background: #fafafa; }
.fms-th2 .tl { background: #fbfbfc; border: 1px solid #e4e4e7; }
.fms-th2 i { background: #efeff1; }
.fms-th2 .r2 i:first-child { background: #efeff1; }
.fms-th2 .r2 i:last-child { background: #fff; border: 1px solid #e4e4e7; }
.fms-th3 { background: #050a14; }
.fms-th3 .tl { background: #0a111f; }
.fms-th3 i { background: #1c2942; }
.fms-th3 .r2 i:first-child { background: #15264a; }
.fms-th3 .r2 i:last-child { background: #0d1526; }
.fms-th4 { background: #f5f8fa; }
.fms-th4 .tl { background: #fff; border: 1px solid #e5ebf1; box-shadow: inset 3px 0 0 #12a594; }
.fms-th4 i { background: #e5ebf1; }
.fms-th4 .r2 i:first-child { background: #12a594; }
.fms-th4 .r2 i:last-child { background: #fff; border: 1px solid #e5ebf1; }
.fms-nm { display: block; padding: 7px 9px; border-top: 1px solid var(--fm-line-2); }
.fms-nm b { display: block; font-size: 12px; color: var(--fm-ink); font-weight: 600; }
.fms-nm span { display: block; font-size: 10.5px; color: var(--fm-mute); line-height: 1.35; margin-top: 1px; }
.fms-card .fms-cur { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 999px;
                     background: var(--fm-pri); color: #fff; font-size: 11px; line-height: 18px; text-align: center; display: none; }
.fms-card.on .fms-cur { display: block; }
.fms-row { display: flex; flex-wrap: wrap; gap: 7px; }
.fms-opt { height: 32px; padding: 0 11px; border: 1px solid var(--fm-line); border-radius: 8px; background: var(--fm-surface);
           font: inherit; font-size: 12.5px; color: var(--fm-ink-2); cursor: pointer; }
.fms-opt:hover { background: var(--fm-surface-2); border-color: var(--fm-line-3); }
.fms-opt.on { border-color: var(--fm-pri); box-shadow: inset 0 0 0 1px var(--fm-pri); color: var(--fm-ink); font-weight: 500; }
.fms-opt:disabled { opacity: .45; cursor: not-allowed; }
.fms-ft { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--fm-line-2);
          background: var(--fm-surface); flex-wrap: wrap; }
.fms-ft .sp { flex: 1; }
.fms-msg { font-size: 12px; color: var(--fm-mute); min-height: 16px; }
.fms-msg.ok { color: #067647; }
.fms-msg.err { color: #d92d20; }
html[data-mode="dark"] .fms-msg.ok { color: #4ade9b; }
html[data-mode="dark"] .fms-msg.err { color: #f97066; }

/* Preview pane */
.fms-prev-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.fms-prev-h .t { font-size: 12.5px; font-weight: 600; color: var(--fm-ink); }
.fms-seg { display: inline-flex; padding: 2px; gap: 1px; border: 1px solid var(--fm-line); border-radius: 7px; background: var(--fm-surface); }
.fms-seg button { height: 24px; padding: 0 9px; border: 0; background: transparent; border-radius: 5px; font: inherit; font-size: 11.5px;
                  color: var(--fm-mute); cursor: pointer; }
.fms-seg button.on { background: var(--fm-pri-50); color: var(--fm-pri-d); font-weight: 600; }
.fms-dev { margin: 0 auto; display: flex; justify-content: center; }
.fms-dev .frame { width: 100%; border: 1px solid var(--fm-line); border-radius: 10px; background: var(--fm-surface);
                  box-shadow: 0 14px 30px -22px rgba(16,24,40,.4); overflow: hidden; transition: width .25s ease; }
.fms-dev[data-dev="tablet"] .frame { width: 460px; max-width: 100%; }
.fms-dev[data-dev="mobile"] .frame { width: 270px; max-width: 100%; }
html[data-motion="off"] .fms-dev .frame { transition: none; }
.fms-mock { display: flex; min-height: 300px; font-size: 10px; color: var(--fm-ink-3); background: var(--fm-bg); }
.fms-mock .mk-sb { width: 74px; flex: 0 0 74px; background: var(--fm-surface); border-right: 1px solid var(--fm-line); padding: 8px 6px; }
.fms-mock .mk-sb i { display: block; height: 7px; margin: 0 0 6px; border-radius: 3px; background: var(--fm-line-2); }
.fms-mock .mk-sb i.on { background: var(--fm-pri-50); box-shadow: inset 2px 0 0 var(--fm-pri); }
.fms-mock .mk-main { flex: 1; min-width: 0; padding: 9px 10px; }
.fms-mock .mk-top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.fms-mock .mk-top b { font-size: 10px; color: var(--fm-ink); font-weight: 600; }
.fms-mock .mk-top .sp { flex: 1; }
.fms-mock .mk-top span { display: block; width: 34px; height: 14px; border-radius: 4px; background: var(--fm-pri); }
.fms-mock .mk-kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.fms-mock .mk-kpi div { background: var(--fm-surface); border: 1px solid var(--fm-line); border-radius: 6px; padding: 6px; }
.fms-mock .mk-kpi u { display: block; height: 4px; width: 60%; border-radius: 2px; background: var(--fm-line-2); text-decoration: none; }
.fms-mock .mk-kpi b { display: block; font-size: 11px; margin-top: 4px; color: var(--fm-ink); }
.fms-mock .mk-chart { height: 74px; border: 1px solid var(--fm-line); border-radius: 6px; background: var(--fm-surface);
                     display: flex; align-items: flex-end; gap: 5px; padding: 8px; }
.fms-mock .mk-chart i { flex: 1; border-radius: 2px 2px 0 0; background: var(--fm-pri-200); }
.fms-mock .mk-chart i.hi { background: var(--fm-pri); }
.fms-mock .mk-tbl { border: 1px solid var(--fm-line); border-radius: 6px; background: var(--fm-surface); overflow: hidden; }
.fms-mock .mk-tbl .th, .fms-mock .mk-tbl .td { display: flex; gap: 6px; padding: 5px 6px; }
.fms-mock .mk-tbl .th { background: var(--fm-surface-2); border-bottom: 1px solid var(--fm-line); }
.fms-mock .mk-tbl .td { border-bottom: 1px solid var(--fm-line-2); }
.fms-mock .mk-tbl i { display: block; height: 5px; border-radius: 2px; background: var(--fm-line-2); flex: 1; }
.fms-mock .mk-tbl .th i { background: var(--fm-line-3); }
.fms-mock .mk-form label { display: block; font-size: 9px; color: var(--fm-mute); margin: 0 0 3px; }
.fms-mock .mk-form div { height: 16px; border: 1px solid var(--fm-line-3); border-radius: 4px; background: var(--fm-surface); margin-bottom: 7px; }
.fms-mock .mk-form button { height: 18px; width: 56px; border: 0; border-radius: 4px; background: var(--fm-pri); }
.fms-mock .mk-flow { display: flex; align-items: center; gap: 4px; margin: 4px 0 10px; }
.fms-mock .mk-flow i { width: 16px; height: 16px; border-radius: 999px; border: 2px solid var(--fm-ok); flex: 0 0 auto; }
.fms-mock .mk-flow i.pd { border-color: var(--fm-warn); }
.fms-mock .mk-flow u { flex: 1; height: 2px; background: var(--fm-line-2); }
.fms-mock .mk-apv { border: 1px solid var(--fm-line); border-radius: 6px; background: var(--fm-surface); padding: 6px; }
.fms-mock .mk-apv div { display: flex; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--fm-line-2); }
.fms-mock .mk-apv div:last-child { border-bottom: 0; }
.fms-mock .mk-apv i { width: 9px; height: 9px; border-radius: 999px; background: var(--fm-ok); margin-top: 2px; flex: 0 0 auto; }
.fms-mock .mk-apv i.pd { background: var(--fm-warn); }
.fms-mock .mk-apv u { display: block; height: 5px; border-radius: 2px; background: var(--fm-line-2); }
.fms-mock .mk-apv .g { flex: 1; }
html[data-theme="executive"] .fms-right { background: #020617; }
html[data-theme="executive"] .fms-dev .frame { box-shadow: 0 20px 40px -24px rgba(0,0,0,.9); }

@media (max-width: 920px) {
    .fms-body { grid-template-columns: 1fr; }
    .fms-left { border-right: 0; border-bottom: 1px solid var(--fm-line-2); }
    .fms-dlg.fms { width: calc(100vw - 20px); }
}

