/**
 * 零售店标准版 POS 系统 - 样式表
 */

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 0.25rem;
    --box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    /* Mobile viewport height (overridden by viewport-height.js) */
    --app-height: 100vh;
    --navbar-height: 56px;
    --pos-layout-offset: 120px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

@supports (height: 100dvh) {
    :root {
        --app-height: 100dvh;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: auto;
    scrollbar-gutter: stable; /* 需要滚动时预留 gutter，避免布局左右晃动 */
    height: 100%;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #87CEEB; /* 天蓝色背景 */
    min-height: var(--app-height);
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* 缅甸文字形在同等字号下比拉丁字偏小、笔画更密，单独略放大并加行高。 */
html[lang="my-MM"] body {
    font-family: "Myanmar Text", "Noto Sans Myanmar", "Padauk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14.5px;
    line-height: 1.55;
}

/* 导航栏中的用户名样式 */
.navbar-nav #currentUser,
.navbar-nav span[id="currentUser"] {
    font-size: 0.8rem;
}

/* 导航栏 */
.navbar {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    box-shadow: var(--box-shadow);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0; /* 导航栏不收缩 */
    width: 100%;
}

.navbar::-webkit-scrollbar {
    height: 4px;
}

.navbar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.navbar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.navbar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.navbar-brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    flex-shrink: 0;
}

.navbar-nav {
    display: flex !important;
    align-items: center;
    list-style: none;
    margin-left: auto;
    flex-wrap: nowrap;
    gap: 0.3rem;
    min-width: max-content;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.nav-item {
    margin-left: 1rem;
}

.nav-link {
    color: #333;
    text-decoration: none;
    padding: 0.5rem 0.7rem;
    border-radius: var(--border-radius);
    transition: background-color 0.2s;
    font-size: 0.8rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link i {
    font-size: 0.9em;
    width: 1em;
    text-align: center;
}

.nav-link:hover {
    background-color: var(--light-color);
}

.nav-link.active {
    color: #fff;
    background-color: var(--success-color);
}

.nav-link.disabled {
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

.nav-link.disabled:hover {
    background-color: transparent;
}

.nav-link.free-plan-locked,
.nav-link.free-plan-locked:hover,
.nav-link.disabled.free-plan-locked {
    color: #999;
    cursor: not-allowed;
    opacity: 0.55;
    pointer-events: auto !important;
    background-color: transparent;
}

.pos-sale-mode-option.free-plan-locked {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.35);
}

/* 容器 */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.container-fluid {
    width: 100%;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    font-size: 12px;
    flex-wrap: nowrap;
    gap: 1rem;
    max-width: 100%;
}

.container-fluid > .navbar-brand {
    flex-shrink: 0;
    width: 220px; /* 固定宽度，防止导航按钮位置移动 */
    min-width: 220px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left; /* 左对齐，保持一致性 */
}

.container-fluid > .navbar-nav {
    flex: 0 0 auto;
    min-width: max-content;
    overflow: visible;
}

/* 卡片 */
.card {
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许卡片内容滚动 */
}

.card-header {
    padding: 0.75rem 1rem;
    background-color: var(--light-color);
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.card-body {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* 允许内容滚动 */
}

.card-footer {
    padding: 0.75rem 1rem;
    background-color: var(--light-color);
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* 表单 */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-control:disabled {
    background-color: #e9ecef;
    opacity: 1;
}

/* ==========================================================================
   设置页表单栅格
   --------------------------------------------------------------------------
   背景：模板里用了 Bootstrap 风格的 .row + .col-md-*（settings.html 19 处、
   audit_logs.html 5 处），但项目从未引入 Bootstrap，这两个类在桌面端没有任何
   定义 —— .col-md-* 只是普通块级 div，于是「每个字段各占一整行」。
   ≤768px 由 mobile-compact.css 补上了两列，桌面端一直空着，
   结果「系统设置」表单被拉到 800px 高、右侧大片留白。

   这里给设置页的三处表单区补两列栅格。沿用模板已有的 .row / .col-md-*
   做容器，避免再引入一套命名；.settings-span-2 用于必须独占整行的格子。

   不放进媒体查询：桌面端只有这份规则生效；≤768px 时 mobile-compact.css
   也把这几个 .row 变成同样的两列，两边结论一致，手机上不会打架。
   ========================================================================== */
.settings-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
}

.settings-form-grid > [class*="col-"] {
    width: auto;
    max-width: none;
    min-width: 0;
}

/* 独占整行：店铺地址（长文本）、页脚留言（textarea）、
   打印字号（内含嵌套 .row，半列宽放不下）、自动备份开关（单个复选框） */
.settings-form-grid > .settings-span-2 {
    grid-column: 1 / -1;
}

/* 备份列表工具栏：桌面端标题左、按钮右；手机端由 mobile-compact.css 改成整行等宽 */
.backup-list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.backup-list-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.backup-save-row {
    margin-top: 1rem;
}

/* 按钮 */
.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    font-size: 18px;
    line-height: 1.5;
    border-radius: var(--border-radius);
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
    cursor: pointer;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed;
    /* 确保禁用按钮仍然可见 */
    visibility: visible !important;
    display: inline-block !important;
}

.btn.free-plan-locked,
.btn.free-plan-locked:hover,
.btn.free-plan-locked:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.35);
    pointer-events: auto !important;
}

/* 确保打印按钮在启用时完全可见 */
#printBtn:not(:disabled) {
    opacity: 1 !important;
    cursor: pointer !important;
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

#printBtn:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
}

