/* Danh mục — giao diện kiểu KiotViet */

html:has(.kv-dm),
body.kv-dm-body {
    min-height: 100%;
    margin: 0 !important;
    background: #eef1f4;
}

body.kv-dm-body {
    margin-bottom: 0 !important;
}

body.kv-dm-body main {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px 14px 24px !important;
}

.kv-dm {
    --kv-green: #00b14f;
    --kv-green-dark: #009644;
    --kv-green-deep: #00753a;
    --kv-bar: #1f4d3a;
    --kv-text: #1f2937;
    --kv-muted: #64748b;
    --kv-line: #e2e8f0;
    --kv-bg: #eef1f4;
    --kv-card: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--kv-text);
    font-size: 14px;
}

.kv-dm-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    padding: 8px 16px;
    color: #fff;
    background: var(--kv-bar);
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
}

.kv-dm-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 800;
}

.kv-dm-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--kv-green);
    font-size: 14px;
}

.kv-dm-title {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
}

.kv-dm-meta {
    font-size: 12px;
    opacity: .82;
}

.kv-dm-top-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.kv-dm-link {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,.12);
}

.kv-dm-link:hover {
    color: #fff;
    background: rgba(255,255,255,.22);
}

.kv-dm-main {
    flex: 1 1 auto;
    min-height: 0;
}

/* Ẩn tiêu đề trùng với topbar, giữ thông báo */
.kv-dm-main > .text-center.mb-4 {
    text-align: left !important;
    margin: 0 0 10px !important;
}

.kv-dm-main > .text-center.mb-4 > h2,
.kv-dm-main > h2:first-child,
.kv-dm-main > form > h2:first-of-type,
.kv-dm-main > h3.mb-2:first-child {
    display: none;
}

.kv-dm-main > .text-center.mb-4 > h1,
.kv-dm-main > h1,
.kv-dm-main > form > h1,
.kv-dm-main > h2 + h1 {
    font-size: 13px !important;
    font-weight: 700 !important;
    margin: 0 0 8px !important;
}

.kv-dm-msg,
.kv-dm-main .erp-message,
.kv-dm-main .erp-alert {
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 13px;
}

/* Nút kiểu KiotViet */
.kv-dm .btn-primary,
.kv-dm input[type="button"].btn-primary,
.kv-dm input[type="submit"].btn-primary {
    background: var(--kv-green) !important;
    border-color: var(--kv-green) !important;
    color: #fff !important;
    font-weight: 700;
    border-radius: 8px;
}

.kv-dm .btn-primary:hover,
.kv-dm input[type="button"].btn-primary:hover {
    background: var(--kv-green-dark) !important;
    border-color: var(--kv-green-dark) !important;
}

.kv-dm .btn-success {
    background: var(--kv-green) !important;
    border-color: var(--kv-green) !important;
    font-weight: 700;
    border-radius: 8px;
}

.kv-dm .btn-secondary,
.kv-dm .btn-outline-secondary {
    border-radius: 8px;
    font-weight: 700;
}

.kv-dm input[type="button"][value="Xóa"],
.kv-dm input[type="button"][value*="Xóa"],
.kv-dm .btn-danger,
.kv-dm .erp-btn-del {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #fff !important;
}

.kv-dm input[type="button"][value="Sửa"],
.kv-dm input[type="button"][onclick*="Edit"] {
    background: #0ea5e9 !important;
    border-color: #0ea5e9 !important;
    color: #fff !important;
}

.kv-dm input[type="button"][value="Thoát ra"],
.kv-dm input[type="button"][value="Thoát"] {
    background: #64748b !important;
    border-color: #64748b !important;
    color: #fff !important;
}

.kv-dm input[type="button"][value="Thêm"],
.kv-dm input[type="button"][value*="Thêm"],
.kv-dm input[type="button"][value="Lưu dữ liệu"],
.kv-dm input[type="button"][value="Lưu lại"],
.kv-dm input[type="submit"][value="Lưu lại"] {
    background: var(--kv-green) !important;
    border-color: var(--kv-green) !important;
    color: #fff !important;
    font-weight: 700;
}

