/* CRMPRO — giao diện Python, phong cách theo "new index.html" (sidebar navy, header trắng, slate + xanh #1e40af).
   CSS thuần, không cần build step. Giữ nguyên tên class cũ (.btn, .card, .input, .toolbar…) để mọi trang tự đổi theo. */
:root {
  --bg: #ffffff; --bg-soft: #f8fafc; --surface: #ffffff; --text: #1e293b; --text-2: #334155; --muted: #64748b;
  --border: #e2e8f0; --border-strong: #cbd5e1; --field: #f8fafc;
  --primary: #1e40af; --primary-dark: #1e3a8a; --primary-soft: #eff6ff; --accent: #3b82f6; --link: #2563eb;
  --danger: #dc2626; --danger-soft: #fef2f2; --danger-border: #fecaca; --amber: #b45309;
  --side-bg: #1a233a; --side-bg-deep: #151c2f; --side-active: #25304a; --side-text: #cbd5e1; --side-muted: #64748b;
  --radius: 6px; --header-h: 56px; --side-w: 220px;
  font-family: var(--ui-font, "Inter"), ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* .btn / flex không được đè thuộc tính hidden */
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: var(--ui-font-size, 13px); line-height: 1.45; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 18px; font-weight: 600; margin: 0; color: var(--text); }
h3 { font-size: 14px; font-weight: 600; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------------- shell ---------------- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--side-w); flex: 0 0 var(--side-w); background: var(--side-bg); color: var(--side-text); display: flex;
  flex-direction: column; z-index: 20; transition: width .2s, flex-basis .2s; font-size: 13px; }
.brand { height: var(--header-h); display: flex; align-items: center; gap: 8px; padding: 0 16px; background: var(--side-bg-deep);
  color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .06em; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 24px; height: 24px; border-radius: 4px; background: var(--accent); display: inline-flex; align-items: center;
  justify-content: center; font-size: 11px; flex-shrink: 0; }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 0 24px; }
.side-section { margin: 16px 16px 6px; font-size: 11px; font-weight: 600; color: var(--side-muted); text-transform: uppercase; letter-spacing: .06em; }
.side-top, .side-group > summary { display: flex; align-items: center; padding: 8px 16px 8px 12px; color: var(--side-text); cursor: pointer;
  list-style: none; border-left: 4px solid transparent; transition: background .15s, color .15s; }
