/* Bảng màu và kiểu giao diện tổng thể của Trí Việt Kanban. */
:root {
  --navy: #111a30;
  --blue: #2563eb;
  --page: #f4f6fb;
  --ink: #172033;
  --muted: #778196;
  --border: #e4e8f0;
  --shadow: 0 5px 18px rgba(31, 45, 78, .055);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; }
button, input, select, textarea { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 210px; flex: 0 0 210px; background: var(--navy); color: #d7deed; padding: 20px 12px; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 7px 25px; border-bottom: 1px solid #2a344b; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg,#54b7ff,#554ce8); color: white; font-weight: 800; }
.brand strong { display: block; color: white; font-size: 14px; letter-spacing: .5px; }
.brand small { display: block; margin-top: 4px; color: #8794ae; font-size: 11px; }
.nav { display: grid; gap: 7px; padding-top: 23px; }
.nav-item { text-decoration: none; color: #b9c3d8; padding: 12px 11px; border-radius: 9px; font-weight: 500; }
.nav-item:hover, .nav-item.active { background: #26334e; color: white; }
.nav-item.active { box-shadow: inset 3px 0 #62a5ff; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #2a344b; padding: 18px 8px 0; color: #aeb9ce; font-size: 12px; line-height: 1.8; }
.sidebar-bottom span { color: #73819c; }
.main { min-width: 0; flex: 1; padding: 27px 28px 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: 1.2px; color: #8290a8; }
h1 { font-size: 27px; margin: 5px 0 4px; letter-spacing: -.6px; }
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 9px; padding: 10px 15px; cursor: pointer; text-decoration: none; font-weight: 650; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg,#347cf6,#2555d9); color: white; box-shadow: 0 4px 10px #2563eb25; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-dark { background: #24334d; color: white; }
.btn-light { background: white; border: 1px solid var(--border); color: #536078; }
.stats { display: grid; grid-template-columns: repeat(5,minmax(125px,1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { position: relative; min-height: 91px; padding: 17px; border: 1px solid var(--border); border-radius: 13px; background: white; box-shadow: var(--shadow); }
.stat-card span { display: block; color: #7b879b; font-size: 12px; }
.stat-card strong { display: block; font-size: 25px; margin-top: 9px; }
.stat-icon { position: absolute; right: 15px; top: 15px; width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; font-style: normal; }
.stat-icon.blue { background: #e6efff; color: #2563eb; }.stat-icon.gray { background: #eef1f5; color: #64748b; }.stat-icon.indigo { background: #e8eaff; color: #5559d9; }.stat-icon.amber { background: #fff3d1; color: #b7790b; }.stat-icon.green { background: #d9f8e9; color: #15865b; }
.filter-bar { background: white; padding: 13px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 19px; box-shadow: var(--shadow); }
.filters { display: flex; gap: 9px; }
.filters input, .filters select { min-width: 130px; border: 1px solid #e0e5ee; background: #fbfcfe; border-radius: 8px; padding: 10px 11px; color: #344057; }
.filters input { flex: 1; }
.kanban { display: grid; grid-template-columns: repeat(4,minmax(220px,1fr)); gap: 13px; align-items: start; overflow-x: auto; padding-bottom: 10px; }
.kanban-column { min-width: 220px; border-radius: 13px; }
.column-heading { display: flex; align-items: center; gap: 8px; padding: 13px 12px; border: 1px solid transparent; border-radius: 11px; margin-bottom: 10px; }
.heading-gray { background: #e9edf4; border-color: #dfe5ee; }.heading-blue { background: #dceaff; border-color: #c8dcff; }.heading-amber { background: #fff0c2; border-color: #ffe6a0; }.heading-green { background: #d5f8e8; border-color: #b7efd6; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #8a96a8; }.heading-blue .status-dot { background: #3478f6; }.heading-amber .status-dot { background: #d18b0d; }.heading-green .status-dot { background: #179968; }
.column-heading strong { font-size: 12px; flex: 1; }
.column-count { min-width: 24px; text-align: center; padding: 3px 6px; border-radius: 20px; background: #ffffffbb; color: #59657a; font-size: 11px; }
.task-card { background: white; border: 1px solid #e6eaf1; border-radius: 12px; padding: 13px; margin-bottom: 10px; box-shadow: 0 3px 10px #233b6408; transition: transform .15s,box-shadow .15s; }
.task-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px #233b6412; }
.task-topline { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 9px; }
.task-id { color: #6080b6; font-size: 10px; font-weight: 750; letter-spacing: .4px; }
.priority { padding: 4px 7px; border-radius: 20px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.priority-Thấp { background: #edf2f7; color: #64748b; }.priority-Trung-bình { background: #e8f1ff; color: #3268c4; }.priority-Cao { background: #fff0d7; color: #a65c00; }.priority-Khẩn-cấp { background: #ffe5e5; color: #c52d3a; }
.task-card h3 { font-size: 13px; line-height: 1.45; margin: 0 0 8px; overflow-wrap: anywhere; }
.description { color: #7a8599; font-size: 11px; line-height: 1.5; margin: 0 0 9px; }
.assignee { color: #68758c; font-size: 11px; margin: 10px 0; }
.task-meta { border-top: 1px solid #f0f2f6; padding-top: 9px; color: #8993a4; font-size: 10px; }
.card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.card-actions form { margin: 0; }
.small-btn { padding: 6px 8px; border-radius: 6px; border: 1px solid #e0e6ef; background: #f8faff; color: #50617d; cursor: pointer; font-size: 11px; }
.small-btn:hover { background: #edf3ff; }
.small-btn.danger { color: #c43b48; background: #fff7f7; border-color: #f5dada; }
.move-form { flex: 1; min-width: 110px; }
.move-form select { width: 100%; min-width: 0; border: 1px solid #e0e6ef; border-radius: 6px; padding: 6px 3px; font-size: 10px; background: white; color: #526078; }
.empty-column { border: 1px dashed #d8deea; border-radius: 10px; color: #98a2b3; text-align: center; padding: 22px 8px; background: #ffffff70; font-size: 12px; }
.add-inline { width: 100%; padding: 11px; border: 1px dashed #ccd5e4; border-radius: 9px; background: transparent; color: #72809a; cursor: pointer; }
.add-inline:hover { background: white; border-color: #8bb3ff; color: #2563eb; }
.messages { margin-bottom: 14px; }.alert { border-radius: 8px; padding: 11px 14px; margin-bottom: 7px; }.alert.success { color: #126b4b; background: #dcf8e9; }.alert.error { color: #a52c38; background: #ffe6e8; }
.footer-note { color: #929bad; text-align: right; padding-top: 12px; font-size: 11px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; background: #101a30a8; display: grid; place-items: center; padding: 20px; }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(620px,100%); max-height: 90vh; overflow-y: auto; background: white; border-radius: 16px; padding: 25px; box-shadow: 0 25px 80px #0003; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.modal h2 { margin: 5px 0 0; font-size: 22px; }
.close-btn { border: 0; background: #f0f3f8; color: #58647a; width: 32px; height: 32px; border-radius: 9px; font-size: 23px; cursor: pointer; }
.modal label { display: block; font-weight: 650; font-size: 12px; color: #4d5970; margin-bottom: 13px; }
.modal label span { color: #e04452; }
.modal input, .modal textarea, .modal select { display: block; width: 100%; margin-top: 7px; padding: 11px; border: 1px solid #dfe5ee; border-radius: 8px; background: #fbfcff; color: #253149; outline: none; }
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: #7aa7ff; box-shadow: 0 0 0 3px #2563eb15; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 8px; }
@media(max-width:1200px) { .stats { grid-template-columns: repeat(3,minmax(120px,1fr)); }.kanban { grid-template-columns: repeat(4,minmax(240px,1fr)); } }
@media(max-width:760px) { .sidebar { width: 65px; flex-basis: 65px; padding: 12px 7px; }.brand { justify-content: center; padding: 5px 0 18px; }.brand > div:last-child,.nav-item { font-size: 0; }.nav-item { text-align: center; padding: 13px 4px; }.nav-item:first-letter { font-size: 18px; }.sidebar-bottom { display: none; }.main { padding: 18px 12px; }.topbar { align-items: flex-start; }.topbar h1 { font-size: 23px; }.topbar .btn { padding: 10px; font-size: 12px; }.stats { grid-template-columns: repeat(2,minmax(110px,1fr)); }.filters { flex-wrap: wrap; }.filters input { flex-basis: 100%; }.filters select { flex: 1; }.kanban { grid-template-columns: repeat(4,minmax(245px,1fr)); }.form-grid { grid-template-columns: 1fr; } }

/* Giao diện Hồ sơ nhân sự */
.employee-summary { display:grid; grid-template-columns:repeat(3,minmax(150px,1fr)); gap:13px; margin-bottom:18px; }
.employee-summary > div { background:white; border:1px solid var(--border); border-radius:12px; padding:17px; box-shadow:var(--shadow); }
.employee-summary span { display:block; color:var(--muted); font-size:12px; margin-bottom:8px; }
.employee-summary strong { font-size:22px; color:#1e3150; }
.employee-grid { display:grid; grid-template-columns:repeat(3,minmax(230px,1fr)); gap:14px; align-items:start; }
.employee-card { background:white; border:1px solid var(--border); border-radius:14px; padding:17px; box-shadow:var(--shadow); min-width:0; }
.employee-head { display:flex; align-items:center; gap:10px; padding-bottom:14px; border-bottom:1px solid #edf0f6; }
.avatar { width:42px; height:42px; flex:0 0 42px; display:grid; place-items:center; border-radius:13px; color:white; font-size:18px; font-weight:800; background:linear-gradient(135deg,#36a3ff,#6257e8); }
.employee-name { flex:1; min-width:0; }.employee-name h3 { margin:0 0 5px; font-size:14px; overflow-wrap:anywhere; }.employee-name p { margin:0; color:var(--muted); font-size:11px; }
.employee-status { border-radius:20px; padding:5px 7px; font-size:10px; font-weight:700; white-space:nowrap; }.employee-status.is-active { background:#d9f8e9; color:#14734f; }.employee-status.is-inactive { background:#edf0f5; color:#69758a; }
.employee-details { display:grid; grid-template-columns:1fr 1fr; gap:14px 10px; padding:15px 0; }.employee-details span { display:block; font-size:10px; color:#8994a7; margin-bottom:5px; }.employee-details strong { display:block; font-size:12px; font-weight:600; overflow-wrap:anywhere; color:#3d4a61; }
.employee-actions { display:flex; justify-content:flex-end; gap:7px; border-top:1px solid #edf0f6; padding-top:12px; }.employee-actions form { margin:0; }
@media(max-width:1100px) { .employee-grid { grid-template-columns:repeat(2,minmax(220px,1fr)); } }
@media(max-width:760px) { .employee-grid,.employee-summary { grid-template-columns:1fr; } }

/* Đăng nhập và cài đặt tài khoản */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left,#dce9ff 0,transparent 38%),linear-gradient(135deg,#f4f7ff,#eef2f9); }
.auth-card { width: min(460px,100%); background: #fff; padding: 34px; border: 1px solid #e3e9f3; border-radius: 20px; box-shadow: 0 22px 70px #233b6417; }
.auth-brand { padding: 0 0 25px; border: 0; margin-bottom: 22px; color: var(--ink); }
.auth-brand strong { color: var(--ink); }.auth-card h1 { font-size: 28px; margin: 8px 0; }.auth-subtitle,.muted { color: #7b879b; line-height: 1.6; font-size: 13px; }
.auth-form { display: grid; gap: 15px; margin-top: 22px; }.auth-form label,.settings-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; color: #4d5970; }
.auth-form input,.settings-form input,.settings-form select,.inline-admin-form input,.inline-admin-form select { width: 100%; padding: 11px; border: 1px solid #dfe5ee; border-radius: 8px; background: #fbfcff; color: #253149; min-width: 0; }
.block-btn { width: 100%; padding: 12px; }.auth-foot { display: block; margin-top: 20px; color: #8994a7; line-height: 1.6; }
.logout-form { margin-top: 13px; }.logout-btn { border: 0; background: transparent; color: #ffb4b8; padding: 0; cursor: pointer; font-size: 12px; }
.settings-grid { display: grid; grid-template-columns: minmax(280px,.9fr) minmax(300px,1.1fr); gap: 16px; margin-bottom: 17px; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel h2 { font-size: 17px; margin: 0 0 8px; }.settings-form { display: grid; gap: 13px; margin-top: 18px; }
.permission-row { display: flex; align-items: flex-start; gap: 13px; padding: 16px 0; border-top: 1px solid #edf0f5; }.permission-row p { margin: 5px 0 0; color: #778196; line-height: 1.6; font-size: 12px; }
.role-pill,.state-pill,.you-tag,.count-chip { display: inline-block; white-space: nowrap; border-radius: 30px; padding: 5px 8px; font-size: 10px; font-weight: 800; }
.admin-pill { color: #5144c5; background: #ebe8ff; }.member-pill { color: #1c6db8; background: #e4f2ff; }.state-on { color: #14805b; background: #d9f8e9; }.state-off { color: #b33c47; background: #ffe5e7; }.you-tag { margin-left: 6px; color: #2563eb; background: #e6efff; padding: 3px 6px; }.count-chip { color: #2563eb; background: #e8f0ff; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }.panel-heading h2 { margin: 0; }
.table-wrap { overflow-x: auto; }table { width: 100%; border-collapse: collapse; font-size: 12px; }th,td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #edf0f5; vertical-align: top; }th { color: #758198; background: #f8faff; font-weight: 750; white-space: nowrap; }td { color: #39465d; }
.inline-admin-form { display: grid; grid-template-columns: minmax(100px,1fr) minmax(110px,1fr) minmax(90px,.8fr) auto; gap: 5px; min-width: 360px; }.inline-admin-form select,.inline-admin-form input { padding: 7px; font-size: 11px; }.inline-admin-form input[type=password] { min-width: 120px; }.accounts-panel .inline-admin-form:last-child { grid-template-columns: minmax(120px,1fr) auto; min-width: 210px; }
@media(max-width:1000px) { .settings-grid { grid-template-columns: 1fr; } }

/* TRIVIET MOBILE RESPONSIVE PATCH V1 */
/* Giao diện điện thoại: full width, menu trượt, thẻ 2 cột, Kanban cuộn ngang. */
.mobile-nav-toggle,
.mobile-nav-backdrop {
  display: none;
}

@media (max-width: 760px) {
  html, body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body.mobile-nav-open {
    overflow: hidden;
    touch-action: none;
  }

  .app-shell {
    display: flex;
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: clip;
  }

  /* Menu trái chuyển thành ngăn kéo; không còn chiếm chỗ nội dung. */
  .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0;
    z-index: 1002;
    width: min(300px, 86vw) !important;
    min-width: 0 !important;
    max-width: 86vw;
    height: 100vh;
    height: 100dvh;
    flex: 0 0 auto !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 12px calc(22px + env(safe-area-inset-bottom)) !important;
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .22s ease, visibility .22s ease;
    box-shadow: none;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    box-shadow: 16px 0 42px rgba(8, 17, 38, .24);
  }

  /* Trả lại nhãn menu đầy đủ khi ngăn kéo được mở. */
  .sidebar .brand {
    justify-content: flex-start !important;
    padding: 4px 7px 22px !important;
  }
  .sidebar .brand > div:last-child {
    display: block !important;
  }
  .sidebar .nav {
    display: grid !important;
    gap: 6px;
    padding-top: 18px;
  }
  .sidebar .nav-item {
    display: block;
    width: 100%;
    padding: 12px 11px !important;
    text-align: left !important;
    font-size: 14px !important;
    line-height: 1.35;
    white-space: normal;
  }
  .sidebar .sidebar-bottom {
    display: block !important;
    margin-top: auto;
  }

  .mobile-nav-toggle {
    display: flex !important;
    position: fixed;
    top: calc(env(safe-area-inset-top) + 10px);
    left: 12px;
    z-index: 1004;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 12px;
    background: #123a72;
    color: #fff;
    box-shadow: 0 5px 18px rgba(18, 58, 114, .25);
    font: 700 13px/1.2 "Segoe UI", Arial, sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-toggle-icon {
    display: inline-block;
    font-size: 20px;
    line-height: 1;
  }
  .mobile-nav-backdrop {
    display: none;
  }
  .app-shell.sidebar-open .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1001;
    background: rgba(9, 17, 34, .48);
    -webkit-tap-highlight-color: transparent;
  }

  /* Vùng nội dung sử dụng toàn bộ bề rộng máy. */
  .main {
    display: block;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 64px 12px calc(24px + env(safe-area-inset-bottom)) !important;
    box-sizing: border-box;
  }
  .main > *, .main section, .main header {
    min-width: 0;
    max-width: 100%;
  }
  .main img, .main video, .main iframe {
    max-width: 100%;
  }

  .topbar {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
    min-width: 0;
  }
  .topbar > div:first-child { min-width: 0; }
  .topbar .eyebrow { font-size: 10px; }
  .topbar h1 {
    font-size: clamp(23px, 6vw, 28px) !important;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  .topbar p { font-size: 13px; line-height: 1.45; }
  .topbar > div:last-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px !important;
  }
  .topbar .btn {
    width: 100%;
    min-width: 0;
    padding: 11px 8px !important;
    white-space: normal;
    text-align: center;
    font-size: 13px !important;
    line-height: 1.25;
  }

  /* Thẻ thống kê hiển thị hai cột, không bị kéo thành trang rộng. */
  .stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 14px !important;
  }
  .stat-card {
    min-width: 0 !important;
    min-height: 86px;
    padding: 13px 12px !important;
    border-radius: 14px;
    overflow: hidden;
  }
  .stat-card span {
    font-size: 12px !important;
    line-height: 1.35;
    padding-right: 25px;
    overflow-wrap: anywhere;
  }
  .stat-card strong {
    font-size: 24px !important;
    line-height: 1.15;
    margin-top: 8px !important;
  }
  .stat-icon { right: 10px !important; top: 10px !important; width: 26px; height: 26px; }

  /* Bộ lọc xếp hàng gọn và trường nhập đủ rộng. */
  .filter-bar {
    width: 100%;
    max-width: 100%;
    padding: 10px !important;
    margin-bottom: 14px !important;
  }
  .filters {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    width: 100%;
  }
  .filters input,
  .filters input[type="search"] {
    grid-column: 1 / -1;
    width: 100% !important;
    min-width: 0 !important;
    font-size: 16px !important;
    padding: 11px 10px !important;
  }
  .filters select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    padding: 10px 7px !important;
    font-size: 12px !important;
  }
  .filters .btn {
    width: 100%;
    min-width: 0;
    padding: 10px 7px;
  }

  /* Bảng Kanban cuộn ngang bên trong, không kéo toàn bộ trang. */
  .kanban {
    display: grid !important;
    grid-template-columns: none !important;
    grid-auto-flow: column !important;
    grid-auto-columns: minmax(260px, calc(100vw - 32px)) !important;
    gap: 12px !important;
    align-items: start;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 2px 2px 14px !important;
    box-sizing: border-box;
    touch-action: pan-x pan-y;
  }
  .kanban-column {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    scroll-snap-align: start;
  }
  .kanban-column .column-heading { gap: 7px; padding: 11px 10px; }
  .kanban-column .column-heading strong { font-size: 12px; overflow-wrap: anywhere; }
  .kanban-column .task-card { min-width: 0; overflow-wrap: anywhere; }
  .task-card { padding: 12px; }
  .card-actions, .workflow-actions { flex-wrap: wrap; gap: 7px; }
  .card-actions button, .workflow-actions button, .small-btn { min-height: 36px; }
  .move-form { min-width: 0; flex-basis: 100%; }

  /* Các trang hồ sơ, khách hàng, tài sản, kế toán và cài đặt. */
  .employee-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .employee-summary > div { min-width: 0; padding: 13px; }
  .employee-grid,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }
  .employee-card, .panel { min-width: 0; padding: 15px; }
  .employee-details { grid-template-columns: minmax(0, 1fr) !important; }
  .form-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 0 !important; }
  .inline-admin-form,
  .accounts-panel .inline-admin-form {
    grid-template-columns: minmax(0, 1fr) !important;
    min-width: 0 !important;
  }
  .inline-admin-form input,
  .inline-admin-form select,
  .inline-admin-form button { width: 100%; min-width: 0 !important; }
  .table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table { min-width: 620px; }

  /* Hộp thoại và biểu mẫu vừa màn hình, hỗ trợ vùng an toàn điện thoại. */
  .modal-backdrop {
    place-items: center;
    padding: 8px !important;
    padding-top: max(8px, env(safe-area-inset-top)) !important;
    padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    max-height: 90dvh !important;
    overflow-y: auto;
    padding: 18px 14px !important;
    border-radius: 15px;
  }
  .modal h2 { font-size: 20px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 120px; }
  .main input,
  .main select,
  .main textarea,
  .modal input,
  .modal select,
  .modal textarea {
    max-width: 100%;
    min-width: 0;
    font-size: 16px;
  }
  .auth-body { padding: 12px !important; }
  .auth-card { width: 100% !important; max-width: 460px; padding: 22px 17px !important; }
}

@media (max-width: 360px) {
  .main { padding-left: 9px !important; padding-right: 9px !important; }
  .stats { gap: 8px !important; }
  .stat-card { padding: 11px 9px !important; }
  .stat-card span { font-size: 11px !important; }
  .topbar > div:last-child { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .filters input, .filters input[type="search"] { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none !important; }
}

/* BEGIN TRIVIET MOBILE UI FIX V3 */
/* Put the navigation control in normal page flow and keep it reachable while scrolling. */
@media (max-width: 760px) {
  .main {
    padding-top: 12px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .main > .mobile-nav-toggle {
    position: sticky !important;
    top: 0 !important;
    left: auto !important;
    right: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: calc(100% + 24px) !important;
    max-width: none !important;
    min-height: 48px !important;
    margin: -12px -12px 12px !important;
    padding: 10px 14px !important;
    box-sizing: border-box !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(255,255,255,.20) !important;
    border-radius: 0 0 12px 12px !important;
    background: #123a72 !important;
    color: #fff !important;
    box-shadow: 0 3px 12px rgba(8,17,38,.16) !important;
    z-index: 1004 !important;
    font-size: 14px !important;
  }

  .main > .topbar {
    margin-top: 0 !important;
  }

  /* Use the entire phone width for search and filtering controls. */
  .filter-bar {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .filters {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    min-width: 0 !important;
    gap: 8px !important;
  }
  .filters input,
  .filters input[type="search"],
  .filters select,
  .filters button,
  .filters a {
    grid-column: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* On a phone, stack the Kanban status lanes vertically so none is cut off. */
  .kanban {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    padding: 0 0 16px !important;
    margin: 0 !important;
    scroll-snap-type: none !important;
    box-sizing: border-box !important;
  }
  .kanban-column {
    display: block !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }
  .kanban-column .task-card,
  .kanban-column .column-heading,
  .kanban-column .accounting-queue-title,
  .kanban-column .empty-column {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-wrap: anywhere !important;
  }
  .kanban-column .task-card h3,
  .kanban-column .task-card p,
  .kanban-column .task-card span,
  .kanban-column .task-card .task-time {
    overflow-wrap: anywhere !important;
    word-break: normal;
  }
  .card-actions,
  .workflow-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .card-actions button,
  .card-actions a,
  .workflow-actions button,
  .workflow-actions a,
  .small-btn {
    min-height: 40px !important;
    max-width: 100% !important;
  }
}

@media (max-width: 360px) {
  .main {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  .main > .mobile-nav-toggle {
    width: calc(100% + 16px) !important;
    margin-left: -8px !important;
    margin-right: -8px !important;
  }
}
/* END TRIVIET MOBILE UI FIX V3 */

/* BEGIN TRIVIET MOBILE HORIZONTAL KANBAN V4 */
/* Keep statistics and forms responsive, but allow the Kanban lanes to swipe sideways. */
@media (max-width: 760px) {
  .kanban {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: x proximity !important;
    scroll-behavior: smooth;
    touch-action: pan-x pan-y !important;
    padding: 2px 4px 18px !important;
    margin: 0 0 16px !important;
    box-sizing: border-box !important;
    scrollbar-width: thin;
    scrollbar-color: #7890b5 #e5eaf2;
  }

  .kanban::-webkit-scrollbar {
    height: 7px;
  }
  .kanban::-webkit-scrollbar-track {
    background: #e5eaf2;
    border-radius: 10px;
  }
  .kanban::-webkit-scrollbar-thumb {
    background: #7890b5;
    border-radius: 10px;
  }

  .kanban > .kanban-column {
    display: block !important;
    flex: 0 0 82vw !important;
    width: 82vw !important;
    min-width: 250px !important;
    max-width: 340px !important;
    margin: 0 !important;
    align-self: stretch !important;
    scroll-snap-align: start;
    box-sizing: border-box !important;
  }

  .kanban > .kanban-column .task-card,
  .kanban > .kanban-column .column-heading,
  .kanban > .kanban-column .accounting-queue-title,
  .kanban > .kanban-column .empty-column {
    width: 100%;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-wrap: anywhere;
  }
}
/* END TRIVIET MOBILE HORIZONTAL KANBAN V4 */
