/* HTCONS Quản trị — màu theo trang htcons.net */
:root {
    --navy: #134578;
    --blue: #2874bc;
    --accent: #ef8a32;
    --ink: #15364c;
    --muted: #5d7283;
    --line: #dce5ea;
    --paper: #f2f6fc;
    --white: #fff;
    --good: #287043;
    --good-bg: #e8f5ec;
    --warn: #8a5a00;
    --warn-bg: #fff4d6;
    --bad: #a13428;
    --bad-bg: #fde9e6;
    --info-bg: #e4eff9;
    --radius: 10px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 1rem/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
code { font-family: Consolas, monospace; font-size: .82rem; }

/* ---------- Khung trang ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px;
    flex: 0 0 230px;
    background: var(--navy);
    color: #dbe7f2;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand { display: block; background: var(--white); padding: 10px 14px; }
.sidebar .brand img { display: block; width: 100%; height: 48px; object-fit: contain; }
.sidebar nav { padding: 12px 8px; flex: 1; overflow-y: auto; }
.sidebar nav a {
    display: block;
    color: #dbe7f2;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 2px;
}
.sidebar nav a:hover { background: #ffffff14; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #102d43; font-weight: 600; }
.nav-group { font-size: .72rem; letter-spacing: 1.5px; text-transform: uppercase; color: #9fb7cc; padding: 16px 12px 6px; }
/* Nhóm menu thu gọn: bấm tiêu đề nhóm để mở / thu (site.js). */
.sidebar nav .nav-section { margin-bottom: 2px; }
.sidebar nav button.nav-head {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px;
    background: none; border: 0; border-radius: 6px; padding: 10px 12px 7px;
    color: #9fb7cc; font-size: .74rem; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; text-align: left;
    white-space: normal;
}
.sidebar nav button.nav-head:hover { color: var(--white); background: #ffffff0d; filter: none; }
.sidebar nav .active-group > button.nav-head { color: var(--white); }
.nav-head .chev {
    flex: none; width: 7px; height: 7px; margin-right: 3px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(-45deg); transition: transform .15s;
}
.nav-section.open .nav-head .chev { transform: rotate(45deg); }
.nav-items { display: none; padding: 0 0 6px 6px; }
.nav-section.open .nav-items { display: block; }
.sidebar nav .nav-items a { font-size: .92rem; padding: 7px 12px; }
tr.row-selected td { background: var(--info-bg); }
.logo-row { display: flex; align-items: center; gap: 14px; margin: 6px 0 10px; }
.logo-preview { max-width: 220px; max-height: 70px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: var(--white); }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid #ffffff22; font-size: .88rem; }
.sidebar-foot a, .sidebar-foot .link { color: #dbe7f2; display: block; margin-top: 4px; }
.me { font-weight: 600; color: var(--white); }
.me span { display: block; font-weight: 400; font-size: .8rem; color: #9fb7cc; }

.content { flex: 1; min-width: 0; }
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 28px 6px;
    flex-wrap: wrap;
}
.topbar h1 { margin: 0; flex: 1; min-width: 200px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.menu-toggle { display: none; }
.page { padding: 12px 28px 48px; }

/* ---------- Thẻ, lưới ---------- */
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.card.narrow { max-width: 640px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2.wide-left { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); }
.toolbar { margin-bottom: 12px; display: flex; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; color: var(--muted); font-size: .82rem; }
.stat b { display: block; font-size: 1.3rem; margin-top: 4px; }
.stat.warn { border-color: #e8b24d; background: var(--warn-bg); }
a.stat { display: block; color: var(--ink); }
a.stat:hover { text-decoration: none; border-color: var(--blue); }

.kv { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 4px 0 14px; color: var(--muted); font-size: .9rem; }
.kv b { color: var(--ink); margin-left: 4px; }

dl.info { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }
.pre { white-space: pre-wrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.right { margin-left: auto; }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
tfoot td { font-weight: 600; border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
tr.row-warn td { background: var(--warn-bg); }
tr.row-danger td { background: var(--bad-bg); }
table.matrix td.has { background: var(--info-bg); font-weight: 600; }
.changes { display: block; max-width: 560px; white-space: pre-wrap; word-break: break-word; color: var(--muted); }

/* ---------- Nhãn trạng thái ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .78rem; font-weight: 600; background: #eef2f5; color: var(--muted); white-space: nowrap; }
.st-todo { background: #eef2f5; color: #4b5d6b; }
.st-doing { background: var(--info-bg); color: var(--navy); }
.st-review { background: #f1e8fb; color: #5b2f91; }
.st-rework { background: var(--warn-bg); color: var(--warn); }
.st-done { background: var(--good-bg); color: var(--good); }
.pr-urgent { background: var(--bad-bg); color: var(--bad); }
.pr-high { background: var(--warn-bg); color: var(--warn); }
.pr-normal { background: #eef2f5; color: #4b5d6b; }
.load-over { background: var(--bad-bg); color: var(--bad); }
.load-under { background: var(--warn-bg); color: var(--warn); }
.load-ok { background: var(--good-bg); color: var(--good); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.text-danger { color: var(--bad); font-weight: 600; }

.bar { display: inline-block; width: 70px; height: 7px; background: #e6edf2; border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--blue); }

/* ---------- Form ---------- */
label { display: block; font-size: .88rem; font-weight: 600; margin: 0 0 12px; }
input, select, textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid #c7d3dd;
    border-radius: 7px;
    background: var(--white);
    color: var(--ink);
    font: inherit;
    font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #8dbbe3; border-color: var(--blue); }
input[type=checkbox] { display: inline-block; width: auto; margin: 0 6px 0 0; vertical-align: middle; }
input:disabled { background: #f3f6f8; color: var(--muted); }
label.check { display: inline-flex; align-items: center; font-weight: 400; margin-right: 18px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 4px; margin: 0 0 14px; }
legend { font-size: .82rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 200px; margin: 0; }
.filters label.check { margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input { margin: 0; }
.inline-form input.short { width: 80px; }
.status-form select { margin: 6px 0 0; padding: 4px 6px; font-size: .82rem; }
td .status-form select { margin: 0; min-width: 120px; }
.errors ul { margin: 0 0 12px; padding: 10px 14px 10px 30px; background: var(--bad-bg); color: var(--bad); border-radius: 8px; }
.errors ul:empty, .validation-summary-valid { display: none; }
.err { display: block; color: var(--bad); font-size: .8rem; font-weight: 400; margin-top: 2px; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }

.btn, button {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #c7d3dd;
    border-radius: 7px;
    background: var(--white);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover, button:hover { text-decoration: none; filter: brightness(.96); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #102d43; }
.btn.danger { background: var(--white); border-color: #e3a49c; color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: .82rem; }
.btn.wide { width: 100%; margin-top: 8px; }
button.link { background: none; border: 0; padding: 0; font-weight: 400; text-align: left; }

.flash { margin: 0 28px 10px; padding: 10px 14px; border-radius: 8px; background: var(--good-bg); color: var(--good); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.card .flash { margin: 0 0 12px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--navy); border-bottom-color: var(--accent); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: #e9eff4; border-radius: var(--radius); padding: 10px; min-height: 160px; }
.column h3 { margin: 0 0 10px; font-size: .9rem; }
.task-card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.task-card.overdue { border-left: 4px solid var(--bad); }
.task-title { display: block; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.task-card .small { margin-top: 3px; }

/* ---------- Gantt ---------- */
.gantt-head { display: flex; justify-content: space-between; margin-left: 260px; font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.gantt-row { display: flex; align-items: center; border-top: 1px solid var(--line); min-height: 36px; }
.gantt-label { width: 260px; flex: 0 0 260px; padding: 6px 10px 6px 0; overflow: hidden; }
.gantt-label a { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-track { position: relative; flex: 1; height: 22px; background: #f3f6f9; border-radius: 4px; }
.gantt-bar { position: absolute; top: 3px; height: 16px; border-radius: 4px; min-width: 6px; }
.gantt-bar.st-todo { background: #b7c4cf; }
.gantt-bar.st-doing { background: var(--blue); }
.gantt-bar.st-review { background: #8a63c2; }
.gantt-bar.st-rework { background: #e0a43a; }
.gantt-bar.st-done { background: #4c9a68; }
.gantt-bar.overdue { outline: 2px solid var(--bad); }
.gantt-today { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--accent); z-index: 1; }

/* ---------- Bình luận ---------- */
.comments { list-style: none; margin: 0 0 12px; padding: 0; }
.comments li { padding: 10px 0; border-top: 1px solid var(--line); }
.comments li:first-child { border-top: 0; }
.comments + form textarea { margin-bottom: 8px; }

.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* ---------- Trang đăng nhập ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-logo { width: 240px; max-width: 80vw; margin-bottom: 20px; background: var(--white); padding: 8px 14px; border-radius: 8px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 1.4rem; }

/* ---------- Phiếu lương, bản in ---------- */
.payslip tfoot td { font-size: 1.1rem; border-top: 2px solid var(--ink); }
@media print {
    body { background: var(--white); }
    .sidebar, .topbar-actions, .menu-toggle, .flash { display: none !important; }
    .topbar, .page { padding: 0; }
    .card { border: 0; box-shadow: none; max-width: none; }
}

/* ---------- Điện thoại ---------- */
@media (max-width: 860px) {
    .shell { display: block; }
    .sidebar { position: fixed; left: -240px; z-index: 20; transition: left .2s; box-shadow: 4px 0 20px #0003; }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-block; padding: 6px 10px; font-size: 1.1rem; }
    .topbar { padding: 14px 16px 4px; }
    .page { padding: 10px 16px 40px; }
    .flash { margin: 0 16px 10px; }
    .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; }
    dl.info { grid-template-columns: 1fr; }
    dl.info dt { margin-top: 6px; }
    .gantt-head { margin-left: 140px; }
    .gantt-label { width: 140px; flex-basis: 140px; }
    .filters input, .filters select { min-width: 0; width: 100%; }
}

/* Giai đoạn 3: cảnh báo, ô số trong bảng nhập */
.alert-card { border-color: #e3a49c; background: var(--bad-bg); }
.alert-card h2 { color: var(--bad); }
input.num-input { text-align: right; min-width: 110px; }
tr.muted td { color: var(--muted); text-decoration: line-through; }

/* Báo cáo biểu đồ */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; }
.chart-box { position: relative; height: 300px; }
.stat small.trend { display: block; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.stat small.trend-good { color: var(--good); }
.stat small.trend-bad { color: var(--bad); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
@media (max-width: 560px) { .chart-grid { grid-template-columns: 1fr; } .chart-box { height: 240px; } }
