/* =============================================================
   GUIDIANZI MEDIA - He thong quan ly cong ty du lich
   Giao dien: chu lon, ro rang, khong chong lan, dung tot tren dien thoai
   ============================================================= */

:root {
  --primary: #0f7a8a;
  --primary-dark: #0a5c69;
  --primary-light: #e6f4f6;
  --accent: #e08321;
  --accent-light: #fdf1e3;

  --ok: #16794c;
  --ok-light: #e5f5ed;
  --warn: #b7791f;
  --warn-light: #fdf4e3;
  --danger: #c0392b;
  --danger-light: #fdecea;
  --info: #1d5fa8;
  --info-light: #e8f1fb;

  --bg: #f2f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #d8e0e5;
  --border-strong: #b9c6cd;
  --text: #17252b;
  --text-2: #4b5c66;
  --text-3: #7a8b95;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16, 40, 50, .06), 0 1px 3px rgba(16, 40, 50, .08);
  --shadow-2: 0 6px 20px rgba(16, 40, 50, .12);

  --fs-base: 16.5px;
  --fs-sm: 15px;
  --fs-xs: 13.5px;
  --fs-lg: 19px;
  --fs-xl: 24px;

  --sidebar-w: 268px;
  --topbar-h: 62px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.3; font-weight: 700; }
h1 { font-size: 26px; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: 17px; }
p { margin: 0 0 .8em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: var(--fs-xs); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: #eef2f4; }
::-webkit-scrollbar-thumb { background: #c2ced5; border-radius: 6px; border: 2px solid #eef2f4; }
::-webkit-scrollbar-thumb:hover { background: #a7b6bf; }

/* ============================ MAN HINH DANG NHAP ============================ */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(140deg, #0f7a8a 0%, #0a5c69 45%, #08404a 100%);
}
.login-card {
  width: 100%; max-width: 430px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  padding: 30px 28px 26px;
}
.login-logo {
  width: 60px; height: 60px; border-radius: 14px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; font-weight: 800; margin: 0 auto 14px;
  letter-spacing: .5px;
}
.login-card h1 { font-size: 21px; text-align: center; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-2); font-size: var(--fs-sm); margin-bottom: 22px; }
.login-hint {
  margin-top: 18px; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--primary-light); color: var(--primary-dark);
  font-size: var(--fs-sm); text-align: center;
}
.login-foot { margin-top: 16px; text-align: center; font-size: var(--fs-xs); color: var(--text-3); line-height: 1.5; }

/* ============================ KHUNG UNG DUNG ============================ */
.app { display: flex; min-height: 100vh; }

/* --------- Thanh ben trai --------- */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: #0d3b45; color: #cfe3e7;
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
  transition: transform .22s ease;
}
.sidebar-head {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; border-bottom: 1px solid rgba(255, 255, 255, .12);
  background: #0a3038;
}
.sidebar-logo {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-title { min-width: 0; }
.sidebar-title b { display: block; color: #fff; font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-title span { display: block; font-size: 12px; color: #8fb3ba; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav {
  flex: 1; overflow-y: auto; padding: 10px 0 18px;
  /* An thanh cuon cua menu ben trai cho phang phiu (van cuon duoc bang chuot/vuot tay) */
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE / Edge cu */
  overscroll-behavior: contain;
}
.nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.nav-group { padding: 11px 18px 4px; font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: #7ea3ab; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 18px; color: #cfe3e7; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(15, 122, 138, .35); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-item .ico { flex: 0 0 20px; width: 20px; height: 20px; opacity: .95; }
.nav-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .badge-count {
  background: var(--accent); color: #fff; border-radius: 10px;
  font-size: 12px; padding: 1px 7px; font-weight: 700;
}
.sidebar-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: 12px; color: #7ea3ab; position: relative;
}
/* Vet mo nhe o day menu: bao cho biet con muc phia duoi ma khong can thanh cuon */
.sidebar-foot::before {
  content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 26px;
  background: linear-gradient(to top, #0d3b45, rgba(13, 59, 69, 0));
  pointer-events: none;
}

/* --------- Vung noi dung --------- */
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  position: sticky; top: 0; z-index: 40;
}
.topbar h2 { margin: 0; font-size: var(--fs-lg); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.burger {
  display: none; width: 42px; height: 42px; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius-sm); cursor: pointer;
  align-items: center; justify-content: center; flex: 0 0 42px;
}

.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.lang-switch button {
  border: 0; background: transparent; padding: 6px 13px; cursor: pointer;
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); font-family: var(--font);
}
.lang-switch button.on { background: var(--primary); color: #fff; }

.user-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 5px 10px 5px 5px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface);
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px; background: var(--primary);
}
.user-chip .u-name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.15; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .u-role { font-size: 12px; color: var(--text-3); line-height: 1.15; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 232px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; z-index: 90;
}
.dropdown-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--fs-sm); color: var(--text); font-family: var(--font);
}
.dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 4px; }

