/* ============ APP TỒN KHO THẺ BÀI — giao diện ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6fa; --panel: #ffffff; --line: #e3e8f0;
  --text: #1c2333; --muted: #68738a;
  --primary: #2563eb; --primary-dark: #1d4ed8;
  --green: #16a34a; --red: #dc2626; --amber: #d97706;
  --radius: 10px; --shadow: 0 1px 3px rgba(16,24,40,.08);
}
body {
  font-family: "Times New Roman", Times, serif;
  background: var(--bg); color: var(--text); font-size: 16px;
}
input, select, button, textarea { font-family: "Times New Roman", Times, serif; }

/* Đề mục: chữ đầu viết hoa, in đậm */
h1, h2, h3, h4, th, .card-label, .tab, .modal label, .login-box label {
  text-transform: capitalize;
}
th { font-weight: 700; }
.card-label { font-weight: 700; }
h2, h3, h4 { font-weight: 700; }

/* ---------- Thanh trên ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 20px; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.brand { font-size: 20px; font-weight: 700; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  border: none; background: transparent; padding: 9px 16px; font-size: 15px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600;
}
.tab:hover { background: #eef2f9; color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Thẻ tổng quan ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.card-value { font-size: 22px; font-weight: 700; }
.card-warn .card-value { color: var(--amber); }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--amber); }

/* ---------- Thanh công cụ ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { font-size: 18px; flex: 1; }
#search {
  flex: 1; min-width: 240px; padding: 10px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
#search:focus { outline: 2px solid var(--primary); border-color: transparent; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; white-space: nowrap; }

/* ---------- Nút ---------- */
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 9px 16px; font-size: 14px; font-weight: 600; border-radius: 8px; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #eef2f9; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-green { color: var(--green); }
.btn-red { color: var(--red); }

/* ---------- Bảng ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 10px 12px; text-align: left; border: 1px solid var(--line); white-space: nowrap; }
td.wrap { white-space: normal; }
th { background: #eef2f9; color: var(--text); font-size: 15px; font-weight: 700; position: sticky; top: 0; }
tbody tr:hover { background: #f8fafc; }
.num { text-align: right; }
.actions-col { text-align: right; }
td.actions-col { display: flex; gap: 6px; justify-content: flex-end; }
tr { height: 46px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Nhãn trạng thái ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-low { background: #fef3c7; color: #92400e; }
.badge-out { background: #fee2e2; color: #991b1b; }
.badge-nhap { background: #dcfce7; color: #166534; }
.badge-xuat { background: #dbeafe; color: #1e40af; }
.badge-dc { background: #f3e8ff; color: #6b21a8; }

.money { font-variant-numeric: tabular-nums; }
.profit-pos { color: var(--green); font-weight: 600; }
.profit-neg { color: var(--red); font-weight: 600; }

/* ---------- Báo cáo ---------- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
@media (max-width: 900px) { .report-grid { grid-template-columns: 1fr; } }
.report-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); overflow-x: auto;
}
.report-box h3 { margin-bottom: 12px; font-size: 16px; }
.report-box h4 { margin: 14px 0 6px; font-size: 14px; }
.report-box p, .report-box ol { margin-bottom: 10px; color: var(--text); }
.report-box ol { padding-left: 22px; }
.report-box li { margin-bottom: 4px; }
.report-box select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.backup-list { list-style: none; max-height: 180px; overflow-y: auto; font-size: 13.5px; color: var(--muted); }
.backup-list li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
code { background: #eef2f9; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.hint { color: var(--muted); font-size: 13.5px; margin-top: 10px; white-space: pre-line; }

/* ---------- Modal (hộp thoại) ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 14px; padding: 24px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 50px rgba(15,23,42,.3);
}
.modal h2 { margin-bottom: 16px; font-size: 19px; }
.modal label { display: block; font-size: 13.5px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.modal input {
  display: block; width: 100%; margin-top: 4px; padding: 9px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.modal input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.req { color: var(--red); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.tx-product {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}

/* ---------- Màn hình đăng nhập ---------- */
.login-bg {
  position: fixed; inset: 0; z-index: 300;
  background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #3b82f6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  background: var(--panel); border-radius: 18px; padding: 34px 30px;
  width: 100%; max-width: 400px; box-shadow: 0 25px 60px rgba(0,0,0,.35); text-align: center;
}
.login-logo { font-size: 52px; margin-bottom: 6px; }
.login-box h1 { font-size: 22px; margin-bottom: 18px; }
.login-note { color: var(--muted); font-size: 14px; margin-bottom: 16px; line-height: 1.5; }
.login-box form { text-align: left; }
.login-box label { display: block; font-size: 13.5px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.login-box input {
  display: block; width: 100%; margin-top: 4px; padding: 11px 13px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.login-box input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.login-err { color: var(--red); font-size: 13.5px; min-height: 20px; margin-bottom: 8px; font-weight: 600; }
.btn-full { width: 100%; padding: 12px; font-size: 15px; }

/* ---------- Người dùng trên thanh đầu ---------- */
.user-chip { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-chip span { font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* ---------- Ô chọn trong modal ---------- */
.modal select {
  display: block; width: 100%; margin-top: 4px; padding: 9px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--panel);
}

/* ---------- Thông báo nổi ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1c2333; color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 14.5px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.err { background: var(--red); }
