/* ============================================================================
   updateserver.css — lớp thị giác của trang quản trị Update Server.

   Áp hướng thẩm mỹ đã duyệt ở bản mock: Be Vietnam Pro + JetBrains Mono,
   bo góc 10/6/pill, thang surface nhiều tầng, accent xanh thông, có chế độ tối.

   TÊN CLASS GIỮ NGUYÊN so với bản cũ nên Razor view không phải sửa theo.
   KHÔNG đụng tokens.css: file đó dùng chung với ClinicSolution, đổi --radius*
   ở đó sẽ kéo theo mọi màn bên kia.
   ========================================================================= */

/* ---- 1. Token ---------------------------------------------------------- */
:root {
  --us-font: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --us-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;

  --us-paper:   #f4f5f3;
  --us-raised:  #ffffff;
  --us-surface: #eceee9;
  --us-sink:    #e3e6e1;
  --us-text:    #1c211e;
  --us-text-2:  #3c4642;
  --us-muted:   #5f6a64;
  --us-faint:   #7d8781;
  --us-line:    rgba(28, 40, 34, .15);
  --us-hair:    rgba(28, 40, 34, .075);

  --us-accent:      #0d6e5b;
  --us-accent-dark: #0a5748;
  --us-accent-soft: #e2f0ec;
  --us-on-accent:   #ffffff;

  --us-danger:      #a8321f;
  --us-danger-soft: #fbeae6;
  --us-warn:        #8a5a00;
  --us-warn-soft:   #fbf1de;
  --us-info:        #1f5a86;
  --us-info-soft:   #e6eff7;

  --us-row: 36px;
  --us-radius: 6px;
  --us-radius-lg: 10px;
  --us-radius-pill: 999px;
  --us-side: 246px;
  --us-shadow: 0 1px 2px rgba(28, 40, 34, .05), 0 8px 24px -16px rgba(28, 40, 34, .35);

  color-scheme: light;
}

/* Chưa chọn sáng tối thì theo hệ điều hành. Nút đổi ghi data-theme lên thẻ html
   và luôn thắng khối này. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --us-paper:   #141815;
    --us-raised:  #1c211e;
    --us-surface: #232926;
    --us-sink:    #2a312d;
    --us-text:    #e7ebe8;
    --us-text-2:  #c6cec9;
    --us-muted:   #94a09a;
    --us-faint:   #7f8b85;
    --us-line:    rgba(231, 235, 232, .16);
    --us-hair:    rgba(231, 235, 232, .08);

    --us-accent:      #4bb99b;
    --us-accent-dark: #6fcfb4;
    --us-accent-soft: rgba(75, 185, 155, .15);
    --us-on-accent:   #0a1f1a;

    --us-danger:      #e08a75;
    --us-danger-soft: rgba(224, 138, 117, .15);
    --us-warn:        #d9ab5a;
    --us-warn-soft:   rgba(217, 171, 90, .14);
    --us-info:        #7fb3dc;
    --us-info-soft:   rgba(127, 179, 220, .14);

    --us-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -18px rgba(0, 0, 0, .9);

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --us-paper:   #141815;
  --us-raised:  #1c211e;
  --us-surface: #232926;
  --us-sink:    #2a312d;
  --us-text:    #e7ebe8;
  --us-text-2:  #c6cec9;
  --us-muted:   #94a09a;
  --us-faint:   #7f8b85;
  --us-line:    rgba(231, 235, 232, .16);
  --us-hair:    rgba(231, 235, 232, .08);

  --us-accent:      #4bb99b;
  --us-accent-dark: #6fcfb4;
  --us-accent-soft: rgba(75, 185, 155, .15);
  --us-on-accent:   #0a1f1a;

  --us-danger:      #e08a75;
  --us-danger-soft: rgba(224, 138, 117, .15);
  --us-warn:        #d9ab5a;
  --us-warn-soft:   rgba(217, 171, 90, .14);
  --us-info:        #7fb3dc;
  --us-info-soft:   rgba(127, 179, 220, .14);

  --us-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -18px rgba(0, 0, 0, .9);

  color-scheme: dark;
}

/* ---- 2. Nền tảng ------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: var(--us-paper);
  color: var(--us-text);
  font-family: var(--us-font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--us-accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono, .us-mono, .num { font-family: var(--us-mono); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--us-accent); outline-offset: 2px; border-radius: 3px; }

/* ---- 3. Khung ứng dụng ------------------------------------------------- */
.us-app { min-height: 100dvh; display: grid; grid-template-columns: var(--us-side) minmax(0, 1fr); }
.us-side {
  position: sticky; top: 0; height: 100dvh; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--us-raised); border-right: 1px solid var(--us-line);
}
.us-brand { padding: 16px 16px 13px; border-bottom: 1px solid var(--us-hair); }
.us-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.us-brand-sub { margin-top: 4px; color: var(--us-muted); font-size: 11.5px; }