#printBtn i,
#btPrintBtn i {
    margin-right: 0.35rem;
    vertical-align: -0.05em;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover:not(:disabled) {
    background-color: #0056b3;
    border-color: #004085;
}

.btn-success {
    color: #fff;
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-success:hover:not(:disabled) {
    background-color: #218838;
    border-color: #1e7e34;
}

.btn-danger {
    color: #fff;
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
    border-color: #bd2130;
}

.btn-warning {
    color: #212529;
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

.btn-warning:hover:not(:disabled) {
    background-color: #e0a800;
    border-color: #d39e00;
}

.btn-secondary {
    color: #fff;
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #5a6268;
    border-color: #545b62;
}

/* Logout button specific styles */
button[onclick="logout()"] {
    background-color: rgba(230, 61, 78, 1);
    border-color: rgba(230, 61, 78, 1);
    font-size: 18px;
}

button[onclick="logout()"]:hover:not(:disabled) {
    background-color: rgba(200, 50, 65, 1);
    border-color: rgba(200, 50, 65, 1);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* 表格 */
.table {
    width: 100%;
    margin-bottom: 1rem;
    background-color: transparent;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
}

.table thead th {
    vertical-align: middle;
    border-bottom: 2px solid #dee2e6;
    background-color: var(--light-color);
    font-weight: 600;
}

/* 可排序表头样式 */
.table thead th.sortable {
    position: relative;
    transition: background-color 0.2s;
}

.table thead th.sortable:hover {
    background-color: #e9ecef;
}

/* 排序指示器 */
.sort-indicator {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.7em;
    color: #999;
    width: 10px;
}

.sort-indicator.sort-asc {
    color: var(--primary-color);
}

.sort-indicator.sort-desc {
    color: var(--primary-color);
}

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 过期商品红色条显示 */
.table tbody tr.table-danger {
    background-color: #f8d7da !important;
    border-left: 4px solid #dc3545;
}

.table tbody tr.table-danger:hover {
    background-color: #f5c6cb !important;
}

.table tbody tr.table-danger td {
    color: #721c24;
    font-weight: 500;
}

/* 备份列表滚动容器 */
#backupsList {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
}

#backupsList::-webkit-scrollbar {
    width: 8px;
}

#backupsList::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#backupsList::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#backupsList::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 确保表格在滚动容器中正确显示 */
#backupsList .table {
    margin-bottom: 0;
    table-layout: fixed; /* 固定表格布局，确保列宽一致 */
    width: 100%;
}

/* 备份列表表格列宽分配 */
#backupsList .table th:nth-child(1),
#backupsList .table td:nth-child(1) {
    width: 40%; /* 文件名列 */
    text-align: left;
    word-break: break-all; /* 允许长文件名换行 */
}

#backupsList .table th:nth-child(2),
#backupsList .table td:nth-child(2) {
    width: 12%; /* 大小列 */
    text-align: right;
}

#backupsList .table th:nth-child(3),
#backupsList .table td:nth-child(3) {
    width: 28%; /* 创建时间列 */
    text-align: left;
}