.side-group > summary::-webkit-details-marker, .side-sub > summary::-webkit-details-marker { display: none; }
.side-top:hover, .side-group > summary:hover { color: #fff; background: rgba(255,255,255,.05); text-decoration: none; }
.side-ico { width: 24px; flex-shrink: 0; font-size: 13px; }
.side-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-caret { font-size: 9px; margin-left: 6px; transition: transform .15s; opacity: .8; }
details[open] > summary > .side-caret { transform: rotate(180deg); }
.side-group.is-active > summary, .side-top.is-active { background: var(--side-active); color: #fff; border-left-color: var(--accent); }
.side-children { background: var(--side-bg-deep); padding: 4px 0; }
.side-link { display: block; padding: 7px 16px 7px 40px; color: var(--side-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-link:hover { color: #fff; text-decoration: none; }
.side-link.active { color: #60a5fa; font-weight: 500; }
.side-sub > summary { display: flex; align-items: center; justify-content: space-between; padding: 7px 16px 7px 40px; cursor: pointer; list-style: none; }
.side-sub > summary:hover { color: #fff; }
.side-link.lvl3 { padding-left: 54px; }
html.sb-collapsed .sidebar { width: 56px; flex-basis: 56px; }
html.sb-collapsed .brand-text, html.sb-collapsed .side-label, html.sb-collapsed .side-caret,
html.sb-collapsed .side-children, html.sb-collapsed .side-section { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar { height: var(--header-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: #fff; border-bottom: 1px solid var(--border); z-index: 15; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.crumb { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.crumb i { font-size: 9px; }
.crumb b { color: var(--text); font-weight: 600; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px; line-height: 1; }
.icon-btn:hover { color: var(--text); text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #dbeafe; color: #2563eb; border: 1px solid #bfdbfe;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-pop { position: absolute; right: 0; top: 40px; width: 240px; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15,23,42,.12); padding: 6px; z-index: 60; }
.user-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-head b { color: var(--text); } .user-head span { font-size: 12px; color: var(--muted); }
.user-pop a, .user-pop button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; color: var(--text-2);
  background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.user-pop a:hover, .user-pop button:hover { background: var(--bg-soft); text-decoration: none; }
.user-pop button { color: var(--danger); }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; }

.content { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px; }

/* Cột chuyển trang bên trái (cùng thân trang với nội dung) — nhóm trang gom 1 mục menu (Cài đặt cơ bản, Mẫu in ấn) */
.content-row { flex: 1; min-height: 0; display: flex; }
.content-row > .content { min-width: 0; }
.page-rail { flex: none; width: 210px; border-right: 1px solid var(--border, #e2e8f0); background: var(--bg);
  display: flex; flex-direction: column; min-height: 0; transition: width .15s; }
.page-rail-toggle { flex: none; align-self: flex-end; margin: 8px; width: 28px; height: 28px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px; background: #fff; color: #475569; cursor: pointer; }
.page-rail-toggle:hover { background: var(--primary-soft); color: var(--primary); }
.page-rail-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.page-tab { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; color: #475569; font-size: 13px;
  border-left: 3px solid transparent; }
.page-tab .pt-ico { flex: none; width: 18px; text-align: center; }
.page-tab .pt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-tab:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.page-tab.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; border-left-color: var(--primary); }
.rail-collapsed .page-rail { width: 48px; }
.rail-collapsed .page-rail-toggle { align-self: center; }
.rail-collapsed .page-rail-toggle i { transform: rotate(180deg); }
.rail-collapsed .page-rail-list { padding: 0 4px 12px; }
.rail-collapsed .page-tab { padding: 7px 0; justify-content: center; border-left-width: 0; }
.rail-collapsed .page-tab .pt-label { display: none; }
@media (max-width: 760px) { .page-rail { width: 48px; } .page-rail .pt-label { display: none; } .page-rail .page-tab { justify-content: center; padding: 7px 0; } }

/* ---------------- page header / toolbar (khu vực chức năng của mẫu) ---------------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-title h1 { text-transform: uppercase; letter-spacing: .01em; }
.page-sub { margin-top: 3px; font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.filter-bar:empty { display: none; }
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box i { position: absolute; left: 10px; color: #94a3b8; font-size: 12px; pointer-events: none; }
.search-box input { height: 32px; width: 240px; padding: 0 10px 0 30px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--field); font: inherit; color: var(--text); }
.search-box input:focus, .input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--field); color: #475569; font-size: 13px; }
.chip button { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 0; }
.chip button:hover { color: var(--text); }

/* Bố cục cũ (các trang tự dựng toolbar) */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar h1 { text-transform: uppercase; }
.flex-1 { flex: 1; }
.muted { color: var(--muted); font-size: 12px; }
.notes { color: var(--muted); font-size: 12px; margin: -4px 0 10px; }
.dirty { color: var(--amber); font-size: 12px; font-weight: 500; }
.input, select.input, textarea.input { height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: inherit; color: var(--text); background: #fff; }
textarea.input { height: auto; padding: 6px 10px; }
.input[readonly] { background: var(--bg-soft); color: var(--muted); }
.w-64 { width: 16rem; }
.w-full { width: 100%; }

/* ---------------- buttons ---------------- */
.btn { height: 32px; padding: 0 14px; border-radius: var(--radius); border: 1px solid transparent; background: var(--primary); color: #fff;
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05); white-space: nowrap; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn i { font-size: 12px; }
.btn.secondary { background: #fff; color: #374151; border-color: var(--border-strong); }
.btn.secondary i { color: #9ca3af; }
.btn.secondary:hover { background: var(--bg-soft); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.danger-soft { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.btn.danger-soft:hover { background: #fee2e2; }

/* ---------------- cards / misc ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.card.p-0 { padding: 0; }
.card.msg { max-width: 640px; }
.card.msg h1 { margin-bottom: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--text); }
.tile .k { color: var(--muted); font-size: 12px; }
table.simple { border-collapse: collapse; width: 100%; background: #fff; }
table.simple th, table.simple td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; font-size: 13px; }
table.simple th { background: #f1f5f9; font-weight: 600; color: var(--text); }
table.simple tr:hover td { background: var(--bg-soft); }
table.simple td.num { text-align: right; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 16px; }
.form-grid label, .login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.check { flex-direction: row !important; align-items: center; gap: 6px !important; font-weight: 400 !important; }
.alert { background: var(--danger-soft); border: 1px solid var(--danger-border); color: #991b1b; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 10px; }
.ok-msg { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 10px; }

/* ---------------- grid page: split pane lấp đầy màn hình ---------------- */
.content.grid-fill { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
.split-pane { flex: 1; min-height: 0; display: flex; border-top: 1px solid var(--border); margin: 0 -16px; }
.grid-col { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.hot-wrap { position: relative; overflow: hidden; }
.grid-fill .hot-wrap { flex: 1; min-height: 320px; }
.grid-fill #grid { position: absolute; inset: 0; }
.grid-footer { flex-shrink: 0; border-top: 1px solid var(--border); padding: 8px 16px; font-size: 13px; font-weight: 600; color: #374151; background: #fff; }
.grid-footer:empty { display: none; }
.grid-footer .card { border: 0; padding: 0; }
.grid-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted);
  pointer-events: none; z-index: 10; }
.side-panel { width: 340px; flex-shrink: 0; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: #fff; }
.side-panel-head { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  border-bottom: 1px solid #f1f5f9; font-weight: 600; }
.side-panel-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; }

/* Timeline trạng thái (panel phải) */
.timeline { padding-left: 4px; }
.timeline-item { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 5px; top: 16px; bottom: -2px; width: 2px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--border-strong); margin-top: 3px; z-index: 1; flex-shrink: 0; }
.timeline-item.current .timeline-dot { background: #eab308; border-color: #fff; box-shadow: 0 0 0 1px #eab308; }
.timeline-item.done .timeline-dot { background: #22c55e; border-color: #fff; box-shadow: 0 0 0 1px #22c55e; }
.timeline-title { font-weight: 600; color: var(--text); line-height: 1.25; }
.timeline-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------------- Handsontable khớp giao diện (chỉ màu/chữ — KHÔNG đổi cột) ---------------- */
.handsontable { font-size: 13px; color: var(--text-2); }
.handsontable th { font-weight: 600; background-color: #f1f5f9 !important; color: var(--text); vertical-align: middle; border-color: var(--border) !important; }
.handsontable td { border-color: var(--border) !important; vertical-align: middle; }
.handsontable td.htDimmed { color: var(--muted); }
.hot-wrap .handsontable thead th { white-space: normal !important; text-align: center !important; line-height: 1.2; padding: 2px 4px; word-break: break-word; }
.ht-theme-main { --ht-font-family: var(--ui-font, "Inter"), ui-sans-serif, system-ui, sans-serif; --ht-font-size: 13px;
  --ht-header-background-color: #f1f5f9; --ht-border-color: #e2e8f0; --ht-accent-color: #1e40af; --ht-foreground-color: #334155;
  --ht-header-foreground-color: #1e293b; }

/* ---------------- login ---------------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--side-bg); }
.login-card { background: #fff; width: 100%; max-width: 380px; margin: 16px; padding: 28px; border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { color: var(--primary); font-size: 24px; letter-spacing: .06em; display: flex; align-items: center; gap: 10px; }
.login-card .input { height: 36px; background: var(--field); }
.login-card .btn { height: 38px; justify-content: center; }

@media (max-width: 760px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; height: 100vh; }
  html.sb-collapsed .sidebar { width: 0; flex-basis: 0; overflow: hidden; }
  .search-box, .search-box input, .w-64 { width: 100%; }
  .content { padding: 12px; }
  .side-panel { display: none; }
  .page-actions { width: 100%; }
}

/* ---------------- Trang chi tiết dạng one-page (theo "hang hoa index.html"): đầu trang + menu neo + các thẻ section ---------------- */
.content.gd-fill { display:flex; flex-direction:column; overflow:hidden; padding:0; background:#f1f5f9 }
.gd-form { display:flex; flex-direction:column; flex:1; min-height:0 }
.gd-head { background:#fff; border-bottom:1px solid var(--border); padding:16px 32px; display:flex; align-items:flex-start; gap:16px; flex-shrink:0; box-shadow:0 1px 2px rgba(15,23,42,.04) }
.gd-head .gd-tags { display:flex; align-items:center; gap:10px; margin-bottom:4px; min-height:20px }
.gd-tag { padding:2px 10px; background:#d1fae5; color:#047857; font-size:12px; font-weight:700; border-radius:4px }
.gd-code { font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:12px; color:#64748b }
.gd-head h1 { font-size:20px; font-weight:700; text-transform:uppercase; color:#0f172a; margin:0 }
.gd-actions { margin-left:auto; display:flex; gap:10px; flex-shrink:0 }
.gd-body { flex:1; min-height:0; display:flex }
.gd-nav { width:224px; flex-shrink:0; background:#fff; border-right:1px solid var(--border); padding:24px 8px 24px 0; overflow-y:auto }
.gd-nav h3 { font-size:11px; font-weight:700; color:#94a3b8; text-transform:uppercase; letter-spacing:.06em; margin:0 0 12px 16px }
.gd-nav a { display:flex; align-items:center; justify-content:space-between; padding:9px 16px; font-size:13px; color:#475569; border-left:3px solid transparent;
  border-radius:0 6px 6px 0; text-decoration:none; transition:background .15s }
.gd-nav a:hover { background:#f1f5f9 }
.gd-nav a.on { background:#eff6ff; color:#1d4ed8; font-weight:600; border-left-color:#2563eb }
.gd-nav .gd-new { background:#dbeafe; color:#2563eb; padding:1px 6px; border-radius:4px; font-size:10px; font-weight:700 }
.gd-scroll { position:relative; flex:1; min-width:0; overflow-y:auto; padding:28px 32px; scroll-behavior:smooth }
.gd-inner { max-width:1100px; margin:0 auto; display:flex; flex-direction:column; gap:24px; padding-bottom:96px }
.gd-sec { background:#fff; border:1px solid var(--border); border-radius:8px; box-shadow:0 1px 2px rgba(15,23,42,.05); padding:20px 24px 24px }
.gd-sec > h2 { font-size:16px; font-weight:700; color:#1d4ed8; margin:0 0 20px; padding-bottom:12px; border-bottom:1px solid #f1f5f9; display:flex; align-items:center; gap:8px }
.gd-sec h4 { margin:4px 0 0; font-size:12px; font-weight:700; color:#334155; grid-column:span 12 }
.gd-grid { display:grid; grid-template-columns:repeat(12, minmax(0, 1fr)); gap:20px 24px }
.gd-f { display:flex; flex-direction:column; min-width:0 }
.gd-f.s2 { grid-column:span 2 } .gd-f.s3 { grid-column:span 3 } .gd-f.s4 { grid-column:span 4 } .gd-f.s5 { grid-column:span 5 }
.gd-f.s6 { grid-column:span 6 } .gd-f.s8 { grid-column:span 8 } .gd-f.s12 { grid-column:span 12 }
.gd-f label.form-label { display:block; font-size:12px; font-weight:600; color:#475569; margin-bottom:6px }
.gd-f .req { color:#ef4444; margin-left:2px }
.form-input { width:100%; padding:8px 12px; background:#f8fafc; border:1px solid #e2e8f0; border-radius:6px; font:inherit; font-size:13px; color:#1e293b; transition:all .2s; box-sizing:border-box }
.form-input:focus { outline:none; background:#fff; border-color:#3b82f6; box-shadow:0 0 0 1px #3b82f6 }
textarea.form-input { min-height:80px; resize:vertical }
.form-input.hl { background:#fefce8; font-weight:700 }
.form-input.strong { font-weight:500 }
.gd-check { display:flex; align-items:center; gap:8px; padding-top:22px; font-weight:500; color:#334155; cursor:pointer }
.gd-check input { width:16px; height:16px }
.gd-box { grid-column:span 12; display:grid; grid-template-columns:repeat(12, minmax(0, 1fr)); gap:16px 24px; padding:16px; border:1px solid #e2e8f0; border-radius:8px; background:#f8fafc }
.gd-box .form-input { background:#fff }
@media (max-width: 900px) { .gd-nav { display:none } .gd-f.s2, .gd-f.s3, .gd-f.s4, .gd-f.s5, .gd-f.s6, .gd-f.s8 { grid-column:span 12 } .gd-head { flex-wrap:wrap; padding:14px 16px } .gd-scroll { padding:16px } }
