:root {
    --app-navy: #10213d;
    --app-navy-soft: #253958;
    --app-teal: #10b9b2;
    --app-teal-dark: #079b98;
    --app-blue: #2f80ed;
    --app-blue-dark: #2268c8;
    --app-cyan-soft: #e8fbfa;
    --app-blue-soft: #eaf3ff;
    --app-surface: #ffffff;
    --app-bg: #f4f8fc;
    --app-border: #e2eaf3;
    --app-muted: #718096;
    --app-danger: #ef5b4c;
    --app-success: #0ca789;
    --app-warning: #f39b3d;
    --app-purple: #8a63e8;
    --sidebar-width: 274px;
    --sidebar-collapsed-width: 88px;
    --topbar-height: 88px;
    --shadow-sm: 0 6px 20px rgba(30, 64, 105, .07);
    --shadow-md: 0 14px 38px rgba(30, 64, 105, .11);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--app-navy);
    background: var(--app-bg);
    font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
    font-size: .95rem;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    text-decoration: none;
}

.money,
.tabular-number {
    font-variant-numeric: tabular-nums;
}

/* ------------------------------
   Application shell
------------------------------ */
.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    background: rgba(255, 255, 255, .98);
    border-right: 1px solid var(--app-border);
    box-shadow: 7px 0 28px rgba(35, 70, 110, .045);
    transition: width .24s ease, transform .24s ease;
}

.sidebar-brand {
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    gap: 13px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--app-border);
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, var(--app-teal), var(--app-blue));
    border-radius: 15px;
    box-shadow: 0 9px 22px rgba(22, 164, 190, .25);
}

.brand-mark i {
    font-size: 1.55rem;
}

.brand-copy {
    min-width: 0;
}

