/* ============================================================
   NHATO — giao diện sáng, điểm nhấn vàng gold thương hiệu
   + bảng màu phụ tươi (xanh dương, xanh lá, tím, cam, hồng) cho dữ liệu
   ============================================================ */
:root {
  --bg: #f6f4ef;            /* nền kem rất nhạt, dịu mắt */
  --bg2: #fbfaf7;
  --panel: #ffffff;
  --ink: #1f2430; --muted: #6b7183; --line: #ebe6dc;
  --brand: #b07d33;         /* vàng gold đậm (chữ, viền) */
  --brand-2: #d8ac5e;       /* gold sáng */
  --brand-ink: #7a5420;
  --brand-soft: #fbf1df;
  --grad: linear-gradient(135deg, #c79446 0%, #e2b867 55%, #c8913c 100%);
  --side: #ffffff; --side-ink: #4b5263;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --c-blue: #3b82f6; --c-green: #10b981; --c-violet: #8b5cf6; --c-orange: #f97316; --c-pink: #ec4899; --c-teal: #14b8a6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(80, 60, 20, .05), 0 6px 20px rgba(80, 60, 20, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand-ink); }
.app { display: flex; min-height: 100vh; }
[hidden] { display: none !important; }
img[src*="logo"] { object-fit: contain; flex-shrink: 0; max-width: 100%; }
code { background: var(--brand-soft); color: var(--brand-ink); padding: 0 5px; border-radius: 5px; font-size: 12.5px; }

/* Khởi động / đăng nhập */
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, #fbecd0 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e9f0ff 0%, transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 18px; padding: 28px; box-shadow: 0 24px 60px rgba(80,60,20,.14); display: grid; gap: 12px; border-top: 4px solid var(--brand-2); }
.auth-card h2 { margin: 0; font-size: 19px; }
.auth-card .brand { padding: 0 0 6px; }
.auth-msg { font-size: 13px; padding: 9px 11px; border-radius: 9px; background: var(--brand-soft); }
.auth-msg.err { background: #fee2e2; color: #991b1b; }

/* Sidebar sáng */
.sidebar { width: 244px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; border-right: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 20px 20px 14px; border-bottom: 1px solid var(--line); }
.brand img.logo-word { height: 30px; width: auto; max-width: 100%; object-fit: contain; display: block; flex-shrink: 0; }
.brand small { font-size: 9.5px; color: var(--brand-ink); letter-spacing: .2em; text-transform: uppercase; margin-top: 6px; font-weight: 700; white-space: nowrap; }
nav { flex: 1; overflow-y: auto; padding: 6px 10px 10px; }
nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #a59a86; font-weight: 700; padding: 14px 10px 4px; }
nav a { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 10px; color: var(--side-ink); text-decoration: none; font-weight: 500; position: relative; }
nav a:hover { background: var(--bg2); color: var(--ink); }
nav a.active { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(176,125,51,.3); }
nav a .ic { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; background: var(--ic-bg, #f1ede4); color: var(--ic, var(--brand-ink)); flex-shrink: 0; }
nav a.active .ic { background: rgba(255,255,255,.25); color: #fff; }
nav a .cnt { margin-left: auto; background: var(--bad); color: #fff; border-radius: 99px; font-size: 10.5px; padding: 0 6px; font-weight: 700; }
.side-foot { font-size: 11.5px; padding: 12px 16px; color: var(--muted); border-top: 1px solid var(--line); }
.user-box { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.user-box .av { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.user-box b { color: var(--ink); display: block; font-size: 12.5px; }
.user-box button { margin-left: auto; background: none; border: 1px solid var(--line); color: var(--side-ink); border-radius: 7px; padding: 3px 8px; cursor: pointer; font-size: 11.5px; }
.sync-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 5px; }

/* Thanh trên */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 26px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; letter-spacing: -.01em; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }
.bell { position: relative; border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 38px; height: 36px; cursor: pointer; font-size: 17px; }
.bell .dot { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.content { padding: 22px 26px 60px; }

/* Nút, ô nhập */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 14px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; transition: .15s; }
.btn:hover { border-color: var(--brand-2); background: var(--bg2); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; text-shadow: 0 1px 1px rgba(90,60,10,.35); box-shadow: 0 3px 10px rgba(176,125,51,.28); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.sm { padding: 3px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #e3ddd0; border-radius: 9px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand-2); }
label.f { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
label.f > span { display: block; margin-bottom: 3px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; }

/* Thẻ & lưới */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card h3 { margin: 0 0 12px; font-size: 14.5px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.mt { margin-top: 14px; }
/* KPI nhiều màu: thẻ thứ 1..4 mỗi thẻ một màu */
.kpi { position: relative; overflow: hidden; padding-left: 20px; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--k, var(--brand-2)); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--k, var(--brand-2)); opacity: .08; }
.grid > .kpi:nth-child(4n+1) { --k: var(--c-orange); }
.grid > .kpi:nth-child(4n+2) { --k: var(--c-green); }
.grid > .kpi:nth-child(4n+3) { --k: var(--c-blue); }
.grid > .kpi:nth-child(4n+4) { --k: var(--c-violet); }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .val { font-size: 24px; font-weight: 800; margin-top: 2px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); }

/* Bảng */
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f1ece2; vertical-align: top; }
th { font-size: 11.5px; color: #8a7d66; font-weight: 700; background: #fbf8f2; white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fffaf0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; background: #fbf8f2; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Nhãn trạng thái */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: #f3f0ea; border: 1px solid #e8e2d6; color: #5b5546; white-space: nowrap; }
.b-ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.b-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.b-bad { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.b-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.b-gold { background: var(--brand-soft); color: var(--brand-ink); border-color: #f0dcb5; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Kanban: mỗi cột một màu */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(165px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #fbf8f2; border-radius: var(--radius); padding: 10px; min-height: 200px; border-top: 4px solid var(--col, #d6cdbd); }
.col:nth-child(1) { --col: var(--c-blue); } .col:nth-child(2) { --col: var(--c-violet); } .col:nth-child(3) { --col: var(--c-orange); }
.col:nth-child(4) { --col: #eab308; } .col:nth-child(5) { --col: var(--c-green); } .col:nth-child(6) { --col: #9ca3af; }
.col h4 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; }
.col.drop { outline: 2px dashed var(--brand-2); }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 2px rgba(80,60,20,.05); }
.kcard:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.kcard b { display: block; }

/* Lịch */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.cal .dh { background: #fbf8f2; font-size: 12px; font-weight: 700; color: #8a7d66; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.cal .day { min-height: 106px; border-right: 1px solid #f1ece2; border-bottom: 1px solid #f1ece2; padding: 4px 5px; }
.cal .day:nth-child(7n) { border-right: 0; }
.cal .day.out { background: #fcfbf8; opacity: .6; }
.cal .day.today { background: #fffaf0; box-shadow: inset 0 0 0 2px var(--brand-2); }
.cal .dn { font-size: 12px; font-weight: 700; color: var(--muted); }
.ev { font-size: 11.5px; padding: 2px 6px; border-radius: 6px; margin-top: 3px; color: #fff; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ev.done { opacity: .45; text-decoration: line-through; }
.ev.conflict { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--bad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; margin-bottom: 10px; }

/* Biểu đồ cột */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 10px 4px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .bar { width: 40%; max-width: 26px; border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .lb { font-size: 11px; color: var(--muted); }

/* Hộp thoại */
.modal-bg { position: fixed; inset: 0; background: rgba(40, 32, 18, .35); backdrop-filter: blur(2px); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border-radius: 18px; width: 100%; max-width: 640px; box-shadow: 0 24px 70px rgba(40,32,18,.25); border-top: 4px solid var(--brand-2); }
.modal.wide { max-width: 960px; }
.modal-h { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-h h2 { margin: 0; font-size: 16px; }
.modal-b { padding: 16px 20px; display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.modal-b .full { grid-column: 1 / -1; }
.modal-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: #fcfbf8; border-radius: 0 0 18px 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: flex; gap: 5px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 3px 11px; cursor: pointer; font-size: 12.5px; color: var(--ink); background: #fff; }
.chips label:has(input:checked) { background: var(--brand-soft); border-color: var(--brand-2); color: var(--brand-ink); }
.chips input { width: auto; accent-color: var(--brand); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: #2b2416; color: #fff; padding: 10px 18px; border-radius: 10px; transition: .25s; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.show { transform: translateX(-50%) translateY(0); }

/* AI */
.ai-out { white-space: pre-wrap; background: #fffdf8; border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-height: 260px; font-size: 14px; }
.notes-list { max-height: 180px; overflow-y: auto; font-size: 13px; }
.notes-list div { border-left: 3px solid var(--brand-2); padding: 2px 8px; margin-bottom: 6px; }
.progress { height: 7px; background: #efe9dd; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--c-green), #34d399); border-radius: 99px; }

/* Thông báo */
.noti { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); margin-bottom: 8px; cursor: pointer; }
.noti:hover { border-color: var(--brand-2); }
.noti .ni { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; font-size: 15px; }
.noti.bad .ni { background: #fee2e2; } .noti.warn .ni { background: #fef3c7; } .noti.info .ni { background: #dbeafe; } .noti.ok .ni { background: #dcfce7; }

/* Link sản phẩm & kho tài liệu */
.lchip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; text-decoration: none; color: var(--lc); background: color-mix(in srgb, var(--lc) 10%, #fff); border: 1px solid color-mix(in srgb, var(--lc) 30%, #fff); margin: 0 4px 4px 0; white-space: nowrap; }
.lchip small { font-weight: 500; opacity: .75; }
.lchip:hover { background: color-mix(in srgb, var(--lc) 18%, #fff); }
.lc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lc); display: inline-block; flex-shrink: 0; }
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.libcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border-top: 3px solid var(--lc); display: flex; flex-direction: column; }
.libcard.missing { border-style: dashed; border-top-style: solid; background: #fffdf7; }
.lib-top { display: flex; gap: 10px; align-items: flex-start; }
.lib-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--lc); background: color-mix(in srgb, var(--lc) 12%, #fff); flex-shrink: 0; }
.lib-note { white-space: pre-wrap; font: 12.5px/1.5 Consolas, monospace; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0 0; }
.lib-act { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; flex-wrap: wrap; }
.qa { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 5px 6px 5px 10px; background: #fff; font-size: 13px; font-weight: 600; }
.qa a { color: var(--ink); text-decoration: none; } .qa a:hover { color: var(--lc); }
.qa button { border: 0; background: var(--bg2); border-radius: 6px; cursor: pointer; padding: 1px 6px; color: var(--muted); }
.links-ed .tbl-wrap { box-shadow: none; }

@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) {
  .sidebar { position: fixed; left: -260px; z-index: 40; transition: .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  body.nav-open .sidebar { left: 0; }
  .menu-btn { display: block; }
  .content { padding: 14px 16px 60px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .g4, .g3, .g2, .modal-b { grid-template-columns: 1fr; }
  .cal .day { min-height: 64px; }
  .ev { font-size: 10px; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