.us-nav { display: flex; flex-direction: column; gap: 1px; padding: 9px 9px 14px; overflow-y: auto; flex: 1; }
.us-nav-heading {
  padding: 13px 7px 5px; color: var(--us-muted);
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
}
.us-nav-item {
  min-height: 33px; display: flex; align-items: center; gap: 9px;
  padding: 5px 9px; border-radius: var(--us-radius);
  color: var(--us-text-2); text-decoration: none;
  transition: background .16s ease, color .16s ease;
}
.us-nav-item i { width: 16px; color: var(--us-muted); text-align: center; font-size: 13px; }
.us-nav-item:hover { background: var(--us-surface); text-decoration: none; }
.us-nav-item[aria-current="page"] { background: var(--us-accent-soft); color: var(--us-accent-dark); font-weight: 600; }
.us-nav-item[aria-current="page"] i { color: var(--us-accent-dark); }

/* Badge đếm việc chưa xử lý trên mục điều hướng */
.us-nav-count {
  margin-left: auto; flex: none;
  min-width: 20px; height: 18px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: var(--us-radius-pill);
  background: var(--us-danger); color: #fff;
  font-family: var(--us-mono); font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .us-nav-count { color: #2a0d07; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .us-nav-count { color: #2a0d07; } }
.us-nav-count[hidden] { display: none; }
.us-nav-count.moi { animation: usDapMach 1.1s ease-out 3; }

@keyframes usDapMach {
  0%   { box-shadow: 0 0 0 0 rgba(168, 50, 31, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(168, 50, 31, 0); }
  100% { box-shadow: 0 0 0 0 rgba(168, 50, 31, 0); }
}

.us-side-foot { margin-top: auto; padding: 11px 12px; border-top: 1px solid var(--us-hair); font-size: 12px; }
.us-server-state { display: flex; align-items: center; gap: 7px; color: var(--us-muted); font-size: 11.5px; }
.us-status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--us-accent); flex: none; }
.us-side-version { margin-top: 3px; color: var(--us-muted); font-size: 10.5px; }
.us-user-row { display: flex; align-items: center; gap: 6px; margin-top: 9px; }
.us-user-name { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.us-user-name strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-user-name span { color: var(--us-muted); font-size: 11px; }
.us-inline-form { display: inline; margin: 0; }

.us-main { min-width: 0; display: flex; flex-direction: column; }
.us-mobile-bar, .us-menu-scrim { display: none; }

/* Thanh trên: đường dẫn, đổi sáng tối, chuông thông báo */
.us-topbar {
  position: sticky; top: 0; z-index: 18;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 22px;
  background: var(--us-raised); border-bottom: 1px solid var(--us-line);
}
.us-crumb { min-width: 0; color: var(--us-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-crumb b { color: var(--us-text); font-weight: 600; }
.us-topbar-spacer { margin-left: auto; }

.us-bell { position: relative; }
.us-bell .us-nav-count {
  position: absolute; top: -5px; right: -5px; margin: 0;
  min-width: 17px; height: 17px; font-size: 10px;
  border: 2px solid var(--us-raised);
}
.us-bell-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  width: min(370px, calc(100vw - 32px));
  background: var(--us-raised); border: 1px solid var(--us-line);
  border-radius: var(--us-radius-lg); box-shadow: var(--us-shadow);
  overflow: hidden;
}
.us-bell-panel[hidden] { display: none; }
.us-bell-panel .us-list-row.chua-doc { background: var(--us-accent-soft); }

.us-content { padding: 18px 22px 40px; }

/* ---- 4. Cấu trúc trang ------------------------------------------------- */
.us-page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.us-page-head h1 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; }
.us-page-sub { color: var(--us-muted); font-size: 12.5px; margin-top: 3px; }
.us-head-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
/* Tiêu đề khối để chữ thường: viết hoa toàn bộ hợp với nhãn ngắn, nhưng đây là câu
   tiếng Việt có dấu, viết hoa hết thì dấu chồng lên nhau và khó đọc. */
.us-section-title { margin: 0; color: var(--us-text); font-size: 13px; font-weight: 600; letter-spacing: -.01em; text-transform: none; }

.us-panel { background: var(--us-raised); border: 1px solid var(--us-line); border-radius: var(--us-radius-lg); overflow: hidden; }
.us-panel-head {
  min-height: 38px; display: flex; align-items: center; gap: 8px;
  padding: 9px 13px; border-bottom: 1px solid var(--us-hair); background: var(--us-surface);
}
.us-panel-head i { color: var(--us-muted); }
.us-panel-head h2 { font-size: 13px; font-weight: 600; }
.us-panel-body { padding: 13px; }
.us-stack { display: flex; flex-direction: column; gap: 14px; }
.us-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.us-grid-dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; align-items: start; }
.us-grid-kho { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.us-grid-key { display: grid; grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); gap: 14px; align-items: start; }
.us-grid-check { display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: 14px; align-items: start; }
.us-sticky { position: sticky; top: 62px; }

/* ---- 5. KPI và danh sách ----------------------------------------------- */
.us-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 1px; margin-bottom: 16px;
  background: var(--us-line); border: 1px solid var(--us-line);
  border-radius: var(--us-radius-lg); overflow: hidden;
}
.us-kpi {
  min-height: 78px; padding: 12px 14px; border: 0;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--us-raised); color: inherit; text-align: left; text-decoration: none;
  transition: background .16s ease;
}
a.us-kpi { cursor: pointer; }
a.us-kpi:hover { background: var(--us-surface); text-decoration: none; }
.us-kpi-label { display: block; color: var(--us-muted); font-size: 11.5px; }
.us-kpi-value { display: block; font-family: var(--us-mono); font-size: 25px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.us-kpi-hint { display: block; color: var(--us-muted); font-size: 11px; }

.us-list { display: flex; flex-direction: column; }
.us-list-row {
  min-height: var(--us-row); display: flex; align-items: center; gap: 9px;
  padding: 7px 13px; border: 0; border-bottom: 1px solid var(--us-hair);
  background: transparent; color: inherit; text-align: left; text-decoration: none;
}
.us-list-row:last-child { border-bottom: 0; }
button.us-list-row, a.us-list-row, label.us-list-row { cursor: pointer; }
button.us-list-row:hover, a.us-list-row:hover, label.us-list-row:hover { background: var(--us-surface); text-decoration: none; }
.us-grow { flex: 1; min-width: 0; }
.us-truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-subline { display: block; color: var(--us-muted); font-size: 11.5px; }

/* ---- 6. Nút, ô nhập, thẻ ----------------------------------------------- */
.us-btn, .ft-btn, .bqp-nut {
  height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 12px; border: 1px solid var(--us-line); border-radius: var(--us-radius);
  background: var(--us-raised); color: var(--us-text);
  font-size: 12.5px; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .08s ease;
}
.us-btn:hover, .ft-btn:hover, .bqp-nut:hover { background: var(--us-surface); text-decoration: none; }
.us-btn:active, .ft-btn:active, .bqp-nut:active { transform: translateY(1px); }
.us-btn.primary, .ft-btn.add, .ft-btn.save, .bqp-nut.chinh {
  background: var(--us-accent); border-color: var(--us-accent); color: var(--us-on-accent);
}
.us-btn.primary:hover, .ft-btn.add:hover, .ft-btn.save:hover, .bqp-nut.chinh:hover {
  background: var(--us-accent-dark); border-color: var(--us-accent-dark);
}
.us-btn.secondary, .ft-btn.cancel { border-color: var(--us-line); background: var(--us-raised); }
.us-btn.danger, .ft-btn.delete, .bqp-nut.hoi {
  background: var(--us-danger); border-color: var(--us-danger); color: #fff;
}
:root[data-theme="dark"] .us-btn.danger, :root[data-theme="dark"] .ft-btn.delete { color: #2a0d07; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .us-btn.danger,
  :root:not([data-theme="light"]) .ft-btn.delete { color: #2a0d07; }
}
.us-btn.ghost { background: transparent; border-color: transparent; color: var(--us-accent-dark); }
.us-btn.ghost:hover { background: var(--us-accent-soft); }
.us-btn.small, .bqp-nut.nho { height: 27px; padding: 0 9px; font-size: 11.5px; }
.us-btn:disabled, .ft-btn:disabled { opacity: .5; cursor: not-allowed; }

.us-icon-btn, .icon-btn {
  width: 29px; height: 29px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--us-line); border-radius: var(--us-radius);
  background: var(--us-raised); color: var(--us-text-2);
  font-size: 12px; text-decoration: none; cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.us-icon-btn:hover, .icon-btn:hover { background: var(--us-surface); color: var(--us-text); text-decoration: none; }
.us-icon-btn.danger, .icon-btn.danger { color: var(--us-danger); }
.us-icon-btn.danger:hover, .icon-btn.danger:hover { background: var(--us-danger-soft); border-color: var(--us-danger); }
.us-icon-btn:disabled, .icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.row-act { display: flex; justify-content: flex-end; gap: 5px; }

.us-field, .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.us-field label, .field label { color: var(--us-text-2); font-size: 11.5px; font-weight: 600; }
.us-input, .inp, .sel, .txa {
  width: 100%; min-height: 32px; padding: 6px 9px;
  border: 1px solid var(--us-line); border-radius: var(--us-radius);
  background: var(--us-raised); color: var(--us-text);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.us-input:focus, .inp:focus, .sel:focus, .txa:focus {
  border-color: var(--us-accent); box-shadow: 0 0 0 3px var(--us-accent-soft); outline: none;
}
.us-input::placeholder { color: var(--us-muted); opacity: .85; }
.us-input:disabled, .sel:disabled { background: var(--us-sink); color: var(--us-muted); cursor: not-allowed; }
textarea.us-input, .txa { resize: vertical; line-height: 1.5; min-height: 60px; }

.us-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.us-field.span-2 { grid-column: span 2; }
.us-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; }
.us-check input { width: 15px; height: 15px; accent-color: var(--us-accent); }
.us-choice {
  display: flex; gap: 9px; padding: 9px 11px;
  border: 1px solid var(--us-line); border-radius: var(--us-radius);
  background: var(--us-raised); cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.us-choice + .us-choice { margin-top: 7px; }
.us-choice:hover { background: var(--us-surface); }
.us-choice:has(input:checked) { border-color: var(--us-accent); background: var(--us-accent-soft); }
.us-choice input { margin-top: 3px; accent-color: var(--us-accent); }
.us-choice strong, .us-choice span { display: block; }
.us-choice strong { font-size: 12.5px; }
.us-choice span span, .us-choice > span > span { color: var(--us-muted); font-size: 11.5px; }
.us-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 13px; }

.us-tabs { display: inline-flex; gap: 3px; padding: 3px; border-radius: var(--us-radius); background: var(--us-surface); }
.us-tab {
  min-height: 27px; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border: 0; border-radius: 4px;
  background: transparent; color: var(--us-muted); font-size: 12px;
  text-decoration: none; cursor: pointer;
}
.us-tab:hover { text-decoration: none; color: var(--us-text); }
.us-tab[aria-pressed="true"] { background: var(--us-raised); color: var(--us-text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.us-filter { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.us-filter .us-input, .us-filter .inp, .us-filter .sel { width: auto; min-width: 168px; }

/* ---- 7. Bảng ----------------------------------------------------------- */
.us-table-wrap { width: 100%; overflow-x: auto; }
.us-table, .store-table { width: 100%; min-width: 700px; border-collapse: collapse; table-layout: fixed; }
.us-table th, .store-table th {
  position: sticky; top: 0; z-index: 2;
  padding: 8px 11px; border-bottom: 1px solid var(--us-line);
  background: var(--us-surface); color: var(--us-muted);
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  text-align: left; text-transform: uppercase; white-space: nowrap;
}
.us-table td, .store-table td {
  height: var(--us-row); padding: 7px 11px;
  border-bottom: 1px solid var(--us-hair);
  vertical-align: middle; overflow: hidden; font-size: 12.5px;
}
.us-table td .num, .us-table td.num, .store-table td.num { font-family: var(--us-mono); font-size: 12px; }
.us-table tbody tr:hover, .store-table tbody tr:hover { background: var(--us-surface); }
.us-table .actions, .store-table .c-act { width: 112px; text-align: right; }

.store-head-table { display: none; }
.store-list { overflow-x: auto; }
.mod-group { border-bottom: 1px solid var(--us-hair); }
.grp-row {
  min-width: 700px; display: flex; align-items: center; gap: 9px;
  padding: 8px 13px; background: var(--us-surface); cursor: pointer; list-style: none;
}
.grp-row::-webkit-details-marker { display: none; }
.grp-row .chev { color: var(--us-muted); font-size: 11px; transition: transform .16s ease; }
.grp-row .mod-name { font-family: var(--us-mono); font-weight: 600; font-size: 12.5px; }
.grp-row .vcount { margin-left: auto; color: var(--us-muted); font-size: 11.5px; }
.mod-group:not([open]) .chev { transform: rotate(-90deg); }
.note-cell span, .note-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--us-muted); }
.store-table .c-ver { width: 16%; } .store-table .c-nguon { width: 12%; } .store-table .c-size { width: 10%; }
.store-table .c-sha { width: 15%; } .store-table .c-date { width: 16%; } .store-table .c-act { width: 74px; }

/* ---- 8. Thẻ trạng thái ------------------------------------------------- */
.us-chip, .chip, .hdr-badge, .utag, .tag-latest {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 2px 8px; border: 1px solid transparent; border-radius: var(--us-radius-pill);
  background: var(--us-surface); color: var(--us-text-2);
  font-size: 11px; line-height: 1.55; white-space: nowrap;
}
.us-chip i, .chip i { font-size: 10px; }
.us-chip.live, .chip.ok, .hdr-badge.ok {
  background: var(--us-accent-soft); color: var(--us-accent-dark);
  border-color: color-mix(in srgb, var(--us-accent) 30%, transparent);
}
.us-chip.expired, .chip.pending { background: var(--us-sink); color: var(--us-muted); }
.us-chip.revoked {
  background: var(--us-danger-soft); color: var(--us-danger);
  border-color: color-mix(in srgb, var(--us-danger) 28%, transparent);
  text-decoration: line-through;
}
.us-chip.trial, .hdr-badge.warn { background: transparent; color: var(--us-warn); border: 1px dashed var(--us-warn); }
.us-chip.tamper, .chip.err {
  background: var(--us-danger-soft); color: var(--us-danger);
  border-color: var(--us-danger); font-weight: 600;
}
.us-chip.locked {
  background: var(--us-warn-soft); color: var(--us-warn);
  border-color: color-mix(in srgb, var(--us-warn) 30%, transparent);
}
.us-chip.shared, .utag.chung { font-family: var(--us-mono); background: var(--us-surface); color: var(--us-muted); border-color: var(--us-hair); }
.us-chip.scoped, .utag.rieng { font-family: var(--us-mono); background: var(--us-accent-soft); color: var(--us-accent-dark); }
.us-chip.version, .chip.ver, .tag-latest {
  font-family: var(--us-mono); font-weight: 600;
  background: var(--us-info-soft); color: var(--us-info);
  border-color: color-mix(in srgb, var(--us-info) 26%, transparent);
}

/* ---- 9. Tải lên, dữ liệu máy, ghi chú ---------------------------------- */
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 132px; padding: 16px; text-align: center;
  border: 1.5px dashed var(--us-line); border-radius: var(--us-radius-lg);
  background: var(--us-surface); color: var(--us-muted); cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.dropzone:hover { border-color: var(--us-accent); }
.dropzone.drag { border-color: var(--us-accent); background: var(--us-accent-soft); }
.dropzone > i { color: var(--us-accent); font-size: 22px; }
.dropzone strong { color: var(--us-text); font-size: 13px; font-weight: 600; }
.dropzone .sub { color: var(--us-muted); font-size: 11.5px; }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.staged { margin-top: 9px; display: flex; flex-direction: column; gap: 4px; }
.staged-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 9px;
  border-radius: var(--us-radius); background: var(--us-surface);
  font-family: var(--us-mono); font-size: 11.5px;
}
.staged-row .fname { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staged-row .fsize { color: var(--us-muted); }

.us-machine, .tk-mk-value {
  padding: 9px 11px; border: 1px solid var(--us-hair); border-radius: var(--us-radius);
  background: var(--us-surface); color: var(--us-text-2);
  font-family: var(--us-mono); font-size: 11.5px; line-height: 1.65;
  overflow: auto; overflow-wrap: anywhere; user-select: all;
}
.tk-mk-value {
  border: 1px dashed var(--us-accent); background: var(--us-raised);
  font-size: 17px; letter-spacing: .04em; text-align: center; padding: 13px;
}

.us-note, .notice {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--us-info) 24%, transparent);
  border-radius: var(--us-radius);
  background: var(--us-info-soft); color: var(--us-text-2); font-size: 12px;
}
.us-note i, .notice i { color: var(--us-info); margin-top: 2px; }
.us-note.danger, .notice.dn-loi {
  background: var(--us-danger-soft);
  border-color: color-mix(in srgb, var(--us-danger) 28%, transparent);
}
.us-note.danger i, .notice.dn-loi i { color: var(--us-danger); }

.us-empty, .empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 34px 18px; color: var(--us-muted); text-align: center;
}
.us-empty i, .empty-state i { color: var(--us-faint); font-size: 22px; opacity: .7; }
.us-empty strong { color: var(--us-text); font-size: 13px; }
.us-pagination { display: flex; align-items: center; justify-content: center; gap: 11px; margin-top: 12px; color: var(--us-muted); font-size: 12px; }

