/* ============================================================
   PL kế toán - Components
   ============================================================ */

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    border: 1px solid transparent;
    line-height: 1;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); color: #fff; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--primary-lighter); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 900px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* KPI Stats */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
    width: 46px; height: 46px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.purple { background: #f0eafa; color: #7c4dff; }
.stat-icon.teal { background: var(--info-bg); color: var(--info); }
.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-delta { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.data-table thead th {
    background: var(--primary-lighter);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.data-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--primary-lighter); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }
.data-table tfoot td {
    padding: 12px 14px;
    font-weight: 700;
    border-top: 2px solid var(--primary);
    background: var(--primary-lighter);
}
.data-table tfoot td.num { color: var(--primary); }
.account-code { font-family: 'Courier New', monospace; font-weight: 600; color: var(--primary); }
.muted { color: var(--text-muted); }

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #b97300; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gray { background: #eef1f6; color: var(--text-secondary); }

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: #1d7a40; border-color: #b8e6c8; }
.alert-error, .alert-danger { background: var(--danger-bg); color: #b33529; border-color: #f5c6c0; }
.alert-warning { background: var(--warning-bg); color: #946000; border-color: #f5d990; }
.alert-info { background: var(--info-bg); color: #0c6d7d; border-color: #9bdde8; }
.alert-close { font-size: 20px; line-height: 1; opacity: 0.6; cursor: pointer; }
.alert-close:hover { opacity: 1; }

/* Forms */
.form-row { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; }
.required { color: var(--danger); }
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    margin-top: 8px;
}
@media (max-width: 640px) {
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.toolbar .search-input {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}
.toolbar .search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.toolbar .search-input input { padding-left: 38px; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.filter-select { width: auto; min-width: 140px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; opacity: 0.3; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 50, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    overflow-y: auto;
    backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    margin: auto;
    animation: modalIn 0.2s ease;
}
.modal.modal-lg { max-width: 900px; }
.modal.modal-xl { max-width: 1200px; }
.modal.modal-sm { max-width: 420px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 600; color: var(--text); }
.modal-close { font-size: 24px; color: var(--text-muted); line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Progress / bars */
.progress { height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.4s; }

/* Charts (CSS bar) */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 220px;
    padding: 10px 0;
}
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bar {
    width: 70%;
    max-width: 42px;
    background: linear-gradient(180deg, var(--accent), var(--primary));
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: opacity var(--transition);
    position: relative;
}
.chart-bar:hover { opacity: 0.85; }
.chart-bar-label { font-size: 11px; color: var(--text-muted); }

/* Pie/donut via conic-gradient */
.donut {
    width: 160px; height: 160px;
    border-radius: 50%;
    position: relative;
    margin: 0 auto;
}
.donut::after {
    content: '';
    position: absolute;
    inset: 22px;
    background: var(--surface);
    border-radius: 50%;
}
.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
    text-align: center;
}
.donut-center .val { font-size: 20px; font-weight: 700; }
.donut-center .lbl { font-size: 11px; color: var(--text-muted); }

/* Legend */
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Misc utility */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8{margin-top:8px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}
.mb-8{margin-bottom:8px}.mb-16{margin-bottom:16px}.mb-24{margin-bottom:24px}
.text-right{text-align:right}.text-center{text-align:center}
.text-muted{color:var(--text-muted)}
.text-success{color:var(--success)}.text-danger{color:var(--danger)}.text-primary{color:var(--primary)}
.font-bold{font-weight:700}.font-600{font-weight:600}
.text-sm{font-size:13px}.text-lg{font-size:18px}.text-xl{font-size:22px}
.w-full{width:100%}
.hidden{display:none}
.nowrap{white-space:nowrap}
.fw-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #005baa 0%, #003d70 60%, #002850 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(30,155,255,0.25), transparent 70%);
    top: -200px; right: -150px;
}
.login-wrapper::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,180,255,0.15), transparent 70%);
    bottom: -180px; left: -100px;
}
.login-card {
    background: rgba(255,255,255,0.98);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    position: relative;
    z-index: 2;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-size: 26px; color: var(--primary); font-weight: 300; }
.login-logo .brand strong { font-weight: 800; }
.login-logo .tagline { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-hint {
    margin-top: 20px;
    padding: 12px 14px;
    background: var(--primary-lighter);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text-secondary);
    text-align: center;
}
.login-hint code { background: #fff; padding: 1px 6px; border-radius: 4px; color: var(--danger); font-weight: 600; }

/* Action cell in tables */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-action-btn {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition);
}
.row-action-btn:hover { background: var(--primary-lighter); color: var(--primary); }
.row-action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.row-action-btn svg { width: 16px; height: 16px; }