.content { padding: 20px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .ph-text { flex: 1; min-width: 220px; }
.page-head h2 { margin: 0 0 3px; font-size: var(--fs-xl); }
.page-head .desc { color: var(--text-2); font-size: var(--fs-sm); margin: 0; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ============================ THANH PHAN CHUNG ============================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1); margin-bottom: 16px;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 17px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 9px 15px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; font-family: var(--font);
  min-height: 42px; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.94); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn .ico { width: 18px; height: 18px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); border-color: #f0bdb7; }

/* --------- Bieu mau --------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.form-grid.one { grid-template-columns: minmax(0, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .req { color: var(--danger); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; font-size: var(--fs-base); font-family: var(--font);
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  min-height: 44px; transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 122, 138, .16);
}
input:disabled, select:disabled, textarea:disabled { background: #eef2f4; color: var(--text-3); }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234b5c66' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.checkbox { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: var(--fs-sm); }
.checkbox input[type=checkbox] { width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 20px; accent-color: var(--primary); cursor: pointer; }

/* --------- Bang du lieu --------- */
.table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255,255,255,0)) left center / 34px 100% no-repeat,
    linear-gradient(to left, var(--surface) 30%, rgba(255,255,255,0)) right center / 34px 100% no-repeat,
    linear-gradient(to right, rgba(16,40,50,.13), rgba(16,40,50,0)) left center / 12px 100% no-repeat,
    linear-gradient(to left, rgba(16,40,50,.13), rgba(16,40,50,0)) right center / 12px 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.data td { padding: 10px 12px; text-align: left; vertical-align: middle; white-space: nowrap; }