.us-inline-dialog td { background: var(--us-warn-soft) !important; }

/* ---- 10. Hộp thoại và thông báo ---------------------------------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 20px;
  background: rgba(16, 22, 19, .5);
  animation: usVaoMask .16s ease;
}
.modal, dialog.us-dialog {
  width: min(480px, 100%); max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  padding: 0; border: 1px solid var(--us-line); border-radius: var(--us-radius-lg);
  background: var(--us-raised); color: var(--us-text);
  box-shadow: var(--us-shadow); overflow: hidden;
  animation: usVaoModal .2s cubic-bezier(.16, 1, .3, 1);
}
/* `display: flex` ở luật trên ĐÈ MẤT luật mặc định của trình duyệt
   `dialog:not([open]) { display: none }`. Không trả lại thì hộp thoại ĐANG ĐÓNG vẫn được
   vẽ ra giữa trang: lúc đó nó là phần tử thường (luật [open] bên dưới không khớp nên
   z-index auto), tiêu đề bảng sticky đè lên và cắt nát nội dung — nhìn ra thành "hộp thoại
   mờ tự bung khi mở màn". Vẫn dùng :not([open]) chứ không đặt display ở [open], để bản
   không JavaScript mở bằng thuộc tính `open` trong HTML vẫn chạy. */