#backupsList .table th:nth-child(4),
#backupsList .table td:nth-child(4) {
    width: 20%; /* 操作列 */
    text-align: center;
}

/* 备份列表表格行高度优化 - 降低备份信息条高度 */
#backupsList .table th,
#backupsList .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

#backupsList .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* 表格滚动容器 */
.table-scroll-container {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    position: relative;
}

/* 商品管理页面专用样式 - 使容器高度符合屏幕 */
body.index-page .container {
    display: flex;
    flex-direction: column;
    height: calc(var(--app-height) - var(--navbar-height));
    padding: 1rem;
    padding-bottom: max(1rem, var(--safe-bottom));
}

body.index-page .card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

body.index-page .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

body.index-page .card-body .form-group {
    flex-shrink: 0; /* 搜索表单不收缩 */
}

body.index-page #productsTable {
    flex: 1;
    min-height: 0;
    max-height: none;
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
}

/* Products页面表格行高度优化 - 降低商品信息条高度 */
body.index-page #productsTable .table th,
body.index-page #productsTable .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

body.index-page #productsTable .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* 销售记录页面专用样式 - 使容器高度符合屏幕 */
body.orders-page .container {
    display: flex;
    flex-direction: column;
    height: calc(var(--app-height) - var(--navbar-height));
    padding: 1rem;
    padding-bottom: max(1rem, var(--safe-bottom));
}

body.orders-page .card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

body.orders-page .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

body.orders-page .card-body > div:first-child {
    flex-shrink: 0; /* 查询表单不收缩 */
}

body.orders-page #ordersTable {
    flex: 1;
    min-height: 0;
    max-height: none;
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
}

/* Record页面表格行高度优化 - 降低订单信息条高度 */
body.orders-page #ordersTable .table th,
body.orders-page #ordersTable .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

body.orders-page #ordersTable .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* Batches页面表格行高度优化 - 降低批次信息条高度 */
#batchesTable .table th,
#batchesTable .table td,
#expiringBatchesTable .table th,
#expiringBatchesTable .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

#batchesTable .table thead th,
#expiringBatchesTable .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* Stock Count页面表格行高度优化 - 降低盘点信息条高度 */
#stockCountsTable .table th,
#stockCountsTable .table td,
#adjustmentsTable .table th,
#adjustmentsTable .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

#stockCountsTable .table thead th,
#adjustmentsTable .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* Returns页面表格行高度优化 - 降低退货信息条高度 */
#returnOrdersTable .table th,
#returnOrdersTable .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

#returnOrdersTable .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* Statistics页面 Product Sales Ranking 表格行高度优化 */
#salesRanking .table th,
#salesRanking .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

#salesRanking .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* POS页面 Shopping Cart 表格行高度优化 */
#cartItems .table th,
#cartItems .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

#cartItems .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* POS页面 商品搜索结果表格行高度优化 */
#productSearchResults .table th,
#productSearchResults .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

#productSearchResults .table thead th {
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
}

/* 搜索结果「添加」按钮：加大触控区域 */
#productSearchResults .pos-search-add-btn {
    min-width: 4.5rem;
    min-height: 44px;
    padding: 0.55rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 10px;
    touch-action: manipulation;
}

#productSearchResults td:last-child {
    padding: 0.5rem 0.35rem;
    vertical-align: middle;
}

/* POS 选择价格等级对话框：加大整体与触控区域 */
.pos-tier-modal-dialog {
    max-width: min(720px, 92vw);
    margin: 2rem auto;
}

.pos-tier-modal-content {
    border-radius: 16px;
}

.pos-tier-modal-header,
.pos-tier-modal-body,
.pos-tier-modal-footer {
    padding: 1.25rem 1.5rem;
}

.pos-tier-modal-title {
    font-size: 1.5rem;
}

.pos-tier-modal-close {
    font-size: 2rem;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.pos-tier-modal-desc {
    margin-bottom: 1rem;
    font-size: 1.05rem;
    color: #4b5563;
}

.pos-tier-list {
    gap: 0.65rem;
    display: flex;
    flex-direction: column;
}

.pos-tier-list .pos-tier-option {
    min-height: 56px;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    touch-action: manipulation;
}

.pos-tier-option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.pos-tier-option-label {
    font-size: 1.15rem;
}

.pos-tier-option-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color, #667eea);
    white-space: nowrap;
}