table.data th.wrap, table.data td.wrap { white-space: normal; min-width: 190px; }
table.data th.wrap-lg, table.data td.wrap-lg { white-space: normal; min-width: 280px; }
table.data thead th {
  background: var(--surface-2); color: var(--text-2); font-weight: 700;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 2px solid var(--border); white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:hover { background: #f6fafb; }
table.data tbody tr:last-child { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.center, table.data th.center { text-align: center; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .cell-main { font-weight: 600; }
table.data .cell-sub { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.row-click { cursor: pointer; }

.empty { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty .big { font-size: 42px; opacity: .35; margin-bottom: 8px; }

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.toolbar .grow { flex: 1 1 220px; min-width: 180px; }
.toolbar input, .toolbar select { min-height: 42px; }
.toolbar input[type=date], .toolbar input[type=number] { width: auto; max-width: 190px; }
.toolbar select { width: auto; max-width: 260px; }
.filter-box { display: flex; align-items: center; gap: 8px; }
.filter-box > label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); white-space: nowrap; text-transform: uppercase; letter-spacing: .3px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager .info { color: var(--text-2); font-size: var(--fs-sm); flex: 1; }

/* --------- Nhan trang thai --------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs);
  font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.badge.gray { background: #eef2f4; color: #4b5c66; border-color: #dde4e8; }
.badge.green { background: var(--ok-light); color: var(--ok); border-color: #bfe3d1; }
.badge.blue { background: var(--info-light); color: var(--info); border-color: #c3d9f2; }
.badge.orange { background: var(--warn-light); color: var(--warn); border-color: #f0dcae; }
.badge.red { background: var(--danger-light); color: var(--danger); border-color: #f3c6c0; }
.badge.teal { background: var(--primary-light); color: var(--primary-dark); border-color: #b9dfe4; }

/* --------- The so lieu --------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow-1); display: flex; gap: 13px; align-items: flex-start;
}
.stat .s-ico {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary-dark);
}
.stat .s-body { min-width: 0; flex: 1; }
.stat .s-label { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat .s-value { font-size: 25px; font-weight: 800; line-height: 1.2; margin-top: 3px; font-variant-numeric: tabular-nums; word-break: break-word; }
.stat .s-extra { font-size: var(--fs-xs); color: var(--text-3); margin-top: 3px; }
.stat.green .s-ico { background: var(--ok-light); color: var(--ok); }
.stat.orange .s-ico { background: var(--warn-light); color: var(--warn); }
.stat.red .s-ico { background: var(--danger-light); color: var(--danger); }
.stat.blue .s-ico { background: var(--info-light); color: var(--info); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* --------- Bieu do cot don gian --------- */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 210px; padding: 10px 4px 0; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; }
.bars .bar-stack { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bars .bar {
  width: 44%; max-width: 34px; background: var(--primary); border-radius: 5px 5px 0 0;
  min-height: 3px; transition: height .3s;
}
.bars .bar.b2 { background: var(--accent); }
.bars .bar-label { font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; }
.bars .bar-value { font-size: var(--fs-xs); font-weight: 700; color: var(--text); white-space: nowrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); padding: 0 4px 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* --------- Danh sach viec can lam --------- */
.task-list { display: flex; flex-direction: column; }
.task-item {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.task-item:last-child { border-bottom: 0; }
.task-item:hover { background: var(--surface-2); }
.task-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: 0 0 10px; background: var(--info); }
.task-dot.warn { background: var(--warn); }
.task-text { flex: 1; font-size: var(--fs-sm); min-width: 0; }

/* --------- Cua so (modal) --------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12, 30, 36, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-2);
  width: 100%; max-width: 720px; margin: auto; display: flex; flex-direction: column;
  max-height: calc(100vh - 48px);
}
.modal.wide { max-width: 1000px; }
.modal.narrow { max-width: 480px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex: 0 0 auto;
}
.modal-head h3 { margin: 0; font-size: 19px; flex: 1; min-width: 0; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; flex: 0 0 auto;
  background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius);
}

/* --------- Thong bao --------- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  background: #14313a; color: #fff; padding: 13px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2); font-size: var(--fs-sm); display: flex; gap: 10px; align-items: flex-start;
  animation: toastIn .18s ease;
}
.toast.ok { background: #10603f; }
.toast.err { background: #93261a; }
.toast.warn { background: #8a5a12; }
.toast .t-close { margin-left: auto; cursor: pointer; opacity: .7; font-weight: 700; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --------- Bang phu (dong lap) --------- */
.subtable { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.subtable table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.subtable th { background: var(--surface-2); font-size: var(--fs-xs); text-transform: uppercase; color: var(--text-2); padding: 9px 10px; text-align: left; white-space: nowrap; }
.subtable td { padding: 7px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.subtable input, .subtable select { min-height: 40px; padding: 7px 9px; font-size: var(--fs-sm); }
.subtable .row-del { color: var(--danger); cursor: pointer; border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 4px 8px; }
.subtable-foot { padding: 9px 10px; background: var(--surface-2); border-top: 1px solid var(--border); }

/* --------- Ma tran phan quyen --------- */
.perm-module {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 11px; overflow: hidden;
}
.perm-head {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.perm-head .pm-name { font-weight: 700; flex: 1; font-size: var(--fs-sm); }
.perm-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
.perm-actions .checkbox {
  border: 1px solid var(--border); border-radius: 999px; padding: 7px 13px 7px 11px;
  background: var(--surface); font-size: var(--fs-sm); align-items: center;
}
.perm-actions .checkbox:hover { background: var(--surface-2); }
.perm-actions .checkbox.on { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

/* --------- Chi tiet --------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 13px 20px; }
.detail-item .d-label { font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.detail-item .d-value { font-size: var(--fs-base); font-weight: 600; word-break: break-word; }
.detail-item .d-value.money { font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: 11px 16px; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); font-family: var(--font);
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }

.timeline { border-left: 2px solid var(--border); margin-left: 8px; padding-left: 18px; }
.timeline .tl-item { position: relative; padding-bottom: 16px; }
.timeline .tl-item:before {
  content: ''; position: absolute; left: -25px; top: 5px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--primary); border: 2px solid var(--surface);
}
.timeline .tl-time { font-size: var(--fs-xs); color: var(--text-3); }

.alert {
  padding: 13px 16px; border-radius: var(--radius-sm); font-size: var(--fs-sm);
  margin-bottom: 14px; border: 1px solid transparent;
}
.alert.info { background: var(--info-light); color: var(--info); border-color: #c3d9f2; }
.alert.warn { background: var(--warn-light); color: var(--warn); border-color: #f0dcae; }
.alert.err { background: var(--danger-light); color: var(--danger); border-color: #f3c6c0; }
.alert.ok { background: var(--ok-light); color: var(--ok); border-color: #bfe3d1; }

.money-pos { color: var(--ok); font-weight: 700; }
.money-neg { color: var(--danger); font-weight: 700; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; } .mb-2 { margin-bottom: 18px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.loading { padding: 48px; text-align: center; color: var(--text-3); }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.overlay { display: none; }

/* --- An bot cot khi man hinh khong du rong --- */
@media (max-width: 1500px) {
  table.data th.hide-narrow, table.data td.hide-narrow { display: none; }
}

/* ============================ MAY TINH BANG ============================ */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============================ DIEN THOAI ============================ */
@media (max-width: 900px) {
  :root { --fs-base: 16px; --fs-sm: 15px; --fs-xs: 13.5px; }

  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-2); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .overlay {
    display: block; position: fixed; inset: 0; background: rgba(10, 26, 32, .5); z-index: 50;
  }
  .main { margin-left: 0; }
  .burger { display: inline-flex; }

  .content { padding: 14px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar h2 { font-size: 17px; }
  .user-chip .u-name, .user-chip .u-role { display: none; }
  .user-chip { padding: 4px; border: 0; background: transparent; }
  .user-chip .ico { display: none; }
  .toolbar input[type=date], .toolbar input[type=number], .toolbar select { width: 100%; max-width: none; }
  .filter-box { width: 100%; }
  .filter-box > label { flex: 0 0 90px; }

  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 11px; }
  .stat { padding: 13px; gap: 10px; }
  .stat .s-ico { width: 38px; height: 38px; flex: 0 0 38px; }
  .stat .s-value { font-size: 21px; }

  .modal-backdrop { padding: 0; }
  .modal { max-width: 100%; border-radius: 0; min-height: 100vh; max-height: none; margin: 0; }
  .modal-foot { position: sticky; bottom: 0; }
  .modal-foot .btn { flex: 1 1 auto; }

  /* Bang -> the (card) de doc tren dien thoai */
  table.data.responsive thead { display: none; }
  table.data.responsive, table.data.responsive tbody,
  table.data.responsive tr, table.data.responsive td { display: block; width: 100%; }
  table.data.responsive tr {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin: 0 0 11px; padding: 6px 4px; background: var(--surface);
  }
  table.data.responsive td {
    display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
    padding: 7px 12px; border: 0; text-align: right;
    white-space: normal; min-width: 0; overflow-wrap: anywhere;
  }
  table.data.responsive th.wrap, table.data.responsive td.wrap,
  table.data.responsive th.wrap-lg, table.data.responsive td.wrap-lg { min-width: 0; }
  table.data.responsive td:before {
    content: attr(data-label); flex: 0 0 42%; text-align: left;
    font-size: var(--fs-xs); color: var(--text-3); font-weight: 700;
    text-transform: uppercase; letter-spacing: .3px; padding-top: 2px;
  }
  table.data.responsive td.actions { justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }
  table.data.responsive td.actions:before { content: ''; flex: 0; }
  table.data.responsive td.hide-mobile { display: none; }
  .table-wrap { overflow-x: visible; }
  .card-body.tight { padding: 10px 10px 2px; }

  .toolbar { padding: 11px 12px; }
  .toolbar .grow { flex: 1 1 100%; }
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .bars { height: 170px; gap: 6px; }
  .bars .bar-label { font-size: 11px; }
  .bars .bar-value { font-size: 11px; }
  .page-head h2 { font-size: 21px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 400px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ============================ IN AN ============================ */
@media print {
  .sidebar, .topbar, .page-actions, .toolbar, .pager, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card { border: 0; box-shadow: none; }
  body { background: #fff; font-size: 12pt; }
}