dialog.us-dialog:not([open]) { display: none; }

dialog.us-dialog { width: min(620px, calc(100vw - 32px)); }
dialog.us-dialog::backdrop { background: rgba(16, 22, 19, .5); }
dialog.us-dialog > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

/* Mở bằng showModal() thì hộp thoại nằm ở top layer, không phần tử nào đè lên được.
   Nhưng nếu phải rơi về chế độ thường, nó là phần tử bình thường với z-index auto,
   nên tiêu đề bảng sticky (z-index 2) và thanh trên (z-index 18) sẽ đè lên và cắt
   nát nội dung. Nâng z-index và tự vẽ lớp phủ cho trường hợp đó. */
dialog.us-dialog[open] { position: fixed; inset: 0; margin: auto; z-index: 90; }
dialog.us-dialog.khong-modal::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: rgba(16, 22, 19, .5);
}

.modal-head, .modal-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 14px; }
.modal-head { border-bottom: 1px solid var(--us-hair); font-weight: 600; }
.modal-head .t { font-weight: 600; }
.modal-head .t.danger { color: var(--us-danger); }
.modal-head .x { margin-left: auto; color: var(--us-muted); }
.modal-body { padding: 14px; overflow-y: auto; }
.modal-warn {
  display: flex; gap: 9px; padding: 9px 11px; border-radius: var(--us-radius);
  background: var(--us-danger-soft); color: var(--us-danger);
}
.modal-foot { justify-content: flex-end; border-top: 1px solid var(--us-hair); background: var(--us-surface); }