.brand-title {
    overflow: hidden;
    color: var(--app-navy);
    font-size: 1.22rem;
    font-weight: 800;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-subtitle {
    overflow: hidden;
    margin-top: 3px;
    color: var(--app-muted);
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-scroll {
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 14px 12px;
    scrollbar-width: thin;
    scrollbar-color: #cfd9e6 transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #cfd9e6;
    border-radius: 999px;
}

.sidebar-dashboard-link,
.sidebar-menu-link,
.sidebar-group-toggle,
.sidebar-collapse-button {
    display: flex;
    width: 100%;
    align-items: center;
    border: 0;
    border-radius: 12px;
    transition: color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.sidebar-dashboard-link {
    gap: 13px;
    min-height: 48px;
    margin-bottom: 10px;
    padding: 11px 14px;
    color: var(--app-navy-soft);
    font-weight: 700;
}

.sidebar-dashboard-link:hover,
.sidebar-dashboard-link.active {
    color: var(--app-blue-dark);
    background: linear-gradient(90deg, #e9f5ff, #eefbff);
}

.sidebar-dashboard-link.active {
    box-shadow: inset 4px 0 0 var(--app-blue);
}

.sidebar-icon {
    display: grid;
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    place-items: center;
    font-size: 1.08rem;
}

.sidebar-group {
    margin-bottom: 8px;
}

.sidebar-group-toggle {
    justify-content: space-between;
    gap: 8px;
    min-height: 46px;
    padding: 10px 12px;
    color: var(--app-navy-soft);
    background: transparent;
    font-weight: 700;
    text-align: left;
}

.sidebar-group-toggle:hover,
.sidebar-group-toggle:not(.collapsed) {
    color: var(--app-navy);
    background: #f5f9fd;
}

.sidebar-group-label {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 13px;
}

.sidebar-group-chevron {
    color: #6e819a;
    font-size: .75rem;
    transition: transform .18s ease;
}

.sidebar-group-toggle:not(.collapsed) .sidebar-group-chevron {
    transform: rotate(180deg);
}

.sidebar-submenu {
    padding: 3px 0 4px 42px;
}

.sidebar-menu-link {
    position: relative;
    gap: 9px;
    min-height: 39px;
    margin: 2px 0;
    padding: 8px 11px 8px 17px;
    color: #687b93;
    font-size: .9rem;
    font-weight: 500;
}

.sidebar-menu-link::before {
    position: absolute;
    left: 2px;
    width: 6px;
    height: 6px;
    content: "";
    background: #c6d2df;
    border-radius: 50%;
    transition: background-color .16s ease, transform .16s ease;
}

.sidebar-menu-link:hover,
.sidebar-menu-link.active {
    color: var(--app-blue-dark);
    background: #edf6ff;
}

.sidebar-menu-link.active::before {
    background: var(--app-blue);
    transform: scale(1.25);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--app-border);
}

.sidebar-collapse-button {
    gap: 12px;
    justify-content: flex-start;
    min-height: 44px;
    padding: 9px 14px;
    color: #6b7d93;
    background: transparent;
    font-weight: 600;
}

.sidebar-collapse-button:hover {
    color: var(--app-blue-dark);
    background: #edf6ff;
}

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left .24s ease;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 28px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--app-border);
    backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-right,
.user-trigger {
    display: flex;
    align-items: center;
}

.topbar-left {
    min-width: 0;
    gap: 16px;
}

.topbar-right {
    gap: 10px;
}

.icon-button {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    color: #5f728b;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 1.22rem;
    transition: .16s ease;
}

.icon-button:hover {
    color: var(--app-blue);
    background: #eff7ff;
    border-color: #dcecff;
}

.mobile-sidebar-toggle {
    display: none;
}

.desktop-sidebar-toggle {
    display: grid;
}

.topbar-heading {
    overflow: hidden;
}

.topbar-heading h1 {
    overflow: hidden;
    margin: 0;
    color: var(--app-navy);
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-heading p {
    overflow: hidden;
    margin: 3px 0 0;
    color: var(--app-muted);
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.language-chip {
    display: grid;
    min-width: 46px;
    height: 40px;
    place-items: center;
    color: var(--app-navy);
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    font-weight: 700;
}

.topbar-divider {
    width: 1px;
    height: 38px;
    margin: 0 3px;
    background: var(--app-border);
}

.user-trigger {
    gap: 10px;
    max-width: 245px;
    padding: 5px 7px 5px 6px;
    color: var(--app-navy);
    background: #fff;
    border: 0;
    border-radius: 14px;
}

.user-trigger:hover,
.user-trigger.show {
    background: #f3f8fd;
}

.user-avatar {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    color: var(--app-navy);
    background: linear-gradient(145deg, #eefbfa, #e8f2ff);
    border: 1px solid #d6e8f4;
    border-radius: 50%;
    font-size: 1.15rem;
}

.user-copy {
    min-width: 0;
    text-align: left;
}

.user-name,
.user-role {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-name {
    font-size: .9rem;
    font-weight: 700;
}

.user-role {
    color: var(--app-muted);
    font-size: .72rem;
}

.app-content {
    padding: 24px 28px 36px;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    display: none;
    background: rgba(10, 29, 51, .42);
    backdrop-filter: blur(2px);
}

/* Collapsed sidebar */
body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .sidebar-link-text,
body.sidebar-collapsed .sidebar-group-chevron,
body.sidebar-collapsed .sidebar-collapse-text {
    display: none;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-inline: 12px;
}

body.sidebar-collapsed .sidebar-dashboard-link,
body.sidebar-collapsed .sidebar-group-toggle,
body.sidebar-collapsed .sidebar-collapse-button {
    justify-content: center;
    padding-inline: 10px;
}

body.sidebar-collapsed .sidebar-submenu {
    display: none;
}

body.sidebar-collapsed .sidebar-collapse-button i {
    transform: rotate(180deg);
}

/* ------------------------------
   Shared cards, forms, tables
------------------------------ */
.content-card,
.dashboard-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.content-card .card-header,
.dashboard-card .card-header {
    padding: 17px 20px;
    background: transparent;
    border-bottom: 1px solid #edf1f6;
    color: var(--app-navy);
    font-weight: 750;
}

.content-card .card-body,
.dashboard-card .card-body {
    padding: 20px;
}

.metric {
    border-left: 0;
}

.form-label {
    color: #40526a;
    font-size: .85rem;
    font-weight: 650;
}

.form-control,
.form-select {
    min-height: 43px;
    color: var(--app-navy);
    background-color: #fff;
    border-color: #dbe5ef;
    border-radius: 10px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(47, 128, 237, .58);
    box-shadow: 0 0 0 .22rem rgba(47, 128, 237, .11);
}

.btn-dark,
.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--app-teal), var(--app-blue));
    border: 0;
    box-shadow: 0 7px 16px rgba(23, 141, 205, .18);
}

.btn-dark:hover,
.btn-primary:hover,
.btn-dark:focus,
.btn-primary:focus {
    color: #fff;
    background: linear-gradient(135deg, var(--app-teal-dark), var(--app-blue-dark));
}

.btn-outline-secondary {
    color: #60738c;
    border-color: #cfdae6;
}

.btn-outline-secondary:hover {
    color: var(--app-blue-dark);
    background: #edf6ff;
    border-color: #c7def9;
}

.table {
    --bs-table-color: #32455e;
    --bs-table-hover-bg: #f6faff;
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: .84rem .9rem;
    vertical-align: middle;
    border-bottom-color: #edf1f6;
}

.table thead th {
    color: #64778f;
    background: #f8fbfe;
    border-bottom-width: 1px;
    font-size: .78rem;
    font-weight: 750;
    letter-spacing: .01em;
    white-space: nowrap;
}

/* ตารางหน้ารายการ: หัวตารางชัดและแถวสลับสี ใช้เหมือนกันทั้งคอมและแท็บเล็ต */
.content-card .table-responsive > .table > thead > tr > th,
.dashboard-card .table-responsive > .table > thead > tr > th {
    --bs-table-bg: #d8ebff;
    --bs-table-color: #173a61;
    color: #173a61;
    background-color: #d8ebff;
    border-bottom: 2px solid #a9cdef;
    font-weight: 800;
}

.content-card .table-responsive > .table > tbody > tr:not([class*="table-"]):nth-child(odd) > *,
.dashboard-card .table-responsive > .table > tbody > tr:not([class*="table-"]):nth-child(odd) > * {
    --bs-table-bg: #ffffff;
    background-color: #ffffff;
}

.content-card .table-responsive > .table > tbody > tr:not([class*="table-"]):nth-child(even) > *,
.dashboard-card .table-responsive > .table > tbody > tr:not([class*="table-"]):nth-child(even) > * {
    --bs-table-bg: #eef6ff;
    background-color: #eef6ff;
}

.content-card .table-responsive > .table.table-hover > tbody > tr:not([class*="table-"]):hover > *,
.dashboard-card .table-responsive > .table.table-hover > tbody > tr:not([class*="table-"]):hover > * {
    --bs-table-bg: #dcecff;
    background-color: #dcecff;
}

/* ให้ข้อความในตารางอ่านเป็นคำ ไม่ถูกบีบแยกทีละตัวอักษรบนจอแคบ */
.table tbody td {
    line-height: 1.5;
    overflow-wrap: normal;
    word-break: normal;
}

.table-responsive {
    scrollbar-color: #b9c9da #f5f8fb;
    scrollbar-width: thin;
}

.table-responsive::-webkit-scrollbar {
    height: 9px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f5f8fb;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #b9c9da;
    border: 2px solid #f5f8fb;
    border-radius: 999px;
}

.alert {
    border: 0;
    border-radius: 13px;
    box-shadow: var(--shadow-sm);
}

.badge {
    border-radius: 999px;
    font-weight: 650;
}

/* ------------------------------
   Dashboard
------------------------------ */
.dashboard-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.summary-card {
    position: relative;
    display: flex;
    min-height: 130px;
    align-items: flex-start;
    gap: 15px;
    overflow: hidden;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card::after {
    position: absolute;
    right: -24px;
    bottom: -40px;
    width: 105px;
    height: 105px;
    content: "";
    background: var(--metric-soft, #edf7ff);
    border-radius: 50%;
    opacity: .7;
}

.summary-icon {
    position: relative;
    z-index: 1;
    display: grid;
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    place-items: center;
    color: #fff;
    background: var(--metric-gradient, linear-gradient(145deg, var(--app-teal), var(--app-blue)));
    border-radius: 50%;
    box-shadow: 0 9px 20px var(--metric-shadow, rgba(47, 128, 237, .18));
    font-size: 1.35rem;
}

.summary-content {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.summary-label {
    margin-bottom: 5px;
    color: #45576e;
    font-size: .88rem;
    font-weight: 650;
}

.summary-value {
    overflow: hidden;
    color: var(--app-navy);
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-trend {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 9px;
    color: var(--app-muted);
    font-size: .72rem;
}

.summary-trend.positive strong {
    color: var(--app-success);
}

.summary-trend.negative strong {
    color: var(--app-danger);
}

.metric-teal {
    --metric-gradient: linear-gradient(145deg, #21c5bb, #08a9a5);
    --metric-soft: #dffaf7;
    --metric-shadow: rgba(16, 185, 178, .22);
}

.metric-blue {
    --metric-gradient: linear-gradient(145deg, #438cf2, #276fd6);
    --metric-soft: #e3efff;
    --metric-shadow: rgba(47, 128, 237, .22);
}

.metric-purple {
    --metric-gradient: linear-gradient(145deg, #9a77ed, #7955d7);
    --metric-soft: #eee8ff;
    --metric-shadow: rgba(138, 99, 232, .2);
}

.metric-orange {
    --metric-gradient: linear-gradient(145deg, #ffb65d, #ee8734);
    --metric-soft: #fff0dc;
    --metric-shadow: rgba(243, 155, 61, .2);
}

.dashboard-chart-grid {
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.35fr);
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card {
    min-height: 410px;
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px 5px;
}

.chart-card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
}

.chart-card-subtitle {
    margin: 4px 0 0;
    color: var(--app-muted);
    font-size: .76rem;
}

.chart-body {
    position: relative;
    height: 315px;
    padding: 13px 18px 18px;
}

.doughnut-layout {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(215px, .9fr);
    gap: 12px;
    align-items: center;
    height: 100%;
}

.doughnut-canvas-wrap {
    position: relative;
    height: 250px;
}

.cost-list {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.cost-list-item {
    display: grid;
    grid-template-columns: 11px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    color: #53667e;
    font-size: .78rem;
}

.cost-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.cost-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-value {
    color: var(--app-navy);
    font-weight: 700;
    white-space: nowrap;
}

.cost-total {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--app-border);
    color: var(--app-navy);
    font-weight: 800;
}

.dashboard-mini-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.mini-status-card {
    display: flex;
    min-height: 112px;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 15px;
    box-shadow: var(--shadow-sm);
}

.mini-status-icon {
    display: grid;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    place-items: center;
    color: var(--mini-color, var(--app-blue));
    background: var(--mini-bg, var(--app-blue-soft));
    border-radius: 50%;
    font-size: 1.15rem;
}

.mini-status-label {
    color: #5a6e85;
    font-size: .75rem;
}

.mini-status-value {
    margin-top: 3px;
    color: var(--app-navy);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
}

.mini-status-link {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-top: 6px;
    color: var(--app-blue);
    font-size: .72rem;
    font-weight: 650;
}

.dashboard-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
    gap: 16px;
}

.empty-state {
    display: grid;
    min-height: 210px;
    place-items: center;
    color: var(--app-muted);
    text-align: center;
}

.empty-state i {
    display: block;
    margin-bottom: 8px;
    color: #bed0e3;
    font-size: 2.2rem;
}

/* ------------------------------
   Login
------------------------------ */
.login-page {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 9% 88%, rgba(20, 190, 185, .22), transparent 30%),
        radial-gradient(circle at 94% 8%, rgba(47, 128, 237, .16), transparent 28%),
        linear-gradient(120deg, #fbfdff 0%, #f3f8fd 48%, #edf4fc 100%);
}

.login-page::before,
.login-page::after {
    position: absolute;
    content: "";
    pointer-events: none;
}

.login-page::before {
    left: -120px;
    bottom: -180px;
    width: 440px;
    height: 440px;
    background: rgba(17, 190, 184, .12);
    border-radius: 50%;
}

.login-page::after {
    right: -130px;
    top: -180px;
    width: 500px;
    height: 500px;
    background: rgba(47, 128, 237, .08);
    border-radius: 50%;
}

.login-layout {
    position: relative;
    z-index: 1;
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1.08fr) minmax(440px, .72fr);
    gap: 42px;
    align-items: center;
    width: min(1500px, calc(100% - 70px));
    margin: 0 auto;
    padding: 48px 0;
}

.login-hero {
    padding: 24px 18px 24px 8px;
}

.login-brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 48px;
}

.login-brand .brand-mark {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
}

.login-brand-title {
    color: var(--app-navy);
    font-size: 1.55rem;
    font-weight: 850;
    line-height: 1.15;
}

.login-brand-subtitle {
    margin-top: 4px;
    color: var(--app-muted);
    font-size: .9rem;
}

.login-hero h1 {
    max-width: 720px;
    margin: 0;
    color: var(--app-navy);
    font-size: clamp(2rem, 4vw, 3.35rem);
    font-weight: 850;
    line-height: 1.28;
}

.login-hero h1 .accent-teal {
    color: var(--app-teal);
}

.login-hero h1 .accent-blue {
    color: var(--app-blue);
}

.login-hero-copy {
    max-width: 610px;
    margin: 22px 0 34px;
    color: #586c84;
    font-size: 1.05rem;
    line-height: 1.85;
}

.login-preview {
    position: relative;
    width: min(780px, 100%);
    overflow: hidden;
    padding: 18px;
    background: rgba(255, 255, 255, .72);
    border: 1px solid rgba(222, 233, 244, .9);
    border-radius: 21px;
    box-shadow: 0 24px 54px rgba(44, 90, 132, .12);
    backdrop-filter: blur(10px);
}

.preview-top {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.preview-metric {
    min-height: 78px;
    padding: 12px;
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: 12px;
    box-shadow: 0 5px 12px rgba(30, 64, 105, .055);
}

.preview-metric-label {
    color: #6f8197;
    font-size: .6rem;
}

.preview-metric-value {
    margin-top: 6px;
    color: var(--app-navy);
    font-size: .78rem;
    font-weight: 800;
}

.preview-content {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 12px;
}

.preview-panel {
    min-height: 205px;
    padding: 15px;
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: 13px;
}

.preview-panel-title {
    color: #53677f;
    font-size: .62rem;
    font-weight: 750;
}

.preview-donut {
    position: relative;
    width: 124px;
    height: 124px;
    margin: 20px auto 8px;
    background: conic-gradient(var(--app-teal) 0 35%, #169db4 35% 60%, var(--app-blue) 60% 78%, #1e4f8d 78% 90%, #b8def5 90% 100%);
    border-radius: 50%;
}

.preview-donut::after {
    position: absolute;
    inset: 36px;
    content: "";
    background: #fff;
    border-radius: 50%;
}

.preview-bars {
    display: flex;
    height: 145px;
    align-items: flex-end;
    justify-content: space-around;
    gap: 10px;
    padding-top: 18px;
    border-bottom: 1px solid #dce6f0;
}

.preview-bar-group {
    display: flex;
    height: 100%;
    align-items: flex-end;
    gap: 5px;
}

.preview-bar {
    width: 13px;
    background: var(--app-teal);
    border-radius: 5px 5px 0 0;
}

.preview-bar.blue {
    background: var(--app-blue);
}

.login-card {
    position: relative;
    padding: 44px 44px 30px;
    background: rgba(255, 255, 255, .95);
    border: 1px solid rgba(222, 232, 243, .95);
    border-radius: 24px;
    box-shadow: 0 28px 70px rgba(35, 70, 110, .15);
    backdrop-filter: blur(12px);
}

.login-card h2 {
    margin: 0;
    color: var(--app-navy);
    font-size: 2rem;
    font-weight: 850;
}

.login-card-intro {
    margin: 10px 0 30px;
    color: var(--app-muted);
}

.login-field {
    position: relative;
}

.login-field .form-control {
    min-height: 54px;
    padding-left: 48px;
    border-radius: 12px;
}

.login-field-icon {
    position: absolute;
    z-index: 3;
    left: 16px;
    top: 50%;
    color: #7b8ca1;
    font-size: 1.05rem;
    transform: translateY(-50%);
}

.password-toggle {
    position: absolute;
    z-index: 3;
    right: 10px;
    top: 50%;
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #788aa1;
    background: transparent;
    border: 0;
    border-radius: 9px;
    transform: translateY(-50%);
}

.password-toggle:hover {
    color: var(--app-blue);
    background: #eef6ff;
}

.login-submit {
    min-height: 55px;
    margin-top: 8px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 750;
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.login-help-text {
    color: var(--app-blue);
    font-size: .85rem;
}

.demo-separator {
    display: flex;
    align-items: center;
    gap: 13px;
    margin: 27px 0 20px;
    color: #8796a9;
    font-size: .78rem;
}

.demo-separator::before,
.demo-separator::after {
    height: 1px;
    flex: 1;
    content: "";
    background: var(--app-border);
}

.demo-accounts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    background: #f8fbfe;
    border: 1px solid var(--app-border);
    border-radius: 14px;
}

.demo-account {
    min-width: 0;
    padding: 14px 12px;
    color: inherit;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--app-border);
    text-align: left;
}

.demo-account:last-child {
    border-right: 0;
}

.demo-account:hover {
    background: #eef7ff;
}

.demo-account-role {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--app-navy);
    font-size: .78rem;
    font-weight: 750;
}

.demo-account-email,
.demo-account-password {
    overflow: hidden;
    margin-top: 7px;
    color: #667990;
    font-size: .62rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.login-footer {
    margin-top: 24px;
    color: #91a0b1;
    font-size: .7rem;
    text-align: center;
}

/* ------------------------------
   Responsive
------------------------------ */
@media (max-width: 1299.98px) {
    .dashboard-summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-mini-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .login-layout {
        grid-template-columns: minmax(0, 1fr) minmax(420px, .78fr);
        width: min(1320px, calc(100% - 50px));
        gap: 26px;
    }
}

@media (max-width: 1099.98px) {
    .dashboard-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-chart-grid,
    .dashboard-detail-grid {
        grid-template-columns: 1fr;
    }

    .login-layout {
        grid-template-columns: 1fr;
        width: min(720px, calc(100% - 38px));
    }

    .login-hero {
        padding-bottom: 0;
    }

    .login-brand {
        margin-bottom: 30px;
    }

    .login-preview {
        display: none;
    }
}

/* แท็บเล็ตใช้เมนูแบบเลื่อนออก แม้รุ่นจอใหญ่จะมีความกว้างเกิน 1200px */
@media (max-width: 1199.98px), (hover: none) and (pointer: coarse) {
    .app-sidebar {
        width: min(300px, 86vw);
        transform: translateX(-102%);
    }

    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-mobile-open .sidebar-backdrop {
        display: block;
    }

    .app-main,
    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }

    body.sidebar-collapsed .app-sidebar {
        width: min(300px, 86vw);
    }

    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .sidebar-link-text,
    body.sidebar-collapsed .sidebar-group-chevron,
    body.sidebar-collapsed .sidebar-collapse-text {
        display: block;
    }

    body.sidebar-collapsed .sidebar-brand,
    body.sidebar-collapsed .sidebar-dashboard-link,
    body.sidebar-collapsed .sidebar-group-toggle,
    body.sidebar-collapsed .sidebar-collapse-button {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .sidebar-submenu {
        display: block;
    }

    .desktop-sidebar-toggle,
    .sidebar-footer {
        display: none !important;
    }

    .mobile-sidebar-toggle {
        display: grid !important;
    }

    .app-topbar {
        min-height: 72px;
        padding: 12px 18px;
    }

    .app-content {
        padding: 20px 18px 30px;
    }
}

@media (max-width: 767.98px) {
    .topbar-heading p,
    .language-chip,
    .topbar-divider,
    .user-copy,
    .topbar-settings {
        display: none;
    }

    .app-topbar {
        gap: 10px;
    }

    .topbar-right {
        gap: 3px;
    }

    .user-trigger {
        padding: 2px;
    }

    .dashboard-summary-grid,
    .dashboard-mini-grid {
        grid-template-columns: 1fr;
    }

    .summary-card {
        min-height: 112px;
    }

    .doughnut-layout {
        grid-template-columns: 1fr;
    }

    .chart-card {
        min-height: auto;
    }

    .chart-body {
        height: auto;
        min-height: 300px;
    }

    .doughnut-canvas-wrap {
        height: 220px;
    }

    .login-layout {
        width: min(100% - 24px, 650px);
        padding: 22px 0;
    }

    .login-hero {
        padding: 8px 5px 0;
    }

    .login-brand {
        margin-bottom: 22px;
    }

    .login-hero h1 {
        font-size: 1.9rem;
    }

    .login-hero-copy {
        margin: 15px 0 22px;
        font-size: .92rem;
    }

    .login-card {
        padding: 30px 22px 23px;
        border-radius: 19px;
    }

    .login-card h2 {
        font-size: 1.65rem;
    }

    .demo-accounts {
        grid-template-columns: 1fr;
    }

    .demo-account {
        border-right: 0;
        border-bottom: 1px solid var(--app-border);
    }

    .demo-account:last-child {
        border-bottom: 0;
    }
}

/* แดชบอร์ดหลายช่วงเวลาและหน้าประวัติระบบ */
.dashboard-period-tabs .btn {
    min-width: 5.5rem;
    font-weight: 600;
}

.audit-detail {
    width: min(34rem, 75vw);
    max-height: 22rem;
    overflow: auto;
}

.audit-detail pre {
    color: #40546a;
    font-family: \"Noto Sans Thai\", \"Leelawadee UI\", Tahoma, sans-serif;
    font-size: .75rem;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 575.98px) {
    .dashboard-period-tabs {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-period-tabs .btn {
        min-width: 0;
        padding-inline: .65rem;
    }
}

@media (max-width: 479.98px) {
    .app-content {
        padding-inline: 12px;
    }

    .app-topbar {
        padding-inline: 12px;
    }

    .summary-value {
        font-size: 1.2rem;
    }
}


/* Tax and document features */
.tax-feature-icon {
    display: grid;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, var(--app-teal), var(--app-blue));
    border-radius: 14px;
    font-size: 1.25rem;
    box-shadow: 0 9px 22px rgba(22, 164, 190, .2);
}

.tax-report-table th,
.tax-report-table td {
    white-space: nowrap;
}

.print-report-heading {
    display: none;
}

@media print {
    .print-report-heading {
        display: block;
    }
}

/* VAT future-ready patch */
.vat-status-panel {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid #dbe5ef;
    border-radius: 1rem;
    background: #f8fbfd;
}

.vat-status-panel.is-active {
    border-color: #b9e6d7;
    background: #effbf6;
}

.vat-status-panel.is-inactive {
    border-color: #d9e2ec;
    background: #f7f9fc;
}

.vat-status-icon,
.vat-readiness-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: .9rem;
    color: #0f8f8a;
    background: #e4f8f5;
    font-size: 1.25rem;
}

.vat-readiness-card {
    overflow: hidden;
    border: 1px solid #dce8f2;
    background: linear-gradient(135deg, #ffffff 0%, #f5fbfc 100%);
}

.vat-threshold-progress {
    height: .7rem;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef4;
}

.sidebar-menu-link .badge {
    font-size: .62rem;
    font-weight: 600;
}

/* ตารางซื้อ ขาย และขนส่ง: แยกเลขที่เอกสารกับปริมาณให้อ่านง่าย */
.doc-number-column,
.doc-number-cell {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
}

.doc-number-cell {
    background: transparent !important;
    line-height: 1.35;
}

.document-number-copy {
    display: inline-block;
    width: auto;
    max-width: 100%;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: #204d82;
    font-weight: 650;
    line-height: 1.4;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    overflow-wrap: anywhere;
    white-space: normal;
}

.document-number-copy:hover,
.document-number-copy:focus-visible {
    color: #0875dd;
    text-decoration: underline;
}

.document-number-reference {
    margin-top: .2rem;
    font-size: .76rem;
    font-weight: 500;
}

.quantity-cell {
    min-width: 105px;
    color: var(--bs-body-color);
    font-weight: 600;
    white-space: nowrap;
}

.document-number-plain {
    display: inline-block;
    max-width: 180px;
    color: #204d82;
    font-weight: 650;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

/* ตารางธุรกรรมมีหลายคอลัมน์ จึงรักษาความกว้างให้อ่านง่ายและเลื่อนเฉพาะในกรอบตาราง */
.transaction-table {
    min-width: 1180px;
}

.transaction-table td:nth-child(3),
.transaction-table td:nth-child(4) {
    min-width: 155px;
}

.transaction-table td:nth-child(4) {
    min-width: 210px;
}

.transaction-table td:last-child {
    min-width: 180px;
}

.transaction-table .text-end,
.transaction-table td:last-child,
.transaction-table .quantity-cell {
    white-space: nowrap;
}

/* ตัวเลือกหน้าแบบกระชับ: แสดงจำนวนรายการและปุ่มก่อนหน้า/เลขหน้า/ถัดไป */
.app-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .85rem;
    padding: .85rem 1rem;
    background: #fff;
    border-top: 1px solid var(--app-border);
}

.app-pagination-summary {
    color: var(--app-muted);
    font-size: .78rem;
    white-space: nowrap;
}

.app-pagination .pagination {
    gap: .2rem;
}

.app-pagination nav {
    margin-left: auto;
}

.app-pagination .page-link {
    display: grid;
    min-width: 38px;
    height: 38px;
    padding: 0 .65rem;
    place-items: center;
    color: #34506f;
    background: #fff;
    border-color: #dbe5ef;
    border-radius: 9px !important;
    font-weight: 650;
}

.app-pagination .page-item.active .page-link {
    color: #fff;
    background: linear-gradient(135deg, var(--app-teal), var(--app-blue));
    border-color: transparent;
    box-shadow: 0 6px 14px rgba(47, 128, 237, .18);
}

.app-pagination .page-item.disabled .page-link {
    color: #a0afbf;
    background: #f6f8fa;
}

/* ตารางสินค้าและคลัง: ล็อกโครงคอลัมน์ให้ทุกการ์ดตรงแนวกัน */
.catalog-table {
    width: 100%;
    table-layout: fixed;
}

.catalog-table th,
.catalog-table td {
    padding: .82rem .9rem;
    vertical-align: middle;
}

.catalog-table th {
    white-space: nowrap;
}

.catalog-table .text-end,
.catalog-table td:last-child {
    white-space: nowrap;
}

.product-catalog-table {
    min-width: 1180px;
}

.product-catalog-table.has-actions {
    min-width: 1400px;
}

.inventory-catalog-table {
    min-width: 1200px;
}

.catalog-col-code { width: 100px; }
.catalog-col-variant { width: 145px; }
.catalog-col-variant-wide { width: 190px; }
.catalog-col-detail { width: 190px; }
.catalog-col-stock { width: 110px; }
.catalog-col-reserved { width: 105px; }
.catalog-col-available { width: 120px; }
.catalog-col-minimum { width: 90px; }
.catalog-col-cost { width: 120px; }
.catalog-col-price { width: 110px; }
.catalog-col-value { width: 130px; }
.catalog-col-formula { width: 110px; }
.catalog-col-status { width: 140px; }
.catalog-col-action-compact { width: 90px; }
.catalog-col-actions { width: 210px; }

.production-history-filter {
    background: #fbfdff;
}

@media (max-width: 767.98px) {
    .production-history-filter .form-label {
        margin-bottom: .25rem;
    }
}

/* หน้าคู่มือการใช้งาน */
.help-toolbar {
    position: sticky;
    top: 84px;
    z-index: 12;
}

.help-accordion {
    display: grid;
    gap: .85rem;
}

.help-accordion .accordion-item {
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
}

.help-accordion .accordion-button {
    gap: .8rem;
    padding: 1rem 1.15rem;
    color: var(--app-text);
    font-weight: 700;
}

.help-accordion .accordion-button:not(.collapsed) {
    color: #087f8c;
    background: #eefbfc;
    box-shadow: none;
}

.help-guide-icon {
    display: inline-grid;
    width: 2.35rem;
    height: 2.35rem;
    flex: 0 0 2.35rem;
    place-items: center;
    color: #087f8c;
    background: #e3f7f8;
    border-radius: .75rem;
    font-size: 1.1rem;
}

.help-steps {
    margin-bottom: 1rem;
    padding-left: 1.35rem;
}

.help-steps li + li {
    margin-top: .65rem;
}

.help-result,
.help-warning {
    padding: .8rem .9rem;
    border-radius: .75rem;
}

.help-result {
    color: #126b55;
    background: #ecf9f4;
}

.help-warning {
    margin-top: .65rem;
    color: #7a5900;
    background: #fff7dc;
}

/* ทำให้ปุ่มและฟอร์มหลักใช้งานบนแท็บเล็ตได้สะดวกขึ้น */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .app-content {
        padding: 18px 16px 28px;
    }

    .content-card .table-responsive > .table {
        min-width: 880px;
    }

    .content-card .table-responsive > .transaction-table {
        min-width: 1180px;
    }

    .modal-xl {
        --bs-modal-width: calc(100vw - 2rem);
    }

    .btn,
    .form-control,
    .form-select {
        min-height: 42px;
    }

    .help-toolbar {
        top: 78px;
    }
}

@media (max-width: 767.98px) {
    .doc-number-column,
    .doc-number-cell {
        width: 130px;
        min-width: 130px;
        max-width: 130px;
    }

    .help-toolbar {
        position: static;
    }

    .help-accordion .accordion-button {
        padding: .85rem;
    }

    .app-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .app-pagination-summary {
        text-align: center;
    }

    .app-pagination nav,
    .app-pagination .pagination {
        justify-content: center;
    }
}

/* คู่มือแบบมีภาพประกอบ: แยกหมวด ขั้นตอน และภาพจำลองเพื่ออ่านง่ายบนแท็บเล็ต */
.manual-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.35rem;
    color: #10334b;
    background: linear-gradient(130deg, #f1fcfb 0%, #f3f8ff 100%);
}

.manual-hero-main,
.manual-search-header,
.manual-flow-list,
.manual-category-list {
    display: flex;
    align-items: center;
}

.manual-hero-main {
    gap: .9rem;
}

.manual-hero-icon,
.manual-flow-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: #087f8c;
    background: #def5f3;
    border-radius: .9rem;
}

.manual-hero-icon {
    width: 3.4rem;
    height: 3.4rem;
    font-size: 1.55rem;
}

.manual-hero-title {
    margin: 0;
    font-size: 1.22rem;
    font-weight: 750;
}

.manual-hero-meta,
.manual-hero-badge,
.manual-guide-category,
.manual-image-caption,
.manual-flow-note {
    font-size: .8rem;
}

.manual-hero-meta,
.manual-guide-category,
.manual-image-caption {
    color: #688095;
}

.manual-hero-badge {
    padding: .48rem .72rem;
    color: #087f8c;
    background: rgba(255, 255, 255, .85);
    border-radius: 999px;
    white-space: nowrap;
}

.manual-flow-card {
    padding: 1rem 1.15rem;
}

.manual-flow-title,
.manual-instructions-title {
    margin-bottom: .8rem;
    color: #294156;
    font-weight: 700;
}

.manual-flow-list {
    flex-wrap: wrap;
    gap: .55rem;
}

.manual-flow-step {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    padding: .35rem .6rem;
    color: #234059;
    background: #f5f9fc;
    border: 1px solid #e2ebf2;
    border-radius: .75rem;
    font-size: .79rem;
    white-space: nowrap;
}

.manual-flow-icon {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: .5rem;
}

.manual-flow-arrow {
    color: #9eb0bf;
    font-size: .75rem;
}

.manual-flow-note {
    margin-top: .8rem;
    color: #866214;
}

.manual-search-header {
    justify-content: space-between;
}

.manual-visible-count {
    color: #087f8c;
    font-size: .84rem;
    font-weight: 650;
}

.manual-category-list {
    flex-wrap: wrap;
    gap: .48rem;
}

.manual-category-button {
    padding: .42rem .72rem;
    color: #566e81;
    background: #fff;
    border: 1px solid #dae5ec;
    border-radius: 999px;
    font-size: .79rem;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.manual-category-button:hover,
.manual-category-button.active {
    color: #087f8c;
    background: #eaf9f7;
    border-color: #90d6cf;
}

.manual-accordion-heading {
    display: grid;
    gap: .12rem;
    min-width: 0;
}

.manual-guide-title {
    line-height: 1.25;
}

.manual-guide-category {
    font-weight: 400;
}

.manual-guide-page {
    margin-left: auto;
    padding-right: .6rem;
    color: #91a1af;
    font-size: .8rem;
    font-weight: 500;
}

.manual-guide-body {
    padding: 1.05rem 1.15rem 1.2rem;
}

.manual-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr);
    align-items: start;
    gap: 1.3rem;
}

.manual-figure {
    min-width: 0;
}

.manual-screen-preview,
.manual-real-image-button {
    overflow: hidden;
    width: 100%;
    border: 1px solid #dbe6ef;
    border-radius: .85rem;
    box-shadow: 0 8px 24px rgba(23, 51, 78, .07);
}

.manual-real-image-button {
    padding: 0;
    background: #fff;
    text-align: left;
}

.manual-real-image,
.manual-expanded-image {
    display: block;
    width: 100%;
    height: auto;
}

.manual-window-top {
    display: flex;
    align-items: center;
    gap: .3rem;
    min-height: 2.1rem;
    padding: 0 .7rem;
    background: #f3f7fa;
    border-bottom: 1px solid #e3ebf1;
}

.manual-window-top > span {
    width: .48rem;
    height: .48rem;
    background: #d2dce5;
    border-radius: 50%;
}

.manual-window-top > span:first-child {
    background: #f0aaa1;
}

.manual-window-top > span:nth-child(2) {
    background: #e7cd88;
}

.manual-window-top > span:nth-child(3) {
    background: #96c9ae;
}

.manual-window-top > strong {
    overflow: hidden;
    margin-left: .48rem;
    color: #62778a;
    font-size: .7rem;
    font-weight: 550;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manual-window-shell {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr);
    min-height: 15.5rem;
}

.manual-window-sidebar {
    display: grid;
    align-content: start;
    justify-items: center;
    gap: 1rem;
    padding: .8rem 0;
    color: #8394a4;
    background: #f9fbfc;
    border-right: 1px solid #e4ebf1;
    font-size: .82rem;
}

.manual-window-sidebar .active {
    color: #087f8c;
}

.manual-window-main {
    position: relative;
    min-width: 0;
    padding: .82rem .8rem;
    background: #fff;
}

.manual-window-heading {
    overflow: hidden;
    color: #284157;
    font-size: .85rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manual-window-controls {
    display: flex;
    flex-wrap: wrap;
    gap: .36rem;
    margin-top: .75rem;
}

.manual-control-pill {
    max-width: 100%;
    padding: .24rem .45rem;
    overflow: hidden;
    color: #4d667a;
    background: #f5f9fc;
    border: 1px solid #e0e9f0;
    border-radius: .45rem;
    font-size: .61rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manual-window-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .38rem;
    margin-top: .8rem;
}

.manual-window-metrics > span {
    height: 2.2rem;
    background: linear-gradient(135deg, #f1fbfa, #f3f8fd);
    border: 1px solid #e3edf1;
    border-radius: .44rem;
}

.manual-window-table {
    overflow: hidden;
    margin-top: .75rem;
    border: 1px solid #e4edf2;
    border-radius: .42rem;
}

.manual-window-table > div {
    display: grid;
    grid-template-columns: 1.3fr .7fr .7fr;
    gap: .3rem;
    min-height: 1.5rem;
    align-items: center;
    padding: .18rem .38rem;
    color: #73879a;
    background: #fff;
    border-top: 1px solid #edf2f5;
    font-size: .59rem;
}

.manual-window-table > div:first-child {
    background: #f5f8fa;
    border-top: 0;
}

.manual-window-table > div:not(:first-child) > span {
    width: 80%;
    height: .32rem;
    background: #e5edf2;
    border-radius: 999px;
}

.manual-screen-marker {
    position: absolute;
    display: grid;
    width: 1.35rem;
    height: 1.35rem;
    place-items: center;
    color: #fff;
    background: #078a89;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 7px rgba(7, 138, 137, .32);
    font-size: .66rem;
    font-weight: 700;
}

.manual-screen-marker.marker-one {
    top: .72rem;
    right: .6rem;
}

.manual-screen-marker.marker-two {
    top: 4.15rem;
    right: 1rem;
}

.manual-screen-marker.marker-three {
    right: 1.25rem;
    bottom: 1rem;
}

.manual-image-caption {
    margin-top: .55rem;
    text-align: center;
}

.manual-step-list {
    display: grid;
    gap: .82rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.manual-step-list > li {
    display: flex;
    align-items: flex-start;
    gap: .62rem;
}

.manual-step-index {
    display: grid;
    width: 1.6rem;
    height: 1.6rem;
    flex: 0 0 1.6rem;
    place-items: center;
    color: #087f8c;
    background: #e6f7f5;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 700;
}

.manual-step-list strong {
    display: block;
    color: #30495d;
    font-size: .88rem;
}

.manual-step-description {
    display: block;
    margin-top: .1rem;
    color: #637788;
    font-size: .8rem;
    line-height: 1.5;
}

.manual-result-card,
.manual-warning-card {
    display: flex;
    align-items: flex-start;
    gap: .52rem;
    padding: .67rem .72rem;
    border-radius: .68rem;
    font-size: .78rem;
    line-height: 1.5;
}

.manual-result-card {
    color: #17664f;
    background: #eefaf3;
}

.manual-warning-card {
    margin-top: .55rem;
    color: #765608;
    background: #fff8e6;
}

.manual-expanded-image {
    max-height: calc(100vh - 10rem);
    object-fit: contain;
}

@media (max-width: 991.98px) {
    .manual-detail-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .manual-window-shell {
        min-height: 14rem;
    }

    .manual-window-main {
        padding-inline: 1rem;
    }
}

@media (max-width: 767.98px) {
    .manual-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 1rem;
    }

    .manual-hero-title {
        font-size: 1.08rem;
    }

    .manual-hero-meta {
        font-size: .74rem;
    }

    .manual-flow-card,
    .manual-guide-body {
        padding: .9rem;
    }

    .manual-flow-arrow {
        display: none;
    }

    .manual-category-button {
        min-height: 38px;
    }

    .manual-guide-page {
        padding-right: .2rem;
    }

    .manual-window-shell {
        min-height: 13rem;
    }
}

/* คู่มือภาพจริง: หมายเลขบนรูปเชื่อมกับคำอธิบายรายช่องด้านล่าง */
.sidebar-manual-link {
    margin-top: .35rem;
}

.manual-annotated-image {
    position: relative;
    overflow: hidden;
    border-radius: .85rem;
}

.manual-hotspot {
    position: absolute;
    z-index: 2;
    display: grid;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 2px solid #fff;
    border-radius: 50%;
    background: linear-gradient(135deg, #11aa98, #2c76dc);
    box-shadow: 0 2px 9px rgba(17, 42, 73, .36);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    place-items: center;
}

.manual-hotspot:hover,
.manual-hotspot:focus-visible {
    z-index: 3;
    transform: translate(-50%, -50%) scale(1.15);
    outline: 3px solid rgba(50, 125, 235, .28);
}

.manual-example-card {
    margin-top: 1rem;
    padding: .8rem 1rem;
    border: 1px solid #cde9df;
    border-radius: .8rem;
    background: #effbf7;
    color: #245d4e;
    font-size: .88rem;
}

.manual-field-section {
    margin-top: 1.35rem;
    padding-top: 1.15rem;
    border-top: 1px solid #e8eef5;
}

.manual-field-heading {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .85rem;
    color: #183a64;
    font-size: .96rem;
    font-weight: 700;
}

.manual-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .7rem;
}

.manual-field-card {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    min-width: 0;
    padding: .72rem .82rem;
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
    border: 1px solid #e5edf4;
    border-radius: .78rem;
    background: #fff;
}

.manual-field-card.is-highlighted {
    border-color: #36a89a;
    background: #eefbf8;
    box-shadow: 0 0 0 3px rgba(33, 168, 145, .12);
}

.manual-field-number {
    display: grid;
    flex: 0 0 1.6rem;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #11aa98, #2c76dc);
    color: #fff;
    font-size: .76rem;
    font-weight: 700;
    place-items: center;
}

.manual-field-title {
    margin-bottom: .2rem;
    color: #1c3558;
    font-size: .87rem;
    font-weight: 700;
}

.manual-field-card strong {
    display: block;
    margin-bottom: .16rem;
    color: #1c3558;
    font-size: .86rem;
}

.manual-field-description {
    display: block;
    color: #617089;
    font-size: .8rem;
    line-height: 1.55;
}

.manual-zoom-controls {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.manual-image-viewport {
    overflow: auto;
    max-height: calc(100vh - 11rem);
    border-radius: .5rem;
    background: #f3f6fa;
}

.manual-expanded-image {
    max-width: none;
    max-height: none;
    object-fit: initial;
}

@media (max-width: 767.98px) {
    .manual-field-grid {
        grid-template-columns: 1fr;
    }

    .manual-hotspot {
        width: 1.35rem;
        height: 1.35rem;
        border-width: 1px;
        font-size: .64rem;
    }

    .manual-zoom-controls {
        gap: .2rem;
    }

    .manual-zoom-controls .btn {
        padding: .22rem .4rem;
        font-size: .72rem;
    }
}

/* Review update: readable 16 CSS px at browser defaults, with user zoom preserved. */
@media screen {
    html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    body.app-shell, body.login-page { font-size: 1rem; line-height: 1.6; }
    .app-shell .table, .app-shell .form-control, .app-shell .form-select,
    .app-shell .form-label, .app-shell .form-check-label, .app-shell .btn,
    .app-shell .dropdown-item, .app-shell .page-link, .app-shell .sidebar-menu-link,
    .app-shell .sidebar-link-text, .app-shell .sidebar-footer-toggle,
    .login-page .form-control, .login-page .form-label, .login-page .btn { font-size: 1rem; line-height: 1.6; }
    .app-shell .table > :not(caption) > * > * { padding: .75rem .85rem; }
    .app-shell .table thead th { background: #d8eafb; color: #153d68; font-weight: 700; }
    .app-shell .table tbody tr:nth-child(odd) > td { --bs-table-bg: #fff; }
    .app-shell .table tbody tr:nth-child(even) > td { --bs-table-bg: #f0f7ff; }
    .app-shell .small, .app-shell small, .app-shell .badge,
    .app-shell .form-text, .app-shell .summary-label, .app-shell .summary-trend,
    .app-shell .mini-status-label, .app-shell .brand-subtitle { font-size: .875rem; line-height: 1.55; }
    .app-shell .topbar-heading h1 { font-size: clamp(1.5rem, 2vw, 1.75rem); line-height: 1.5; }
    .app-shell .btn, .app-shell .page-link { min-height: 44px; }
    .app-shell .btn-close { min-height: 1rem; }
    .app-shell .form-control, .app-shell .form-select { min-height: 44px; }
    .app-shell .table-responsive { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
    .app-shell .table { table-layout: auto; }
    .app-shell .table th { white-space: nowrap; }
    .app-shell .table td { word-break: normal; overflow-wrap: break-word; }
    .app-shell .document-number, .app-shell .document-number-plain { background: transparent; box-shadow: none; color: #1365a0; white-space: nowrap; }
    .app-shell .table td.text-end { white-space: nowrap; }
    .app-shell .table td .small, .app-shell .table td .badge { white-space: normal; }
    .app-shell .table td .badge { display: inline-block; max-width: 100%; }
    .role-readonly { background: #edf6ff; color: #214e79; border: 1px solid #bfd9ee; border-radius: .75rem; padding: .8rem 1rem; }
    .quick-filter-group { border: 1px solid #d9e5f2; background: #fff; border-radius: .8rem; padding: .85rem; }
    .quick-filter-label { display: block; font-weight: 600; margin-bottom: .5rem; }
    .quick-filter-options { display: flex; flex-wrap: wrap; gap: .5rem; }
    .quick-filter { display: inline-flex; align-items: center; gap: .5rem; max-width: 100%; text-align: left; white-space: normal; }
    .filter-count { border-radius: 1rem; padding: 0 .5rem; background: rgba(100,150,210,.14); font-size: .875rem; flex-shrink: 0; }
    .btn-primary .filter-count { background: rgba(255,255,255,.2); }
    .required-marker { color: #b42318; margin-inline-start: .2rem; }
    .login-page { min-height: 100vh; min-height: 100dvh; padding: clamp(1rem, 3vw, 3rem); }
    .login-layout { width: 100%; max-width: 1240px; min-height: auto; margin: auto; gap: clamp(1.5rem, 4vw, 4rem); }
    .login-hero h1 { font-size: clamp(1.65rem, 2.8vw, 2.5rem); line-height: 1.65; margin: 1rem 0; }
    .login-hero-copy { font-size: 1rem; line-height: 1.8; }
    .shop-eyebrow { color: #176186; font-weight: 600; margin-top: 2rem; }
    .shop-case-study { font-size: 1.4rem; color: #164e74; }
    .shop-login-note { padding: 1rem; background: #edf8fb; color: #245978; border-radius: .8rem; }
    .login-card { align-self: center; width: 100%; padding: clamp(1.5rem, 3vw, 2.75rem); }
    .login-brand-subtitle, .login-card-intro, .login-help-text, .login-footer { font-size: .875rem; }
    .app-shell .brand-copy { min-width: 0; }
    .app-shell .brand-subtitle { white-space: normal; }
}
@media screen and (max-width: 1199.98px) {
    .app-shell .table-responsive > .table:not(.table-compact) { min-width: 900px; }
    .app-shell .table td { min-width: 7rem; }
    .app-shell .table td:nth-child(2), .app-shell .table td:nth-child(4) { min-width: 12rem; }
}
@media screen and (max-width: 850px) {
    .login-layout { display: flex; flex-direction: column; }
    .login-hero, .login-card { max-width: 640px; margin-inline: auto; }
    .login-hero h1 { font-size: 1.65rem; }
    .shop-eyebrow { margin-top: 1rem; }
}

@media screen {
    .login-page { overflow-x: hidden; overflow-y: auto; }
    .login-page::before { left: 0; bottom: 0; width: 300px; height: 300px; }
    .login-page::after { right: 0; top: 0; width: 350px; height: 350px; }
    .login-layout { padding: 0; min-height: calc(100dvh - clamp(2rem, 6vw, 6rem)); }
    .login-brand { margin-bottom: 1.5rem; }
    .app-shell .document-number-copy { font-size: 1rem; }
    .app-shell .document-number-reference, .app-shell .app-pagination-summary { font-size: .875rem; }
    .app-shell .document-number-plain { max-width: 16rem; white-space: normal; overflow-wrap: anywhere; }
    .app-shell .table tbody tr:nth-child(odd) > .doc-number-cell { background: #fff !important; }
    .app-shell .table tbody tr:nth-child(even) > .doc-number-cell { background: #f0f7ff !important; }
}
@media screen and (min-width: 900px) and (max-width: 1199.98px) {
    .login-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, .9fr); }
    .login-hero { padding: 0; }
}
