:root {
    --blue: #046dd6;
    --blue-dark: #0356a8;
    --red: #c62828;
    --red-dark: #8b1a1a;
    --green: #1b5e20;
    --amber: #b26a00;
    --amber-bg: #fff8e1;
    --text: #1f2328;
    --text-2: #5b6470;
    --text-3: #8a929c;
    --line: #e3e6ea;
    --bg: #f4f6f8;
    --white: #fff;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08),
        0 1px 2px rgba(16, 24, 40, 0.04);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial,
        sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--blue);
}

/* ---------- Layout ---------- */

.app {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #0e2a47;
    color: #cfd8e3;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
}

.brand-logo {
    font-size: 22px;
}

.brand-text {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    color: #fff;
}

.brand-sub {
    font-size: 11px;
    color: #93a4b8;
    margin-top: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    color: #cfd8e3;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
    background: var(--blue);
    color: #fff;
    font-weight: 600;
}

.nav-count {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: #93a4b8;
}

.main {
    padding: 20px 24px 48px;
    min-width: 0;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.page-desc {
    color: var(--text-2);
    margin: 4px 0 0;
    font-size: 13px;
    max-width: 720px;
    line-height: 1.5;
}

/* ---------- Card ---------- */

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-weight: 700;
    font-size: 15px;
    margin: 0;
}

.grid {
    display: grid;
    gap: 12px;
}

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

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

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

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

/* ---------- Stat tile ---------- */

.stat {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 12px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    margin-top: 4px;
    line-height: 1.1;
}

.stat-value.red {
    color: var(--red);
}

.stat-value.blue {
    color: var(--blue);
}

.stat-value.green {
    color: var(--green);
}

/* ---------- Form ---------- */

.field {
    margin-bottom: 12px;
}

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(4, 109, 214, 0.12);
}

.textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.5;
}

.help {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 4px;
    line-height: 1.5;
}

.err-text {
    font-size: 12px;
    color: var(--red);
    margin-top: 4px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    cursor: pointer;
}

/* ---------- Button ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    background: #f7f8fa;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

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

.btn-primary:hover {
    background: var(--blue-dark);
}

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

.btn-danger:hover {
    background: var(--red-dark);
}

.btn-ghost {
    border-color: transparent;
    background: none;
    color: var(--blue);
}

.btn-ghost:hover {
    background: rgba(4, 109, 214, 0.08);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
}

.btn-icon {
    padding: 5px 8px;
    font-size: 13px;
}

/* ---------- Chip ---------- */

.chip {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--white);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-2);
}

.chip.active {
    border-color: var(--blue);
    background: #e8f1fc;
    color: var(--blue);
    font-weight: 600;
}

/* ---------- Bảng chọn biểu tượng (js/icons.js) ---------- */

.icon-grid-host {
    max-height: 46vh;
    overflow-y: auto;
    padding-right: 4px;
}

.icon-group-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    margin: 14px 0 6px;
}

.icon-grid-host > .icon-group-name:first-child {
    margin-top: 0;
}

.icon-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.icon-cell {
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--white);
    cursor: pointer;
    font-family: inherit;
}

.icon-cell:hover {
    border-color: var(--blue);
    background: #f2f7fd;
}

.icon-cell.active {
    border-color: var(--blue);
    background: #e8f1fc;
    box-shadow: 0 0 0 2px rgba(4, 109, 214, 0.18);
}

/* ---------- Badge ---------- */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: #eef1f4;
    color: var(--text-2);
    white-space: nowrap;
}

.badge-new {
    background: #fdeaea;
    color: var(--red);
}

.badge-processing {
    background: #e8f1fc;
    color: var(--blue);
}

.badge-done {
    background: #e7f4e8;
    color: var(--green);
}

.badge-rejected {
    background: #eef1f4;
    color: var(--text-2);
}

.badge-amber {
    background: var(--amber-bg);
    color: var(--amber);
}

/* ---------- Table ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    background: #f7f8fa;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-2);
    white-space: nowrap;
}

.table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.table tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover {
    background: #fafbfc;
}

.table .clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 420px;
}

/* ---------- Misc ---------- */

.muted {
    color: var(--text-2);
}

.small {
    font-size: 12.5px;
}

.mono {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
}

.notice {
    background: var(--amber-bg);
    border: 1px solid #ffe0a3;
    color: #7a4a00;
    border-radius: 8px;
    padding: 11px 13px;
    font-size: 13px;
    line-height: 1.55;
}

.empty {
    text-align: center;
    padding: 36px 16px;
    color: var(--text-3);
}

.skeleton {
    background: linear-gradient(90deg, #eef1f4 25%, #e3e6ea 50%, #eef1f4 75%);
    background-size: 200% 100%;
    animation: sk 1.2s infinite;
    border-radius: 6px;
    height: 14px;
}

@keyframes sk {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
    background: #eef1f4;
    display: block;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

/* ---------- Modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 32, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
    z-index: 100;
}

.modal {
    background: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.2);
}

.modal-lg {
    max-width: 900px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}

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

.modal-body {
    padding: 18px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
}

/* ---------- Toast ---------- */

.toast-wrap {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
}

.toast {
    background: #1f2328;
    color: #fff;
    padding: 11px 15px;
    border-radius: 8px;
    font-size: 13.5px;
    box-shadow: 0 6px 20px rgba(16, 24, 40, 0.25);
    max-width: 360px;
}

.toast-success {
    background: var(--green);
}

.toast-error {
    background: var(--red);
}

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0e2a47 0%, #046dd6 100%);
}

.login-card {
    background: var(--white);
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.login-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px;
}

.login-sub {
    color: var(--text-2);
    font-size: 13px;
    margin: 0 0 20px;
    line-height: 1.5;
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        flex-direction: row;
        overflow-x: auto;
        align-items: center;
    }

    .brand,
    .sidebar-footer {
        display: none;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .main {
        padding: 16px;
    }
}