.toast-wrap {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  position: relative; display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--us-line); border-radius: var(--us-radius-lg);
  background: var(--us-raised); box-shadow: var(--us-shadow);
  font-size: 12.5px;
  animation: usVaoToast .22s cubic-bezier(.16, 1, .3, 1);
}
.toast > i { margin-top: 2px; color: var(--us-accent); }
.toast.error > i { color: var(--us-danger); }
.toast.info > i { color: var(--us-warn); }
.toast-msg b { display: block; }
.toast-x { position: absolute; top: 9px; right: 10px; color: var(--us-muted); cursor: pointer; }
.toast:has(.toast-close:checked) { display: none; }

@keyframes usVaoMask  { from { opacity: 0; } to { opacity: 1; } }
@keyframes usVaoModal { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes usVaoToast { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

/* ---- 11. Đăng nhập ----------------------------------------------------- */
.dn-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 460px at 12% -8%, var(--us-accent-soft), transparent 62%),
    var(--us-paper);
}
.dn-shell { width: min(396px, 100%); }
.dn-brand { margin-bottom: 16px; }
.dn-brand-ten { font-size: 27px; font-weight: 700; letter-spacing: -.03em; }
.dn-brand-phu, .dn-ghichu { color: var(--us-muted); font-size: 12.5px; margin-top: 4px; }
.dn-card {
  display: flex; flex-direction: column; gap: 11px; padding: 18px;
  border: 1px solid var(--us-line); border-radius: var(--us-radius-lg);
  background: var(--us-raised); box-shadow: var(--us-shadow);
}
.dn-nut { width: 100%; }

