/* ================================================================
   SKYPEC — CSS RIÊNG CHO MÁY TÍNH  (chỉ nạp khi màn hình ≥ 768px)
   • 768–1023px : điều hướng là thanh ngang trên đầu.
   • ≥ 1024px    : điều hướng là menu dọc cố định bên trái.
   • Nhật ký nhập-xuất & lưới nhập: hiển thị dạng BẢNG từng cột.
   ================================================================ */

body { padding-bottom: 1.5rem; }
.sub .upd { display: inline; }

/* ---------- Thanh tab ngang trên đầu (tablet / laptop) ---------- */
.tabs {
  position: sticky; top: var(--topbar-h); z-index: 20;
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: .25rem; padding: .5rem 1rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.3) blur(10px);
          backdrop-filter: saturate(1.3) blur(10px);
}
.tab {
  flex: 0 0 auto; flex-direction: row; gap: .45rem;
  padding: .5rem .9rem; border-radius: var(--radius-sm);
  font-size: .88rem;
}
.tab .ic { width: 18px; height: 18px; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-bg); color: var(--accent); }

/* ---------- Layout ---------- */
main { max-width: 1200px; padding: 1.1rem 1.5rem 1.5rem; }
.grid-2 { grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ---------- KPI ---------- */
.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 560px; }
.kpi-num { font-size: 1.7rem; }

/* ---------- Lưới thẻ nhiều cột ---------- */
.card-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: .75rem; }
#listCards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: .55rem; }

.segmented { max-width: 460px; }

/* ---------- Nhật ký: BẢNG từng cột ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-tbl { min-width: 760px; }
.data-tbl thead th { position: sticky; top: 0; z-index: 1; }
.data-tbl tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.data-tbl tbody tr:hover td { background: var(--accent-bg); }
.data-tbl .num { text-align: right; }
.data-tbl .col-stt    { width: 52px; text-align: right; color: var(--muted); }
.data-tbl .col-date   { width: 150px; white-space: nowrap; }
.data-tbl .col-type   { width: 104px; }
.data-tbl .col-code   { width: 140px; }
.data-tbl .col-qty    { width: 72px; text-align: right; }
.data-tbl .col-region { width: 120px; white-space: nowrap; }
.data-tbl .col-act    { width: 56px; text-align: center; }
.data-tbl .cell-name  { min-width: 180px; }
.data-tbl .cell-note  { min-width: 150px; }

/* ---------- Lưới nhập nhiều món: bảng cuộn trong modal ---------- */
.modal-box.wide { max-width: 820px; }
.entry-head { margin-bottom: .5rem; }
.entry-head.field-row { grid-template-columns: 1fr 1fr; }
.entry-wrap { margin: .6rem 0 .2rem; max-height: 54vh; overflow: auto; }
.entry-tbl { min-width: 640px; }
.entry-tbl thead th { position: sticky; top: 0; z-index: 1; }
.entry-tbl thead th { font-size: .68rem; }
.entry-tbl tbody td { padding: .32rem .35rem; }
.entry-tbl .col-stt { width: 40px; }
.entry-tbl .col-code { width: 150px; }
.entry-tbl .col-qty  { width: 84px; }
.entry-tbl .col-region { width: 130px; }
.entry-tbl .col-act  { width: 46px; text-align: center; }
.entry-tbl .e-qty { text-align: right; }

/* ---------- Modal canh giữa ---------- */
.modal { align-items: center; padding: 1rem; }
.modal-box { max-width: 480px; max-height: 90vh; border-radius: 16px; padding: 1.4rem; box-shadow: var(--shadow-lg); animation: fade .18s ease; }
.detail-box { max-width: 560px; }
.login-box  { max-width: 360px; }

/* ---------- Toast ---------- */
.toast { bottom: 1.5rem; }

/* ================================================================
   ≥ 1024px — MENU DỌC BÊN TRÁI, nội dung dàn rộng
   ================================================================ */