.pos-tier-cancel-btn {
    min-height: 48px;
    min-width: 7rem;
    font-size: 1rem;
    touch-action: manipulation;
}

.pos-tier-custom {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #dee2e6;
}

.pos-tier-custom-label {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

.pos-tier-custom-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pos-tier-custom-input {
    flex: 1;
    min-height: 48px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 10px;
    font-size: 16px;
}

.pos-tier-custom-btn {
    min-height: 48px;
    white-space: nowrap;
    touch-action: manipulation;
}

.pos-tier-custom-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
}

/* POS 清空/打印操作区：加大按钮、分区防误触 */
.pos-secondary-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.pos-action-btn {
    min-height: 52px;
    padding: 0.75rem 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 12px;
    touch-action: manipulation;
}

.pos-clear-cart-btn,
.pos-reset-unit-btn {
    width: 100%;
    border: 2px solid #adb5bd;
    background: #f8f9fa;
    color: #495057;
}

.pos-print-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.pos-print-actions .pos-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* 美化滚动条样式（Webkit浏览器） */
.table-scroll-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Firefox滚动条样式 */
.table-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* 固定表头（当表格在滚动容器中时） */
.table-scroll-container table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f8f9fa;
}

.table-scroll-container table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

/* 徽章 */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.badge-primary {
    color: #fff;
    background-color: var(--primary-color);
}

.badge-success {
    color: #fff;
    background-color: var(--success-color);
}

.badge-danger {
    color: #fff;
    background-color: var(--danger-color);
}

.badge-warning {
    color: #212529;
    background-color: var(--warning-color);
}

.badge-info {
    color: #fff;
    background-color: #17a2b8;
}

/* 提示框 */
.alert {
    position: relative;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: block;
}

.modal-dialog {
    position: relative;
    width: auto;
    max-width: 500px;
    margin: 1.75rem auto;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.modal-footer .btn {
    margin-left: 0.5rem;
}

.close {
    padding: 0;
    background-color: transparent;
    border: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #000;
    opacity: 0.5;
    cursor: pointer;
}

.close:hover {
    opacity: 1;
}

/* 加载中 */
.loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 屏幕阅读器专用（隐藏但可访问） */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* 列表组 */
.list-group {
    display: flex;
    flex-direction: column;
    padding-left: 0;
    margin-bottom: 0;
}

.list-group-item {
    position: relative;
    display: block;
    padding: 0.75rem 1.25rem;
    margin-bottom: -1px;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.125);
}

.list-group-item:first-child {
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
}

.list-group-item:last-child {
    margin-bottom: 0;
    border-bottom-right-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}

.list-group-item-action {
    width: 100%;
    color: #495057;
    text-align: left;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.list-group-item-action:hover {
    z-index: 1;
    color: #495057;
    text-decoration: none;
    background-color: #f8f9fa;
}

.list-group-item-action:focus {
    z-index: 1;
    color: #495057;
    text-decoration: none;
    background-color: #f8f9fa;
}

/* 响应式 */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
        padding-bottom: max(0.5rem, var(--safe-bottom));
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .modal-dialog {
        margin: max(0.5rem, var(--safe-top)) max(0.5rem, var(--safe-right)) max(0.5rem, var(--safe-bottom)) max(0.5rem, var(--safe-left));
        max-width: calc(100% - 1rem - var(--safe-left) - var(--safe-right));
    }
}

/* 收银台专用样式 */
.pos-sale-mode-group {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

.pos-sale-mode-options {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.5rem;
}

.pos-sale-mode-option {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-weight: 500;
    margin: 0;
}

.pos-sale-mode-option input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.pos-retail-tier-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
}

.pos-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    height: calc(var(--app-height) - var(--pos-layout-offset));
    min-height: 0;
}

.cart-section {
    display: flex;
    flex-direction: column;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    background-color: #fff;
    min-height: 0;
    max-height: 360px;
    padding: 0.5rem;
}

.cart-items::-webkit-scrollbar {
    width: 8px;
}

.cart-items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.cart-items::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.cart-summary {
    border-top: 2px solid #dee2e6;
    padding: 1rem;
    background-color: #fff;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 1rem;
}