/* Section divider */
.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
   Tra cứu đối tác (vendor / customer auto-lookup)
   ============================================================ */
.lookup-banner {
    display: flex; align-items: flex-start; gap: 10px;
    background: #eef5ff; border: 1px solid #cfe3ff; border-radius: 8px;
    padding: 10px 12px; margin-bottom: 14px; color: #1f4e8c; font-size: 13px; line-height: 1.45;
}
.lookup-banner svg { flex-shrink: 0; margin-top: 1px; color: var(--primary); }
.lookup-input { display: flex; gap: 8px; align-items: center; }
.lookup-input input { flex: 1; }
.btn-sm { padding: 6px 12px; font-size: 13px; flex-shrink: 0; }
.lookup-tax-btn {
    background: none; border: none; color: var(--primary); cursor: pointer;
    font-size: 12px; padding: 0 4px; text-decoration: underline; float: right;
}
.lookup-status { font-size: 12px; color: var(--success, #2e9e5b); min-height: 16px; display: block; margin-top: 4px; }
.lookup-status.is-error { color: var(--danger, #e5484d); }
.lookup-results {
    margin-top: 6px; border: 1px solid var(--border, #e4e7ed); border-radius: 8px;
    max-height: 240px; overflow-y: auto; background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.lookup-item { padding: 9px 12px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.lookup-item:last-child { border-bottom: none; }
.lookup-item:hover { background: #f5f9ff; }
.lookup-item-main { display: flex; align-items: center; gap: 8px; }
.lookup-item-name { font-weight: 600; color: #1f2a44; }
.lookup-item-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }
.lookup-empty { padding: 12px; font-size: 13px; color: #6b7280; }
.tag { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 10px; background: #eef; color: #5a6; font-weight: 600; }
.tag-info { background: #e0f0ff; color: #1f4e8c; }

/* Print */
@media print {
    .sidebar, .topbar, .page-actions, .toolbar, .row-actions, .btn, .no-print { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: none; }
    .print-toolbar { display: none !important; }
}

/* ============================================================
   Mẫu in "Phiếu nội bộ" / Hóa đơn (theo ảnh mẫu)
   ============================================================ */
.print-doc { max-width: 800px; margin: 0 auto; }
.print-toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
/* Lớp bao trang in (trên màn hình có padding; khi in @media print bỏ padding) */
.print-page { padding: 24px; max-width: 100%; }

.print-sheet {
    background: #fff;
    color: #000;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 28px 32px;
    font-family: 'Times New Roman', 'Segoe UI', Arial, sans-serif;
    font-size: var(--ps-document-font-size, 13px);
    line-height: 1.5;
    border: 1px solid #e4e7ed;
    border-radius: 6px;
}
.ps-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.ps-header > * { min-width: 0; }
.ps-barcode { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.print-barcode { display: block; width: 100%; max-width: var(--ps-barcode-max-width, 130px); height: auto; }
.ps-title {
    min-width: 0;
    text-align: center;
    font-size: var(--ps-title-font-size, 22px);
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.2;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}
.ps-meta { min-width: 0; text-align: right; font-size: 12.5px; overflow-wrap: anywhere; }
.ps-meta-row { line-height: 1.7; }

.ps-parties {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 10px 24px;
    padding: 8px 0;
}
.ps-info-block { min-width: 0; }
.ps-info-company { border-top: 1px dashed #bbb; margin-top: 4px; padding-top: 10px; }
.ps-col { display: flex; flex-direction: column; gap: 2px; }
.ps-col.ps-right { text-align: right; }
.ps-field { line-height: 1.75; }
.ps-label { font-weight: 600; }

.ps-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 12px 0 8px;
    font-size: var(--ps-table-font-size, 12.5px);
}
.ps-table th, .ps-table td {
    min-width: 0;
    border: 1px solid #555;
    padding: var(--ps-cell-padding, 6px 8px);
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: normal;
}
.ps-table thead th {
    background: #f0f0f0;
    font-weight: 700;
    text-align: center;
}
.ps-table tbody td { min-height: 22px; }
.ps-c-stt { width: 5%; text-align: center; }
.ps-c-name { width: auto; }
.ps-c-unit { width: 8%; text-align: center; }
.ps-c-qty, .ps-c-price, .ps-c-disc, .ps-c-amt { text-align: right; white-space: normal; }
.ps-c-price, .ps-c-amt { width: 15%; }
.ps-c-qty { width: 9%; }
.ps-c-disc { width: 13%; }
.ps-c-note { width: 12%; }
.ps-empty { text-align: center; padding: 18px; color: #888; }
.ps-total-row td { font-weight: 700; background: #f7f7f7; }
.ps-total-label { text-align: center; }
.ps-total-amount { font-size: 14px; }

.ps-words {
    margin: 10px 0;
    font-weight: 600;
    font-style: italic;
}

.ps-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 36px;
}
.ps-sign { min-width: 0; overflow: hidden; }
.ps-sign-label { font-weight: 600; text-align: center; word-break: break-word; }
.ps-sign-muted { text-align: center; font-size: 11px; font-style: italic; color: #666; margin-bottom: 4px; }
.ps-sign-space { height: 90px; }
.ps-sign-right .ps-sign-label { text-align: center; }
.ps-sign-center .ps-sign-label { text-align: center; }
.ps-signatures.ps-sign-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Logo / slogan / footer tuỳ chỉnh */
.ps-logo { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ps-logo-mark {
    width: 36px; height: 36px; border-radius: 8px; background: var(--primary,#005baa); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px;
}
.ps-logo-name { min-width: 0; font-weight: 700; font-size: 13px; max-width: 150px; line-height: 1.2; overflow-wrap: anywhere; }
.ps-logo-text { min-width: 0; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.ps-slogan { text-align: center; font-style: italic; color: #555; margin: -6px 0 10px; font-size: 12px; }
.ps-footer { margin-top: 18px; text-align: center; font-size: 11px; color: #888; border-top: 1px dashed #ccc; padding-top: 8px; }

/* Trang Mẫu in (print_design) */
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; padding: 4px 0; }
.check-line input { width: auto; margin: 0; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }

/* Danh sách kéo-thả sắp xếp cột (trang Mẫu in) */
.col-sort { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 340px; }
.col-sort-item {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--border,#e4e7ed); border-radius: 8px;
    padding: 8px 10px; cursor: grab; user-select: none;
    transition: box-shadow .12s, border-color .12s, background .12s;
}
.col-sort-item:hover { border-color: var(--primary,#005baa); box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.col-sort-item.dragging { opacity: .5; cursor: grabbing; }
.col-sort-item.drag-over { background: #f5f9ff; }
.col-sort-grip { color: #9aa3b2; font-size: 18px; line-height: 1; cursor: grab; flex-shrink: 0; }
.col-sort-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; flex: 1; margin: 0; }
.col-sort-label input { width: auto; margin: 0; }
.sort-move-controls { display: inline-flex; gap: 2px; margin-left: auto; }
.sort-move-btn {
    width: 28px; height: 28px; padding: 0; border: 1px solid var(--border,#e4e7ed);
    border-radius: 5px; background: #fff; color: var(--text,#263238); cursor: pointer; font-size: 15px; line-height: 1;
}
.sort-move-btn:hover, .sort-move-btn:focus-visible { border-color: var(--primary,#005baa); color: var(--primary,#005baa); outline: none; }
.pd-preview-box { background: #f4f6f9; padding: 14px; border-radius: 8px; display: flex; justify-content: center; }
.pd-preview-box .print-sheet { width: 100%; max-width: 460px; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.12); padding: 16px; border-radius: 4px; }
.pd-preview-box .print-sheet .ps-table th,
.pd-preview-box .print-sheet .ps-table td { font-size: 11px; }

/* Responsive cho màn hình nhỏ (không in) */
@media (max-width: 640px) {
    .ps-header { grid-template-columns: 1fr; text-align: center; }
    .ps-barcode, .ps-meta { justify-content: center; text-align: center; }
    .ps-title { font-size: 18px; }
    .ps-parties { grid-template-columns: 1fr; }
    .ps-col.ps-right { text-align: left; }
    .print-sheet { padding: 16px; font-size: 12px; }
    .ps-signatures, .ps-signatures.ps-sign-3 { grid-template-columns: 1fr; }
}

/* Khi in: tối giản, đúng khổ A4, gọn 1 trang */
@media print {
    /* Override inline padding/margin trên .content (print.php đặt padding:24px inline) */
    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    main.content, .content { margin: 0 !important; padding: 0 !important; max-width: none !important; }
    .print-doc { max-width: none; margin: 0; }
    .print-toolbar { display: none !important; }
    .print-sheet {
        width: auto;
        max-width: none;
        border: none;
        padding: 0;
        margin: 0;
        font-size: var(--ps-document-font-size, 12.5px);
    }
    /* Thu gọn khoảng trắng để gọn vừa 1 trang */
    .ps-signatures { margin-top: 18px; gap: 18px; }
    .ps-sign-space { height: 60px; }
    .ps-words { margin: 6px 0; }
    .ps-table { margin: 8px 0 4px; font-size: var(--ps-table-font-size, 12.5px); }
    .ps-parties { padding: 4px 0; }
    @page { size: A4 portrait; margin: 10mm; }
}