.kv-dm input[type="submit"][value="Delete"] {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #fff !important;
}

.kv-dm .form-control,
.kv-dm .form-select,
.kv-dm select,
.kv-dm input[type="text"],
.kv-dm input[type="number"],
.kv-dm input[type="date"],
.kv-dm .erp-input,
.kv-dm .erp-select {
    border: 1px solid #d0d7de !important;
    border-radius: 8px !important;
    min-height: 36px;
    font-size: 13px;
}

.kv-dm .form-control:focus,
.kv-dm .form-select:focus,
.kv-dm select:focus,
.kv-dm input:focus {
    border-color: var(--kv-green) !important;
    box-shadow: 0 0 0 3px rgba(0,177,79,.18) !important;
}

/* Toolbar tìm kiếm */
.kv-dm .search-toolbar {
    background: var(--kv-card);
    border: 1px solid var(--kv-line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

/* 2 cột danh sách */
.kv-dm .container-split {
    height: auto !important;
    min-height: calc(100vh - 92px);
    margin: 0 !important;
    gap: 12px !important;
    align-items: stretch;
}

.kv-dm .container-split .left-panel,
.kv-dm .container-split .center-panel,
.kv-dm .container-split .right-panel,
.kv-dm .left-panel,
.kv-dm .right-panel {
    background: var(--kv-card) !important;
    border: 1px solid var(--kv-line) !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.kv-dm .left-panel {
    width: 280px !important;
    max-width: 320px;
    padding: 12px !important;
}

.kv-dm .right-panel {
    width: auto !important;
    flex: 1 1 auto;
    padding: 0 !important;
    overflow: auto;
}

.kv-dm .card {
    border: 1px solid var(--kv-line);
    border-radius: 10px;
    box-shadow: none;
}

.kv-dm .card-header {
    background: #f8faf9 !important;
    color: var(--kv-text) !important;
    font-weight: 800;
    border-bottom: 1px solid var(--kv-line);
}

.kv-dm .card-header.bg-primary,
.kv-dm .card-header.bg-primary.text-white {
    background: var(--kv-bar) !important;
    color: #fff !important;
}

/* Bảng */
.kv-dm table.table,
.kv-dm .erp-table,
.kv-dm .kv-data {
    width: 100%;
    margin: 0;
    font-size: 13px;
    background: #fff;
}

.kv-dm table.table thead th,
.kv-dm .erp-table thead th {
    background: #f4f6f8 !important;
    color: #334155 !important;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .02em;
    border-bottom: 1px solid var(--kv-line) !important;
    white-space: nowrap;
    padding: 10px 8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.kv-dm table.table tbody td,
.kv-dm .erp-table tbody td {
    padding: 8px;
    border-color: #f1f5f9 !important;
    vertical-align: middle;
}

.kv-dm table.table tbody tr:hover td,
.kv-dm .erp-table tbody tr:hover td {
    background: #f0fdf4 !important;
}

.kv-dm .table-scroll {
    overflow: auto;
}

/* Phân trang */
.kv-dm .pagination a,
.kv-dm .pagination span {
    border-radius: 8px;
    border-color: var(--kv-line);
    background: #fff;
}

.kv-dm .pagination .active,
.kv-dm .pagination span.active {
    background: var(--kv-green) !important;
    border-color: var(--kv-green) !important;
    color: #fff !important;
}

.kv-dm .erp-page-btn,
.kv-dm .erp-pager button {
    border-radius: 8px;
}

/* SAP/ERP pages đã có sẵn */
.kv-dm .erp-page {
    padding: 0 !important;
}

.kv-dm .erp-header {
    background: transparent !important;
    color: var(--kv-text) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 0 10px !important;
    margin: 0 0 8px !important;
}

.kv-dm .erp-title,
.kv-dm .erp-header-title {
    display: none;
}

.kv-dm .erp-subtitle,
.kv-dm .erp-header-sub {
    color: var(--kv-muted);
    font-size: 13px;
}

.kv-dm .erp-layout {
    grid-template-columns: 280px 1fr !important;
    gap: 12px !important;
}

.kv-dm .erp-card {
    border: 1px solid var(--kv-line) !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 2px rgba(15,23,42,.04) !important;
}

.kv-dm .erp-card-header,
.kv-dm .erp-panel-title {
    background: #f8faf9 !important;
    color: var(--kv-text) !important;
    font-weight: 800;
    border-bottom: 1px solid var(--kv-line);
}

.kv-dm .erp-btn-primary,
.kv-dm .erp-btn.erp-btn-primary {
    background: var(--kv-green) !important;
    color: #fff !important;
}

.kv-dm .erp-badge-success,
.kv-dm .erp-badge.erp-badge-success {
    background: #dcfce7 !important;
    color: #166534 !important;
}

.kv-dm .erp-table-wrap {
    background: #fff;
    border-radius: 10px;
    overflow: auto;
}

/* Form sửa */
.kv-dm form > .row.g-2:has(input[type="button"]),
.kv-dm form > .mb-3:has(.btn) {
    background: #fff;
    border: 1px solid var(--kv-line);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 12px;
}

.kv-dm form > table.table {
    background: #fff;
    border: 1px solid var(--kv-line);
    border-radius: 10px;
    overflow: hidden;
}

.kv-dm form > table.table td:first-child {
    width: 220px;
    background: #f8faf9;
    font-weight: 700;
    color: #475569;
}

.kv-dm h6.text-primary {
    color: var(--kv-green-deep) !important;
    font-weight: 800;
    border-left: 4px solid var(--kv-green);
    padding-left: 8px;
}

/* Hub danh mục */
.kv-hub {
    display: grid;
    gap: 14px;
}

.kv-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.kv-hub-card {
    background: #fff;
    border: 1px solid var(--kv-line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.kv-hub-card h3 {
    margin: 0;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 800;
    background: #f8faf9;
    border-bottom: 1px solid var(--kv-line);
    color: var(--kv-green-deep);
}

.kv-hub-card a {
    display: block;
    padding: 9px 14px;
    color: #334155;
    text-decoration: none;
    border-bottom: 1px solid #f1f5f9;
    font-weight: 600;
}

.kv-hub-card a:last-child {
    border-bottom: 0;
}

.kv-hub-card a:hover {
    background: #f0fdf4;
    color: var(--kv-green-dark);
}

/* Trang SAP/Fiori đã nhúng style xanh dương — chuyển sang xanh KiotViet */
.kv-dm .sap-app {
    padding: 0 !important;
    background: transparent !important;
}

.kv-dm .sap-title {
    display: none;
}

.kv-dm .sap-shell,
.kv-dm .sap-filter-bar,
.kv-dm .sap-card,
.kv-dm .sap-left,
.kv-dm .sap-right {
    border-color: var(--kv-line) !important;
    border-radius: 10px !important;
}

.kv-dm .sap-btn.primary,
.kv-dm .sap-btn.small.primary {
    background: var(--kv-green) !important;
    color: #fff !important;
}

.kv-dm .sap-btn.ghost {
    background: #fff !important;
    border: 1px solid var(--kv-line) !important;
    color: #334155 !important;
}

.kv-dm .sap-btn.danger,
.kv-dm .sap-btn.small.danger {
    background: #ef4444 !important;
    color: #fff !important;
}

.kv-dm .sap-table thead,
.kv-dm .sap-table th {
    background: #f4f6f8 !important;
}

.kv-dm .sap-table tbody tr:hover td {
    background: #f0fdf4 !important;
}

.kv-dm .sap-code {
    font-family: ui-monospace, Consolas, monospace;
    color: var(--kv-green-deep);
    font-weight: 700;
}

@media (max-width: 992px) {
    .kv-dm .container-split,
    .kv-dm .erp-layout {
        display: flex !important;
        flex-direction: column;
        height: auto !important;
        min-height: 0;
        grid-template-columns: 1fr !important;
    }

    .kv-dm .left-panel,
    .kv-dm .right-panel {
        width: 100% !important;
        max-width: none;
    }
}

/* Systems: toolbar / table / form SAP */
.kv-dm .sap-page {
    padding: 0 !important;
    background: transparent !important;
    min-height: 0 !important;
}

.kv-dm .sap-toolbar,
.kv-dm .top-bar {
    background: #fff !important;
    border: 1px solid var(--kv-line) !important;
    border-radius: 10px !important;
}

.kv-dm .top-bar {
    display: flex;
    gap: 8px;
    padding: 10px;
    margin-bottom: 12px;
}

.kv-dm .btn-sap {
    padding: 8px 14px;
    border-radius: 8px;
    border: 0;
    font-weight: 700;
    cursor: pointer;
}

.kv-dm .btn-sap.btn-secondary {
    background: #e2e8f0 !important;
    color: #334155 !important;
}

.kv-dm .sap-btn-primary,
.kv-dm .sap-mini-btn.primary,
.kv-dm .btn-sap.btn-primary,
.kv-dm .btn-mini.primary {
    background: var(--kv-green) !important;
    border-color: var(--kv-green) !important;
    color: #fff !important;
}

.kv-dm .sap-mini-btn,
.kv-dm .btn-mini {
    border: 0;
    border-radius: 8px;
    padding: 6px 10px;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}

.kv-dm .sap-mini-btn.warn,
.kv-dm .btn-mini.warn {
    background: #0ea5e9 !important;
    color: #fff !important;
}

.kv-dm .sap-mini-btn.danger,
.kv-dm .btn-mini.danger {
    background: #ef4444 !important;
    color: #fff !important;
}

.kv-dm .sap-mini-btn.info {
    background: #6366f1 !important;
    color: #fff !important;
}

.kv-dm .sap-header {
    display: none;
}

.kv-dm .erp-header {
    background: transparent !important;
    color: var(--kv-text) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 0 10px !important;
    margin: 0 0 8px !important;
}

.kv-dm .erp-wrapper {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.kv-dm .sap-wrapper {
    min-height: auto !important;
    padding: 0 !important;
    display: block !important;
}

.kv-dm .sap-wrapper .sap-card {
    max-width: none !important;
    box-shadow: 0 1px 2px rgba(15,23,42,.04) !important;
}

.kv-dm .sap-body {
    padding: 16px !important;
}

.kv-dm .card-header.bg-danger {
    background: #ef4444 !important;
}

.kv-dm .card-header.bg-success,
.kv-dm .card-header.bg-primary {
    background: var(--kv-green) !important;
}

.kv-dm.is-busy {
    pointer-events: none;
    opacity: 0.72;
}

.kv-dm tr.is-new:not(.is-on),
.kv-dm-main tr.is-new:not(.is-on),
.kv-dm tr.is-new:not(.is-on) > td,
.kv-dm-main tr.is-new:not(.is-on) > td {
    background: #ecfdf3 !important;
    color: #0f172a !important;
}

.kv-dm tr.is-on.is-new,
.kv-dm-main tr.is-on.is-new {
    outline: 2px solid #00b14f;
    outline-offset: -2px;
}

.kv-dm tr.is-new:not(.is-on),
.kv-dm-main tr.is-new:not(.is-on) {
    outline: 2px solid #00b14f;
    outline-offset: -2px;
}

.kv-login-body {
    margin: 0 !important;
    background: #eef1f4;
}

/* Danh sách danh mục — bố cục kiểu ĐTPN */
body.kv-dm-body:has(.kv-dm-list) {
    background: #eef2f7;
    overflow: hidden;
    height: 100vh;
}

body.kv-dm-body:has(.kv-dm-list) main.kv-dm-main {
    padding: 8px 10px !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.kv-dm:has(.kv-dm-list) {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.kv-dm-list {
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.kv-dm-list #theForm {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.kv-dm-list .erp-header {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.kv-dm-list .erp-title {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.kv-dm-list .erp-msg {
    font-size: 13px;
    font-weight: 600;
}

.kv-dm-list .erp-toolbar {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
}

.kv-dm-list .toolbar-left,
.kv-dm-list .toolbar-right {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.kv-dm-list .erp-btn {
    border-radius: 6px;
    font-size: 0;
    font-weight: 600;
    padding: 0 !important;
    min-width: 34px;
    width: 34px;
    height: 34px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    line-height: 1;
}

.kv-dm-list .erp-btn i {
    font-size: 14px;
    line-height: 1;
}

.kv-dm-list.dmtq-page .toolbar-left > .btn-secondary.erp-btn {
    width: auto;
    min-width: 34px;
    padding: 0 12px !important;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
}

.kv-dm-list .paging-buttons .erp-btn {
    min-width: 32px;
    width: 32px;
    height: 32px;
    min-height: 32px;
}

.kv-dm-list .toolbar-search {
    width: 260px;
    font-size: 13px;
    min-height: 32px;
}

.kv-dm-list .erp-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 0;
}

.kv-dm-list .filter-panel {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    padding: 8px;
    overflow-y: auto;
    min-height: 0;
}

.kv-dm-list .filter-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #0f172a;
}

.kv-dm-list .filter-group {
    margin-bottom: 7px;
}

.kv-dm-list .filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 2px;
    color: #475569;
}

.kv-dm-list .filter-group select,
.kv-dm-list .filter-group input {
    min-height: 32px;
    font-size: 12px;
    border-radius: 6px !important;
}

.kv-dm-list .filter-stat {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px;
    margin-top: 10px;
    font-size: 12px;
}

.kv-dm-list .filter-stat strong {
    font-size: 16px;
    display: block;
    color: #0f172a;
    word-break: break-all;
}

.kv-dm-list .content-panel {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.kv-dm-list .table-wrap {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.kv-dm-list .erp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.kv-dm-list .erp-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #0f172a;
    color: #fff;
    padding: 7px 6px;
    border: 1px solid #1e293b;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
}

.kv-dm-list .erp-table tbody td {
    border: 1px solid #e2e8f0;
    padding: 4px 6px;
    vertical-align: middle;
}

.kv-dm-list .erp-table tbody tr:hover {
    background: #f8fafc;
}

.kv-dm-list .erp-table tbody tr:nth-child(even) {
    background: #fcfcfd;
}

.kv-dm-list .col-ten {
    min-width: 220px;
    font-weight: 600;
    color: #2563eb;
}

/* Bảng giá POS (chi_tim): không còn filter-panel — layout full width + cuộn ngang đủ cột */
.kv-dm-list.is-chi-tim .erp-layout {
    display: block;
    grid-template-columns: none;
}
.kv-dm-list.is-chi-tim .filter-panel {
    display: none !important;
}
.kv-dm-list.is-chi-tim .content-panel {
    width: 100%;
}
.kv-dm-list.is-chi-tim .erp-table {
    min-width: 1800px;
    width: max-content;
    max-width: none;
}

.kv-dm-list .action-group {
    display: flex;
    gap: 4px;
}

.kv-dm-list .btn-action {
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
}

.kv-dm-list .table-footer {
    border-top: 1px solid #dbe2ea;
    background: #f8fafc;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
}

.kv-dm-list .paging-info {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
}

.kv-dm-list .paging-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.kv-dm-list .paging-buttons button {
    min-width: 34px;
    height: 32px;
    border-radius: 6px;
}

.kv-dm-list .paging-buttons button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

@media (max-width: 1200px) {
    body.kv-dm-body:has(.kv-dm-list) {
        overflow: auto;
        height: auto;
    }

    .kv-dm-list .erp-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .kv-dm-list .content-panel {
        min-height: 500px;
    }
}