.summary-row.total {
    font-size: 1.5rem;
    font-weight: 700;
    border-top: 2px solid #dee2e6;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

@media (max-width: 992px) {
    .pos-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(var(--app-height) - var(--pos-layout-offset));
    }

    .cart-items {
        max-height: min(360px, calc(var(--app-height) - var(--pos-layout-offset) - 300px));
    }
}

.printer-status-chip {
    font-size: 12px;
    color: #666;
    padding: 4px 10px;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    background: #f8f9fa;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pos-printer-status-row {
    margin-top: 0.5rem;
    width: 100%;
}

.printer-status-chip--bottom {
    display: block;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    border-radius: 6px;
    padding: 6px 10px;
    text-align: center;
    white-space: normal;
    word-break: break-all;
    line-height: 1.35;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11px;
}

.printer-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 2000;
}

.printer-modal-backdrop.show {
    display: flex;
}

.printer-modal {
    width: min(720px, 100%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.printer-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #dee2e6;
}

.printer-modal-title {
    font-weight: 600;
    font-size: 16px;
}

.printer-modal-sub {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.printer-modal-body {
    padding: 14px 16px;
    display: grid;
    gap: 14px;
    max-height: min(70vh, calc(var(--app-height) * 0.7));
    overflow-y: auto;
}

.printer-field {
    display: grid;
    gap: 8px;
}

.printer-label {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
}

.printer-chip {
    display: inline-block;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 12px;
}

.printer-paper-width {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.printer-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #343a40;
    cursor: pointer;
}

.printer-wifi-form {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(88px, 0.7fr) auto;
    gap: 8px;
    align-items: end;
}

.printer-wifi-item {
    display: grid;
    gap: 4px;
    font-size: 12px;
    color: #6c757d;
}

.printer-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
}

@media (max-width: 640px) {
    .printer-wifi-form {
        grid-template-columns: 1fr;
    }
}

.printer-listbox {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.printer-listbox .device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
}

.printer-listbox .device-item:hover {
    background: #fff;
    border-color: #dee2e6;
}

.printer-listbox .device-item.selected {
    background: #e7f1ff;
    border-color: #0d6efd;
}

.printer-listbox .device-meta {
    color: #666;
    font-size: 12px;
}

.printer-listbox .mono {
    font-family: ui-monospace, monospace;
    font-size: 12px;
}

.printer-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid #dee2e6;
}

/* 40×30mm 标签打印预览 */
.label-preview-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.label-layout-editor-wrap {
    margin-bottom: 1rem;
}

.label-editor-hint {
    font-size: 0.8rem;
    color: #6c757d;
    margin: 0 0 0.6rem;
    text-align: center;
}

.label-editor-stage {
    position: relative;
    width: 280px;
    max-width: 100%;
    margin: 0 auto;
}

.label-editor-image {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #adb5bd;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    image-rendering: pixelated;
}

.label-editor-zone {
    position: absolute;
    box-sizing: border-box;
    border: 2px dashed transparent;
    border-radius: 2px;
    pointer-events: none;
}

.label-editor-zone-text {
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(102, 126, 234, 0.06);
}

.label-editor-zone-barcode {
    border-color: rgba(40, 167, 69, 0.55);
    background: rgba(40, 167, 69, 0.06);
}

.label-editor-handle {
    position: absolute;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    touch-action: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transform: translate(-50%, -50%);
}

.label-editor-handle-text {
    background: #667eea;
    color: #fff;
    cursor: ns-resize;
}

.label-editor-handle-barcode {
    background: #28a745;
    color: #fff;
    cursor: nwse-resize;
}

.label-editor-handle-grip {
    font-size: 0.85rem;
    opacity: 0.95;
}

body.label-editor-dragging {
    user-select: none;
}

body.label-editor-dragging .label-editor-handle-text {
    cursor: ns-resize;
}

body.label-editor-dragging .label-editor-handle-barcode {
    cursor: nwse-resize;
}

.label-preview-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.label-preview-control-label {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
}

.label-barcode-slider {
    width: 160px;
    max-width: 100%;
    margin: 0;
}

.label-barcode-height-value {
    min-width: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #667eea;
    font-variant-numeric: tabular-nums;
}

.label-preview-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #374151;
}

.label-preview-size-hint {
    font-size: 0.8rem;
    font-weight: 400;
    color: #6c757d;
}