/* ---- 12. Đáp ứng ------------------------------------------------------- */
@media (max-width: 1240px) {
  .us-grid-kho, .us-grid-key, .us-grid-check { grid-template-columns: minmax(0, 1fr); }
  .us-sticky { position: static; }
}

@media (max-width: 780px) {
  .us-app { display: block; }
  .us-mobile-bar {
    position: sticky; top: 0; z-index: 30; height: 48px;
    display: flex; align-items: center; gap: 9px; padding: 0 12px;
    border-bottom: 1px solid var(--us-line); background: var(--us-raised);
  }
  .us-mobile-bar .us-status-dot { margin-left: auto; }
  .us-side {
    position: fixed; left: 0; top: 0; width: min(286px, 88vw);
    transform: translateX(-101%); transition: transform .2s cubic-bezier(.16, 1, .3, 1);
    box-shadow: var(--us-shadow);
  }
  .us-menu-state:checked ~ .us-side { transform: translateX(0); }
  .us-menu-scrim { position: fixed; inset: 0; z-index: 15; background: rgba(16, 22, 19, .45); }
  .us-menu-state:checked ~ .us-menu-scrim { display: block; }
  .us-topbar { padding: 9px 14px; }
  .us-content { padding: 14px 14px 32px; }
  .us-grid-2, .us-grid-dashboard, .us-form-grid { grid-template-columns: minmax(0, 1fr); }
  .us-field.span-2 { grid-column: auto; }
  .us-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .us-kpis .us-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .us-page-head { align-items: flex-start; }
  .us-head-actions { width: 100%; margin-left: 0; }
  .us-filter { width: 100%; }
  .us-filter .us-input, .us-filter .inp, .us-filter .sel { flex: 1; min-width: 130px; }
}

@media (max-width: 480px) {
  .us-kpis { grid-template-columns: 1fr; }
  .us-head-actions .us-btn { flex: 1; }
  .us-tabs { max-width: 100%; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
