/* ==========================================================================
   v3.11 - Kho tệp/ảnh, Bảng phân công, Kết quả thu chi năm, Kết quả đo quét chỉ số
   ========================================================================== */

/* ---------- Kho tệp / ảnh ---------- */
.lib-container { display: flex; flex-direction: column; gap: 14px; }
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 20px !important; margin: 0 !important; }
.lib-head-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.lib-head-icon { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #0F2D4A, #2563EB); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lib-head-parent { font-size: 11.5px; font-weight: 700; color: #FF8A00; text-transform: uppercase; letter-spacing: .04em; }
.lib-head-title { margin: 2px 0; font-size: 20px; font-weight: 800; color: #0F2D4A; }
.lib-head-hint { font-size: 13px; color: #64748b; }
.lib-btn-add { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; padding: 9px 18px; border-radius: 8px; }
.lib-scope-note { font-size: 13px; color: #0369a1; background: #f0f9ff; border: 1px solid #bae6fd; padding: 8px 12px; border-radius: 8px; }
.lib-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.lib-search { position: relative; flex: 1; min-width: 220px; }
.lib-search input { width: 100%; padding-left: 36px !important; }
.lib-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; display: flex; }
.lib-month { width: 170px !important; }
.lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.lib-empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; color: #94a3b8; background: #fff; border: 1px dashed #cbd5e1; border-radius: 12px; }
.lib-card { padding: 14px 16px !important; margin: 0 !important; display: flex; flex-direction: column; gap: 10px; }
.lib-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.lib-card-titles { min-width: 0; }
.lib-card-title { font-weight: 800; color: #0F2D4A; font-size: 15px; word-break: break-word; }
.lib-card-meta { font-size: 12.5px; color: #64748b; margin-top: 3px; line-height: 1.5; }
.lib-card-meta svg { margin-right: 2px; margin-top: -2px; }
.lib-tag-shared { background: #ecfdf5; color: #047857; border-radius: 10px; padding: 1px 8px; font-weight: 700; font-size: 11px; }
.lib-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.lib-card-note { font-size: 13.5px; color: #334155; background: #f8fafc; border-radius: 8px; padding: 8px 10px; }
.lib-icon-btn { border: 1px solid #e2e8f0; background: #fff; color: #475569; border-radius: 7px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.lib-icon-btn:hover { background: #eff6ff; color: #2563EB; border-color: #bfdbfe; }
.lib-icon-btn.lib-danger:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.lib-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.lib-thumb { position: relative; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background: #f1f5f9; cursor: zoom-in; border: 1px solid #e2e8f0; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-thumb-error::after { content: '⚠'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 22px; }
.lib-thumb-del { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(15, 23, 42, .65); color: #fff; font-size: 11px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.lib-thumb:hover .lib-thumb-del { opacity: 1; }
@media (hover: none) { .lib-thumb-del { opacity: 1; } }
.lib-files { display: flex; flex-direction: column; gap: 6px; }
.lib-file { display: flex; align-items: center; gap: 8px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 6px 8px; background: #fff; }
.lib-file-icon { font-size: 18px; }
.lib-file-name { flex: 1; min-width: 0; text-align: left; background: none; border: none; color: #1d4ed8; font-weight: 600; font-size: 13.5px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0; }
.lib-file-name:hover { text-decoration: underline; }
.lib-file-size { font-size: 12px; color: #94a3b8; white-space: nowrap; }
.lib-legacy { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: #475569; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 9px 12px; }
.lib-legacy-link { background: none; border: none; color: #b45309; font-weight: 700; cursor: pointer; padding: 0; }
.lib-viewer { position: fixed; inset: 0; z-index: 10050; background: rgba(2, 6, 23, .92); align-items: center; justify-content: center; }
.lib-viewer-img { max-width: 92vw; max-height: 84vh; object-fit: contain; border-radius: 6px; }
.lib-viewer-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; color: #e2e8f0; font-size: 13.5px; gap: 10px; }
.lib-viewer-bar span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-viewer-bar button { background: rgba(255, 255, 255, .12); color: #fff; border: none; border-radius: 6px; padding: 6px 10px; margin-left: 6px; cursor: pointer; }
.lib-viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .14); color: #fff; border: none; font-size: 34px; width: 46px; height: 64px; border-radius: 8px; cursor: pointer; }
.lib-prev { left: 12px; } .lib-next { right: 12px; }
.lib-drop { border: 2px dashed #93c5fd; background: #f8fbff; border-radius: 12px; padding: 22px 14px; text-align: center; cursor: pointer; color: #1e3a8a; }
.lib-drop.is-over { background: #dbeafe; border-color: #2563EB; }
.lib-drop-sub { font-size: 12.5px; color: #64748b; margin-top: 4px; }
.lib-pending { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.lib-pending-item { display: flex; align-items: center; gap: 8px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 5px 8px; font-size: 13px; }
.lib-pending-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-form-grid { display: grid; grid-template-columns: 1fr 170px; gap: 12px; }
.lib-label { display: block; font-weight: 700; font-size: 13px; color: #334155; margin: 10px 0 5px; }
.lib-optional { font-weight: 400; color: #94a3b8; }
.lib-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
@media (max-width: 640px) {
    .lib-list { grid-template-columns: 1fr; }
    .lib-form-grid { grid-template-columns: 1fr; gap: 0; }
    .lib-month { width: 100% !important; }
    .lib-head-title { font-size: 17px; }
}

/* ---------- Tab chuyển trang con (Phân công, Tài chính) ---------- */
.fc-subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.fc-subtab { border: 1.5px solid #cbd5e1; background: #fff; color: #475569; border-radius: 999px; padding: 7px 16px; font-weight: 700; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.fc-subtab.active { background: #0F2D4A; border-color: #0F2D4A; color: #fff; }

/* ---------- Bảng dùng chung ---------- */
.fc-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; }
.fc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.fc-table th { background: #0F2D4A; color: #fff; font-weight: 700; padding: 10px 10px; text-align: center; white-space: nowrap; border-right: 1px solid rgba(255, 255, 255, .12); }
.fc-table td { padding: 10px 10px; border-top: 1px solid #e2e8f0; border-right: 1px solid #f1f5f9; vertical-align: middle; color: #334155; }
.fc-table tr:hover td { background: #f8fafc; }
.fc-table .c { text-align: center; }
.fc-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.fc-table tfoot td { font-weight: 800; background: #f1f5f9; color: #0F2D4A; }
.fc-empty { text-align: center; color: #94a3b8; padding: 30px 10px !important; font-style: italic; }
.fc-pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.fc-pill-blue { background: #dbeafe; color: #1d4ed8; }
.fc-pill-orange { background: #ffedd5; color: #c2410c; }
.fc-pill-green { background: #dcfce7; color: #15803d; }
.fc-pill-gray { background: #f1f5f9; color: #64748b; }
.fc-pill-red { background: #fee2e2; color: #b91c1c; }

/* ---------- Bảng phân công nhiệm vụ ---------- */
.asg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.asg-title { font-size: 19px; font-weight: 800; color: #0F2D4A; margin: 0; }
.asg-sub { font-size: 13px; color: #64748b; }
.asg-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.asg-filters .form-control { width: auto; min-width: 160px; }
.asg-task-title { font-weight: 700; color: #0F2D4A; }
.asg-task-desc { font-size: 12.5px; color: #64748b; margin-top: 3px; white-space: pre-line; }
.asg-time { white-space: nowrap; font-size: 13px; }
.asg-people { display: flex; flex-direction: column; gap: 5px; }
.asg-person { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.asg-person-name { font-weight: 600; color: #1e293b; }
.asg-role { font-size: 11px; color: #94a3b8; }
.asg-zalo { display: inline-flex; align-items: center; gap: 4px; background: #0068ff; color: #fff !important; border-radius: 6px; padding: 3px 9px; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.asg-zalo:hover { background: #0052cc; }
.asg-zalo-z { background: #fff; color: #0068ff; border-radius: 3px; width: 14px; height: 14px; font-size: 10px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; }
.asg-nophone { font-size: 11.5px; color: #b45309; background: #fffbeb; border-radius: 6px; padding: 2px 7px; }
.asg-row { cursor: pointer; }

/* ---------- Kết quả thu chi năm ---------- */
.fy-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.fy-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fy-controls .form-control { width: auto; }
.fy-source { font-size: 11px; font-weight: 600; }
.fy-auto { color: #0369a1; }
.fy-manual { color: #15803d; }
.fy-neg { color: #dc2626; }
.fy-help { font-size: 12.5px; color: #64748b; margin-top: 10px; line-height: 1.6; }
.fy-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.fy-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 14px; }
.fy-card-label { font-size: 12px; font-weight: 700; color: #64748b; text-transform: uppercase; }
.fy-card-value { font-size: 20px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
    .fy-cards { grid-template-columns: 1fr; }
    .asg-filters .form-control { min-width: 0; flex: 1; }
}

/* ---------- Kết quả đo quét chỉ số (hội viên) ---------- */
.scan-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.scan-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.scan-title { font-size: 16px; font-weight: 800; color: #0F2D4A; display: flex; align-items: center; gap: 8px; }
.scan-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.scan-table th .scan-date { display: block; font-weight: 500; font-size: 11px; opacity: .8; }
.scan-table td.scan-metric { font-weight: 700; color: #0F2D4A; white-space: nowrap; text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.scan-table th.scan-metric { position: sticky; left: 0; z-index: 2; text-align: left; }
.scan-table td.scan-val { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.scan-unit { font-size: 11px; color: #94a3b8; font-weight: 500; }
.scan-up { color: #dc2626; font-weight: 700; font-size: 11.5px; }
.scan-down { color: #059669; font-weight: 700; font-size: 11.5px; }
.scan-diff { text-align: center; white-space: nowrap; background: #f8fafc; }
.scan-note { font-size: 12px; color: #64748b; margin-top: 8px; }
.hm-goal-dvh { background: #ede9fe; color: #6d28d9; }
.hm-goal-tl { background: #dcfce7; color: #15803d; }
.hm-btn-metrics { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px !important; font-size: 12.5px !important; white-space: nowrap; }
.lib-container .fc-subtabs { margin-bottom: 0; }
@media (max-width: 640px) {
    .scan-wrap { padding: 12px 10px; }
    .scan-table td.scan-metric, .scan-table th.scan-metric { white-space: normal; min-width: 96px; max-width: 110px; font-size: 12.5px; }
    .scan-table td, .scan-table th { padding: 8px 7px; font-size: 12.5px; }
    .scan-table td.scan-metric .scan-unit { display: block; }
}

/* Nút gửi Zalo qua bot trong bảng phân công */
button.asg-zalo { border: none; cursor: pointer; font-family: inherit; }
button.asg-zalo:disabled { opacity: .6; cursor: wait; }
.asg-zalo-manual { background: #e0ecff; color: #0052cc !important; }
.asg-zalo-manual .asg-zalo-z { background: #0068ff; color: #fff; }
.asg-zalo-all { margin-top: 6px; align-self: flex-start; border: 1.5px solid #0068ff; background: #fff; color: #0068ff; border-radius: 6px; padding: 3px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.asg-zalo-all:hover { background: #eff6ff; }