.label-preview-panel {
    background: #eef1f5;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 1rem;
    min-height: 120px;
}

.label-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: flex-start;
}

.label-preview-item {
    position: relative;
    flex: 0 0 auto;
}

.label-preview-canvas {
    display: block;
    width: 200px;
    height: 150px;
    background: #fff;
    border: 1px solid #adb5bd;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    image-rendering: pixelated;
}

#labelPreviewModal .label-preview-canvas {
    width: 280px;
    height: 210px;
}

.label-preview-meta {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 28px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #667eea;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.45);
}

.label-preview-empty {
    text-align: center;
    color: #999;
    padding: 1.5rem 1rem;
    font-size: 0.9rem;
}

/* ==========================================================================
   订单列表（Order Query）：收纳态 + 点击展开详情
   ---------------------------------------------------------------------------
   原来是 13 列表格：桌面端表头被挤到换行，手机端每单被转成约 300px 高的卡片，
   一屏只能看到 2 单。改成手风琴后收起态每行约 48px，桌面 / 移动端共用同一套 DOM。
   ========================================================================== */

.order-list {
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    overflow: hidden;              /* 让行的分隔线不溢出圆角 */
    background: #fff;
}

.order-item + .order-item {
    border-top: 1px solid #eef0f3;
}

.order-item__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.75rem;
    min-height: 48px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.order-item__head:hover {
    background: #f6f8ff;
}

.order-item__head:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

.order-item.is-open > .order-item__head {
    background: #eef2ff;
    border-bottom: 1px solid #dde3f5;
}

.order-item__no {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex: 0 0 auto;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.order-item__time,
.order-item__op,
.order-item__pay {
    flex: 0 0 auto;
    font-size: 0.85rem;
    color: #6b7280;
    white-space: nowrap;
}

.order-item__badges {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex: 0 0 auto;
}

/* 金额顶到右侧，把左边的摘要与右边的操作分开 */
.order-item__amount {
    margin-left: auto;
    font-weight: 700;
    color: #198754;
    white-space: nowrap;
    text-align: right;
}

.order-item__actions {
    display: inline-flex;
    gap: 0.25rem;
    flex: 0 0 auto;
}

.order-item__chevron {
    flex: 0 0 auto;
    width: 1em;
    font-size: 0.8rem;
    color: #9aa1ab;
    text-align: center;
    transition: transform 0.2s ease;
}

/* 展开箭头旋转（收起态向右，展开态向下） */
.order-item.is-open .order-item__chevron {
    transform: rotate(90deg);
}

.order-item__body {
    padding: 0.85rem 0.9rem 1rem;
    background: #fbfcff;
}

.order-item__hint {
    padding: 0.5rem 0;
    text-align: center;
    font-size: 0.9rem;
    color: #6b7280;
}

.order-item__hint--error {
    color: #dc3545;
}

/* 详情内部排版（沿用原弹层里的 form-group / 表格结构） */
.order-item__body .form-group {
    margin-bottom: 0.6rem;
}

/* 顶部 6 个字段：自适应多列，避免竖排把面板拉得很长 */
.order-item__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.35rem 1rem;
    margin-bottom: 0.5rem;
}

.order-item__meta .form-group {
    margin-bottom: 0;
}

.order-item__body .form-label {
    margin-bottom: 0.15rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #6b7280;
}

.order-item__body h6 {
    margin: 0 0 0.6rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #374151;
}

.order-item__body hr {
    margin: 1rem 0;
    border: 0;
    border-top: 1px solid #e5e7eb;
}

.order-item__body table {
    margin-bottom: 0.75rem;
}

/* --- 窄屏：收紧字号与间距，次要信息允许换行 --- */
@media (max-width: 768px) {
    .order-item__head {
        gap: 0.25rem 0.5rem;
        padding: 0.45rem 0.6rem;
    }

    .order-item__no {
        font-size: 0.9rem;
    }

    .order-item__time,
    .order-item__op,
    .order-item__pay {
        font-size: 0.78rem;
    }

    .order-item__amount {
        font-size: 0.95rem;
    }

    .order-item__body {
        padding: 0.75rem 0.6rem 0.9rem;
    }
}

/* --- 最窄屏：隐藏支付方式，保住订单号/时间/金额/操作 --- */
@media (max-width: 480px) {
    .order-item__pay {
        display: none;
    }
}

