* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f0f2f5; color: #1f2937; overflow: hidden; }
a { color: #2563eb; text-decoration: none; }
.layout { display: flex; height: 100%; }
.sidebar {
    width: 220px;
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
}
.brand { padding: 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid #1f2937; }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar nav a { display: block; padding: 12px 20px; color: #d1d5db; }
.sidebar nav a:hover, .sidebar nav a.active { background: #1f2937; color: #fff; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid #1f2937; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.sidebar-foot a { color: #9ca3af; }
.logout-form { display: inline; margin: 0; }
.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: #2563eb;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.link-danger { color: #dc2626; }
.inline-form { display: inline; margin: 0 0 0 8px; }
.actions-cell { white-space: nowrap; }
.actions-cell .inline-form:first-of-type { margin-left: 8px; }
.content { flex: 1; min-width: 0; min-height: 0; padding: 24px 32px; overflow-y: auto; }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card .num { font-size: 28px; font-weight: 700; color: #2563eb; }
.card .label { color: #6b7280; margin-top: 6px; font-size: 14px; }
.panel { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 20px; }
.panel h2 { font-size: 16px; margin-bottom: 14px; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 0; }
.list-search-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.list-search-form input[type="text"] {
    width: 220px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}
.list-search-form select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}
.category-select {
    min-width: 120px;
    max-width: 160px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}
.category-select.is-saved { border-color: #16a34a; }
.category-select.is-error { border-color: #dc2626; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form input[type="text"] {
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.batch-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
}
.batch-bar[hidden] { display: none; }
.batch-count { font-size: 14px; color: #1d4ed8; font-weight: 500; }
table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
}
.modal-overlay[hidden] { display: none; }
.modal-dialog {
    width: min(640px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close {
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: #111827; }
.modal-body { padding: 20px; }
.modal-hint { margin: 0 0 14px; font-size: 13px; color: #6b7280; }
.modal-table { margin-top: 16px; }
.modal-table .inline-form { margin: 0; }
.modal-table .category-name-input {
    min-width: 160px;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}
.search-hint { margin: -4px 0 12px; font-size: 13px; color: #6b7280; }
.text-muted { color: #9ca3af; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e5e7eb; text-align: left; }
th { background: #f9fafb; color: #374151; font-weight: 600; }
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; background: #2563eb; color: #fff; }
.btn:hover { background: #1d4ed8; }
.btn-secondary { background: #6b7280; }
.btn-danger { background: #dc2626; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
.label-with-tag .tag { margin-left: 8px; font-weight: normal; vertical-align: middle; }
.form-group input, .form-group select, .form-group textarea { width: 100%; max-width: 480px; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.form-group textarea { min-height: 80px; }
.form-group small { display: block; margin-top: 4px; color: #6b7280; font-size: 12px; }
.form-actions { margin-top: 20px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; padding: 32px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 4px 24px rgba(0,0,0,.1); }
.login-box h1 { text-align: center; margin-bottom: 24px; font-size: 22px; }
.qr-preview { max-width: 200px; border: 1px solid #e5e7eb; border-radius: 8px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag-green { background: #d1fae5; color: #065f46; }
.tag-gray { background: #f3f4f6; color: #4b5563; }
.tag-orange { background: #ffedd5; color: #9a3412; }
.list-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    padding: 14px 16px;
    background: #f9fafb;
    border: 1px solid #eef0f3;
    border-radius: 10px;
}
.list-stats {
    color: #6b7280;
    font-size: 13px;
    line-height: 1.6;
}
.list-stats strong {
    color: #111827;
    font-weight: 600;
}
.list-stats-sep {
    margin: 0 6px;
    color: #d1d5db;
}
.pagination {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.page-numbers {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.page-btn,
.page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
    user-select: none;
}
.page-btn {
    font-size: 20px;
    line-height: 1;
    color: #6b7280;
}
.page-btn:hover {
    background: #f3f4f6;
    color: #111827;
}
.page-num:hover {
    background: #eff6ff;
    color: #2563eb;
}
.page-num.is-active {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28);
    cursor: default;
}
.page-btn.is-disabled {
    color: #d1d5db;
    background: transparent;
    cursor: not-allowed;
}
.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 34px;
    color: #9ca3af;
    font-size: 14px;
    letter-spacing: 1px;
}
.sync-form { position: relative; }
.sync-status { display: inline-flex; align-items: center; gap: 8px; margin-left: 12px; color: #2563eb; font-size: 14px; }
.sync-status[hidden] { display: none !important; }
.sync-spinner { width: 16px; height: 16px; border: 2px solid #bfdbfe; border-top-color: #2563eb; border-radius: 50%; animation: spin .8s linear infinite; }
.btn:disabled { opacity: .65; cursor: not-allowed; }
.sync-progress { margin-top: 14px; max-width: 480px; }
.sync-progress[hidden] { display: none !important; }
.sync-progress-bar { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.sync-progress-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); border-radius: 999px; width: 0; transition: width .35s ease; }
.sync-progress-fill.is-active { width: 35%; animation: progress-slide 1.2s ease-in-out infinite; }
.sync-progress-text { margin-top: 8px; font-size: 13px; color: #2563eb; }
@keyframes progress-slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
@keyframes spin { to { transform: rotate(360deg); } }
.remark-input,
.staff-remark-input,
.customer-remark-input {
    width: 100%;
    min-width: 120px;
    max-width: 160px;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.remark-input:focus,
.staff-remark-input:focus,
.customer-remark-input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.remark-input.is-saved,
.staff-remark-input.is-saved,
.customer-remark-input.is-saved {
    border-color: #6ee7b7;
    background: #f0fdf4;
}
.remark-input.is-error,
.staff-remark-input.is-error,
.customer-remark-input.is-error {
    border-color: #fca5a5;
    background: #fef2f2;
}
.pin-btn,
.staff-pin-btn,
.customer-pin-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #d1d5db;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease, transform .15s ease;
}
.pin-btn:hover,
.staff-pin-btn:hover,
.customer-pin-btn:hover {
    color: #f59e0b;
    border-color: #fcd34d;
    background: #fffbeb;
}
.pin-btn.is-pinned,
.staff-pin-btn.is-pinned,
.customer-pin-btn.is-pinned {
    color: #f59e0b;
    border-color: #fcd34d;
    background: #fffbeb;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.15);
}
.pin-btn:disabled,
.staff-pin-btn:disabled,
.customer-pin-btn:disabled {
    opacity: .6;
    cursor: wait;
}
tr.row-pinned td {
    background: #fffbeb;
}
tr.row-pinned:hover td {
    background: #fef3c7;
}