@media (min-width: 1024px) {
  :root { --side-w: 228px; }
  body { padding-left: var(--side-w); }

  .tabs {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: var(--side-w); height: auto;
    flex-direction: column; flex-wrap: nowrap; justify-content: flex-start;
    gap: .15rem; padding: 1rem .75rem;
    background: var(--surface);
    border-right: 1px solid var(--line); border-bottom: 0;
    z-index: 45; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .nav-brand {
    display: flex; align-items: center; gap: .55rem;
    padding: .35rem .6rem 1.1rem; margin-bottom: .5rem;
    border-bottom: 1px solid var(--line);
    font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em;
  }
  .nav-brand .ic { width: 24px; height: 24px; color: var(--accent); }
  .tab { width: 100%; justify-content: flex-start; padding: .65rem .75rem; font-size: .92rem; }
  .tab span { overflow: visible; }

  .topbar { grid-template-columns: 1fr auto auto; padding: .6rem 1.5rem; }
  .topbar-title { grid-column: 1; grid-row: 1; text-align: left; }
  .topbar h1 { font-size: 1.25rem; }
  .topbar-side:first-child { grid-column: 2; grid-row: 1; justify-content: flex-end; }
  .topbar-side.right { grid-column: 3; grid-row: 1; }
  .user-name { display: inline; max-width: 220px; }

  main { max-width: none; padding: 1.25rem 1.5rem 1.5rem; }

  #listCards { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
  #khoCards  { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }

  /* Danh sách: tìm kiếm | lọc | trạng thái cùng hàng */
  #tab-danhsach.active {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(320px, 440px) 380px;
    grid-template-areas:
      "search filter seg"
      "stats  stats  count"
      "cards  cards  cards";
    column-gap: .75rem; align-items: end;
  }
  #tab-danhsach .toolbar    { grid-area: search; margin: 0; }
  #tab-danhsach .filter-btn { display: none; }
  #listFilterPanel,
  #listFilterPanel[hidden] { grid-area: filter; display: grid !important; margin: 0; padding: 0; border: 0; background: none; }
  #tab-danhsach .segmented { grid-area: seg; margin: 0; max-width: none; }
  #listStats { grid-area: stats; margin: .75rem 0 .5rem; }
  #listCount { grid-area: count; text-align: right; margin: .75rem 0 .5rem; }
  #listCards { grid-area: cards; }

  /* Kho */
  #tab-kho.active {
    display: grid; grid-template-columns: 1fr 420px;
    grid-template-areas: "kpi kpi" "tool seg" "sum sum" "cards cards";
    column-gap: .75rem; align-items: center;
  }
  #tab-kho .kpi-grid  { grid-area: kpi; max-width: 760px; }
  #tab-kho .toolbar   { grid-area: tool; margin: 0; }
  #tab-kho .segmented { grid-area: seg; margin: 0; max-width: none; }
  #khoSummary { grid-area: sum; margin: .75rem 0 .5rem; }
  #khoCards   { grid-area: cards; }

  /* Nhập xuất: KPI | tìm kiếm + bộ lọc; bảng dàn full */
  #tab-nhatky.active {
    display: grid; grid-template-columns: 1fr 420px;
    grid-template-areas: "kpi kpi" "tool filt" "sum sum" "table table";
    column-gap: .75rem; align-items: end;
  }
  #tab-nhatky .kpi-grid { grid-area: kpi; }
  #tab-nhatky .toolbar  { grid-area: tool; margin: 0; }
  #tab-nhatky .filters-inline { grid-area: filt; margin: 0; }
  #logSummary   { grid-area: sum; margin: .75rem 0 .5rem; }
  #logTableWrap { grid-area: table; }

  /* Tổng quan / Nhập / Báo cáo */
  .bars { height: 200px; }
  .ranklist { max-height: 420px; }
  #tab-nhap .box, #tab-xuat .box { max-width: 1100px; }

  .toast { left: calc(50% + var(--side-w) / 2); }
}

/* Laptop nhỏ */
@media (min-width: 1024px) and (max-width: 1299px) {
  #tab-danhsach.active {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "search search" "filter seg" "stats count" "cards cards";
    row-gap: .6rem;
  }
  #tab-kho.active, #tab-nhatky.active { grid-template-columns: 1fr 340px; }
}

@media (min-width: 1600px) {
  :root { --side-w: 252px; }
  main { padding: 1.4rem 2rem 2rem; }
}
