/* ============================================
   DANHMUC BVTV - Main Stylesheet
   ============================================ */

:root {
    --primary:   #1a7f37;
    --primary-d: #155f2a;
    --accent:    #2ea44f;
    --success:   #28a745;
    --warning:   #f0a020;
    --danger:    #dc3545;
    --info:      #17a2b8;
    --bg:        #f6f8fa;
    --surface:   #ffffff;
    --border:    #d0d7de;
    --text:      #1f2328;
    --text-mute: #57606a;
    --shadow:    0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.12);
    --radius:    8px;
    --radius-sm: 4px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary-d); }
img { max-width: 100%; }

/* --- Container --- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ============================================
   HEADER
   ============================================ */
.site-header {
    background: var(--primary);
    color: #fff;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-md);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 60px;
    flex-wrap: wrap;
}
.site-logo {
    display: flex; align-items: center; gap: 8px;
    font-size: 1.15rem; font-weight: 700; color: #fff !important;
    text-decoration: none !important; white-space: nowrap;
}
.site-logo span { letter-spacing: 0.3px; }

.main-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.main-nav a {
    color: rgba(255,255,255,0.9);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background .15s;
    text-decoration: none;
}
.main-nav a:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Dropdown */
.nav-dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%; left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 260px;
    z-index: 200;
    padding: 6px 0;
}
.dropdown-menu a {
    display: block;
    padding: 8px 16px;
    color: var(--text) !important;
    font-size: 0.875rem;
}
.dropdown-menu a:hover { background: var(--bg); }
.nav-dropdown:hover .dropdown-menu { display: block; }

/* Burger button — ẩn trên desktop */
.nav-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-left: auto;
    padding: 8px;
    flex-shrink: 0;
}
.nav-burger span {
    display: block;
    width: 22px; height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .25s, opacity .2s;
}
/* Trạng thái "open" → thành dấu X */
.nav-burger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-burger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* --- Breadcrumb bar --- */
.breadcrumb-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    font-size: 0.825rem;
    color: var(--text-mute);
}
.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 6px; color: var(--text-mute); }
.breadcrumb .bc-sep { margin: 0 6px; color: var(--text-mute); }
.breadcrumb .bc-current { color: var(--text-main, #1a202c); font-weight: 500; }

/* --- Main --- */
.site-main { padding: 28px 0 48px; min-height: calc(100vh - 200px); }

/* ============================================
   HERO
   ============================================ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #0e5c25 100%);
    color: #fff;
    padding: 20px 0;
    margin: -28px -20px 32px;
    text-align: center;
}
.hero-content { max-width: 600px; margin: 0 auto; padding: 0 20px; }
.hero h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 12px; }
.hero p { font-size: 1.05rem; opacity: 0.88; }

/* ============================================
   STATS BAR
   ============================================ */
.stats-bar {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 32px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.stat-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center;
    padding: 20px;
    border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.stat-label { font-size: 0.825rem; color: var(--text-mute); margin-top: 4px; }

/* ============================================
   SECTION
   ============================================ */
.section { margin-bottom: 40px; }
.section-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}
.section-header-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}
.section-header-row .section-title {
    margin-bottom: 0;
}
.section-count {
    font-size: 0.82rem;
    color: var(--text-mute);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    white-space: nowrap;
}

/* ============================================
   CATEGORY GRID
   ============================================ */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
    gap: 16px;
}
.category-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    text-decoration: none;
    transition: all .2s;
    display: block;
}
.category-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
}
.cat-icon { font-size: 2.2rem; margin-bottom: 8px; }
.cat-name { font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cat-count { font-size: 0.775rem; color: var(--text-mute); }

/* ============================================
   CHART
   ============================================ */
.stats-chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.chart-row:last-child { margin-bottom: 0; }
.chart-label { width: 220px; font-size: 0.85rem; text-align: right; flex-shrink: 0; }
.chart-bar-wrap { flex: 1; background: var(--bg); border-radius: 4px; height: 20px; overflow: hidden; }
.chart-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 4px; transition: width .5s; }
.chart-value { width: 60px; font-size: 0.85rem; font-weight: 600; color: var(--primary); text-align: right; }

/* ============================================
   CTA
   ============================================ */
.cta-section { text-align: center; }
.cta-box {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    display: inline-block;
}
.cta-box h3 { font-size: 1.3rem; margin-bottom: 10px; }
.cta-box p { color: var(--text-mute); margin-bottom: 20px; }

/* ============================================
   CONTENT LAYOUT (list page)
   ============================================ */
.content-layout { display: flex; gap: 24px; align-items: flex-start; }
.sidebar { width: 240px; flex-shrink: 0; position: sticky; top: 80px; }
.main-content { flex: 1; min-width: 0; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.total-badge {
    background: var(--primary);
    color: #fff;
    padding: 3px 12px;
    border-radius: 50px;
    font-size: 0.825rem;
    font-weight: 600;
}

/* FILTER SIDEBAR */
.filter-block { margin-bottom: 16px; }
.filter-block:last-child { margin-bottom: 0; }
.filter-title {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 8px;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); }

.quick-link {
    display: block;
    padding: 6px 8px;
    font-size: 0.825rem;
    color: var(--primary);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}
.quick-link:hover, .quick-link.active {
    background: rgba(26,127,55,0.08);
    text-decoration: none;
}

/* ============================================
   DATA TABLE
   ============================================ */
.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.875rem;
}
.data-table thead tr { background: var(--bg); }
.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-mute);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f9fffe; }
.data-table tbody tr:last-child td { border-bottom: none; }

.col-num { width: 50px; color: var(--text-mute); font-size: 0.8rem; }
.col-name { min-width: 200px; }
.col-congty { min-width: 180px; }

.thuoc-name {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.925rem;
}
.thuoc-name:hover { text-decoration: underline; }
.thuoc-hoatchat { margin-top: 3px; }
.congty-link { color: var(--text); font-size: 0.825rem; }
.congty-link:hover { color: var(--primary); }

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-group    { background: #dafbe1; color: #1a7f37; }
.badge-sector   { background: #ddf4ff; color: #0969da; }
.badge-status   { background: #fff8c5; color: #9a6700; }
.badge-success  { background: #dafbe1; color: #1a7f37; }
.badge-danger   { background: #ffebe9; color: #cf222e; }
.badge-warning  { background: #fff8c5; color: #9a6700; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin: 28px 0 10px;
}
.page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    text-decoration: none;
    transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.page-ellipsis { display: flex; align-items: center; padding: 0 4px; color: var(--text-mute); }
.pagination-info { margin-top: 8px; font-size: 0.825rem; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; }
.empty-state p { color: var(--text-mute); margin-bottom: 20px; }

/* ============================================
   DETAIL PAGE
   ============================================ */
.detail-page { flex: 1; min-width: 0; }
.detail-layout { width: 100%; }
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}
.detail-header {
    background: linear-gradient(135deg, var(--primary), #0e5c25);
    padding: 24px 28px;
    color: #fff;
}
.detail-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 12px; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-badges .badge {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}
.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
}
.info-item {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
}
.info-item:nth-child(even) { border-right: none; }
.info-item.info-full {
    grid-column: 1 / -1;
    border-right: none;
}
.info-item label {
    display: block;
    font-size: 0.775rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-mute);
    margin-bottom: 6px;
}
.info-item div { font-size: 0.9rem; line-height: 1.6; }
.highlight-value {
    font-size: 1.05rem !important;
    font-weight: 600;
    color: var(--danger);
}
.usage-text { background: var(--bg); padding: 12px; border-radius: var(--radius-sm); }
.detail-source { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg); }

/* =============================================
   TÓM TẮT SỬ DỤNG - Summary Box
   ============================================= */
.summary-usage-box {
    margin: 0;
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    background: #f8fdf9;
}
.summary-usage-desc {
    margin: 0;
    font-size: .95rem;
    color: var(--text);
    line-height: 1.75;
}
@media (max-width: 640px) {
    .summary-usage-box { padding: 14px 16px; }
}

/* =============================================
   PHẠM VI SỬ DỤNG - JSON Grid
   ============================================= */
.pham-vi-section {
    margin-top: 0;
    border-top: 1px solid var(--border);
    padding: 24px;
}
.pham-vi-heading {
    margin-bottom: 16px;
}
.pham-vi-heading h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.pham-vi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.pham-vi-card {
    border: 1px solid #d0e8ff;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fff;
}
.pham-vi-targets {
    display: flex;
    background: #f0f8ff;
    border-bottom: 1px solid #d0e8ff;
}
.pv-target {
    flex: 1;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pv-target + .pv-target {
    border-left: 1px solid #d0e8ff;
}
.pv-icon { font-size: 1.1rem; }
.pv-label {
    font-size: 0.7rem;
    color: #6b9cc3;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 500;
}
.pv-target strong {
    font-size: 0.9rem;
    color: #1a4a7a;
    font-weight: 600;
}
.pham-vi-details {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.pv-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.85rem;
    line-height: 1.5;
}
.pv-detail-label {
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}
.pv-detail-val { color: var(--text); }
.pv-cacly {
    font-weight: 600;
    color: #d64f00;
}
.pv-cachdung-row {
    border-top: 1px dashed var(--border);
    padding-top: 5px;
    margin-top: 3px;
}
.pv-cachdung-row .pv-detail-val {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* Related */
.related-section { margin-top: 28px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.related-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-decoration: none;
    transition: all .2s;
}
.related-card:hover {
    border-color: var(--primary);
    text-decoration: none;
    box-shadow: var(--shadow);
}
.related-name { font-weight: 600; font-size: 0.875rem; color: var(--primary); margin-bottom: 4px; }
.related-group { font-size: 0.775rem; color: var(--text-mute); }

/* ============================================
   CRAWLER PAGE
   ============================================ */
.crawler-page { padding-bottom: 20px; }
.page-desc { color: var(--text-mute); margin-top: 6px; margin-bottom: 24px; }

.progress-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.progress-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.prog-title { font-size: 0.825rem; font-weight: 600; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 10px; }
.prog-numbers { display: flex; align-items: baseline; gap: 4px; margin-bottom: 12px; }
.prog-current { font-size: 2rem; font-weight: 700; color: var(--primary); }
.prog-sep { font-size: 1.2rem; color: var(--text-mute); }
.prog-total { font-size: 1.2rem; color: var(--text-mute); }
.prog-bar-wrap { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.prog-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 4px; transition: width .5s; }
.bar-green { background: linear-gradient(90deg, #40b060, #28a745); }
.prog-pct { font-size: 0.875rem; font-weight: 600; color: var(--primary); }

.crawler-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 28px; }
.control-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 8px;
}
.ctrl-icon { font-size: 2.5rem; }
.control-card h3 { font-size: 1rem; font-weight: 700; }
.control-card p { font-size: 0.875rem; color: var(--text-mute); flex: 1; }
.ctrl-tips { font-size: 0.8rem; color: var(--text-mute); padding-left: 16px; flex: 1; }
.ctrl-tips li { margin-bottom: 3px; }

.log-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 28px;
}
.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.log-header h3 { font-size: 1rem; font-weight: 700; }
.live-log {
    background: #0d1117;
    border-radius: var(--radius-sm);
    padding: 16px;
    min-height: 120px;
    max-height: 320px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
}
.log-hint { color: #555; font-style: italic; }
.log-entry { margin-bottom: 6px; line-height: 1.5; }
.log-entry.success { color: #3fb950; }
.log-entry.error   { color: #f85149; }
.log-entry.info    { color: #79c0ff; }
.log-entry.warning { color: #e3b341; }
.log-time { color: #6e7681; font-size: 0.8rem; }

.history-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
    font-family: inherit;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-danger  { background: var(--danger);  border-color: var(--danger);  color: #fff; }
.btn-info    { background: var(--info);    border-color: var(--info);    color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm  { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 12px 28px; font-size: 1rem; }
.btn-full{ width: 100%; }

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    background: #1a2028;
    color: rgba(255,255,255,0.75);
    padding: 36px 0 24px;
    margin-top: 48px;
}
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.footer-col h4 { color: #fff; font-size: 0.95rem; margin-bottom: 12px; }
.footer-col p  { font-size: 0.825rem; line-height: 1.7; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 6px; }
.footer-col a { color: rgba(255,255,255,0.65); font-size: 0.825rem; }
.footer-col a:hover { color: #fff; }

/* ============================================
   ERROR PAGE
   ============================================ */
.error-page { max-width: 560px; margin: 60px auto; text-align: center; padding: 0 20px; }
.error-code { font-size: 7rem; font-weight: 900; color: var(--primary); line-height: 1; margin-bottom: 10px; }
.error-page h2 { font-size: 1.6rem; color: var(--text); margin: 12px 0 10px; }
.error-page p { color: var(--text-mute); margin-bottom: 16px; }
.error-hint {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: .95rem;
    color: var(--text);
    margin-bottom: 20px !important;
}
.error-search-form { margin: 20px 0; }
.error-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 4px 16px rgba(26,127,55,.12);
    transition: box-shadow .2s;
}
.error-search-bar:focus-within { box-shadow: 0 6px 24px rgba(26,127,55,.22); }
.error-search-bar .search-icon { font-size: 1.1rem; flex-shrink: 0; }
.error-search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    background: transparent;
    color: var(--text);
    min-width: 0;
}
.error-search-bar .btn { flex-shrink: 0; padding: 7px 18px; font-size: .9rem; border-radius: 8px; }
.error-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.error-actions .btn { padding: 9px 20px; font-size: .95rem; }

/* ============================================
   UTILITIES
   ============================================ */
.text-muted  { color: var(--text-mute) !important; }
.text-center { text-align: center; }
.small       { font-size: 0.8rem; }
.mt-8  { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .crawler-controls { grid-template-columns: 1fr; }
    .progress-cards   { grid-template-columns: 1fr 1fr; }
    .footer-inner     { grid-template-columns: 1fr 1fr; }
    .detail-info-grid { grid-template-columns: 1fr; }
    .info-item { border-right: none; }
}
@media (max-width: 768px) {
    .content-layout { flex-direction: column; }
    .sidebar { width: 100%; position: static; }

    /* Header: logo trái, burger phải */
    .header-inner { height: 56px; padding: 0; flex-wrap: nowrap; }
    .nav-burger { display: flex; }

    /* Nav ẩn mặc định, mở ra khi có class .is-open */
    .main-nav {
        display: none;
        position: absolute;
        top: 56px; left: 0; right: 0;
        background: var(--primary-d);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin-left: 0;
        z-index: 150;
        padding: 8px 0;
        box-shadow: 0 4px 12px rgba(0,0,0,.2);
    }
    .main-nav.is-open { display: flex; }
    .main-nav > a,
    .main-nav .nav-dropdown > a {
        padding: 12px 20px;
        border-radius: 0;
        font-size: 1rem;
        border-bottom: 1px solid rgba(255,255,255,.08);
    }

    /* Dropdown trong mobile: mở bằng click, hiển thị inline */
    .nav-dropdown { position: static; }
    .dropdown-menu {
        position: static;
        display: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: rgba(0,0,0,.15);
        padding: 0;
        min-width: unset;
    }
    .dropdown-menu a {
        padding: 10px 20px 10px 36px;
        color: rgba(255,255,255,.85) !important;
        font-size: 0.9rem;
        border-bottom: 1px solid rgba(255,255,255,.06);
    }
    .dropdown-menu a:hover { background: rgba(255,255,255,.1); }
    /* Hover desktop không còn hiệu lực trên mobile */
    .nav-dropdown:hover .dropdown-menu { display: none; }
    .nav-dropdown.is-open .dropdown-menu { display: block; }

    .hero h1 { font-size: 1.5rem; }
    .progress-cards { grid-template-columns: 1fr; }
    .stats-bar { flex-direction: column; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-inner { grid-template-columns: 1fr; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 8px 10px; }
}

/* ============================================
   Nhóm Độc Badge
   ============================================ */
.nhom-doc-wrap {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 4px;
}


.nhom-doc-so {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    font-weight: 700;
    font-size: 0.9rem;
}

/* ============================================
   STAT ITEM LINK (trang chủ click được)
   ============================================ */
a.stat-item-link {
    text-decoration: none;
    color: inherit;
    transition: background .18s, transform .15s;
    cursor: pointer;
    border-radius: 0;
}
a.stat-item-link:hover {
    text-decoration: none;
}

/* ============================================
   TRANG DANH SÁCH CÔNG TY
   ============================================ */
.content-layout-full {
    max-width: 1200px;
    margin: 0 auto;
}

/* Thanh tìm kiếm inline */
.filter-bar-top {
    margin-bottom: 24px;
}
.search-form-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.search-form-inline .form-control {
    flex: 1;
    min-width: 220px;
    max-width: 400px;
}
.search-result-note {
    margin-top: 8px;
    font-size: .9rem;
    color: var(--text-mute);
}

/* Lưới công ty */
.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.company-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow .18s, transform .15s, border-color .18s;
    gap: 8px;
}
.company-card:hover {
    box-shadow: 0 4px 18px rgba(0,0,0,.1);
    transform: translateY(-3px);
    border-color: var(--primary);
}
.company-icon {
    font-size: 2rem;
    line-height: 1;
}
.company-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    word-break: break-word;
}
.company-count {
    font-size: .78rem;
    color: var(--primary);
    font-weight: 500;
    background: rgba(45,125,70,.08);
    padding: 2px 10px;
    border-radius: 20px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-mute);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); }

@media (max-width: 600px) {
    .company-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    .search-form-inline .form-control { max-width: 100%; }
}

/* ============================================
   THANH TÌM KIẾM NỔI BẬT (trên bảng danh sách)
   ============================================ */
.inline-search-bar {
    margin-bottom: 16px;
}
.search-fallback-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fffbeb;
    border: 1px solid #fbd38d;
    border-left: 4px solid #f6ad55;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: .9rem;
    color: #744210;
    line-height: 1.5;
}
.search-fallback-notice .sfn-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }
.inline-search-form {
    width: 100%;
}
.inline-search-inner {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(26,127,55,.15);
    transition: box-shadow .2s;
}
.inline-search-inner:focus-within {
    box-shadow: 0 3px 14px rgba(26,127,55,.28);
    border-color: var(--primary-d);
}
.inline-search-icon {
    padding: 0 12px 0 14px;
    font-size: 1.1rem;
    color: var(--primary);
    flex-shrink: 0;
    line-height: 1;
}
.inline-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 11px 18px;
    font-size: 1.1rem;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    min-width: 0;
}
.inline-search-input::placeholder {
    color: var(--text-mute);
}
.inline-search-btn {
    flex-shrink: 0;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0 22px;
    height: 46px;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s;
    font-family: inherit;
    white-space: nowrap;
}
.inline-search-btn:hover {
    background: var(--primary-d);
}
@media (max-width: 600px) {
    .inline-search-btn {
        padding: 0 14px;
        font-size: .85rem;
    }
}

/* =====================================================
   RESPONSIVE TABLE — Card layout trên mobile
   ===================================================== */
@media (max-width: 640px) {
    /* Ẩn header bảng */
    .data-table thead {
        display: none;
    }

    /* Xoá overflow-x để card không bị cắt */
    .table-wrapper {
        overflow-x: visible;
    }

    /* Mỗi hàng thành 1 card */
    .data-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 12px;
        background: var(--surface);
        box-shadow: 0 1px 4px rgba(0,0,0,.06);
        overflow: hidden;
    }
    .data-table tbody tr:hover {
        background: #f0fdf4;
    }

    /* Mỗi ô thành 1 hàng label – value */
    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        padding: 9px 14px;
        border-bottom: 1px solid #f0f0f0;
        min-width: unset;
        width: 100%;
        box-sizing: border-box;
        text-align: right;
        font-size: 0.875rem;
    }
    .data-table tbody tr td:last-child {
        border-bottom: none;
    }

    /* Label tự động từ data-label */
    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        color: var(--text-mute);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        white-space: nowrap;
        flex-shrink: 0;
        text-align: left;
        padding-top: 2px;
    }

    /* Ẩn cột số thứ tự — không cần trên mobile */
    .data-table .col-num {
        display: none;
    }

    /* Bỏ min-width cứng */
    .data-table .col-name,
    .data-table .col-congty {
        min-width: unset;
        width: 100%;
    }

    /* Phân nhóm badge căn phải */
    .data-table .col-nhom {
        justify-content: space-between;
    }

    /* Cột số sản phẩm trong cong-ty-list — căn đều */
    .data-table .col-sp {
        text-align: right;
    }

    /* Inline search bar — stack dọc trên mobile nhỏ */
    .inline-search-inner {
        flex-direction: column;
        gap: 8px;
    }
    .inline-search-btn {
        width: 100%;
        justify-content: center;
        border-radius: var(--radius-sm);
    }
    .inline-search-input {
        border-radius: var(--radius-sm);
    }
}

/* ============================================
   MODULE: QUY TRÌNH CANH TÁC
   ============================================ */

/* Hero */
.qt-hero {
    background: linear-gradient(135deg, #0e5c25 0%, #1a7f37 60%, #2ea44f 100%);
    color: #fff;
    padding: 36px 0 28px;
    margin: -28px -20px 32px;
    text-align: center;
}
.qt-hero h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 10px; }
.qt-hero p  { font-size: 1rem; opacity: .88; margin-bottom: 22px; }
.qt-search-form { max-width: 580px; margin: 0 auto; padding: 0 20px; }
.qt-search-form .inline-search-inner { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.5); }
.qt-search-form .inline-search-input { color: #fff; }
.qt-search-form .inline-search-input::placeholder { color: rgba(255,255,255,.7); }
.qt-search-form .inline-search-icon { color: rgba(255,255,255,.8); }

/* Grid nhóm */
.qt-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
}
.qt-group-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 16px 20px;
    text-align: center;
    text-decoration: none;
    transition: all .2s;
    display: block;
}
.qt-group-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    text-decoration: none;
}
.qt-group-icon  { font-size: 2.6rem; margin-bottom: 10px; line-height: 1; }
.qt-group-name  { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: 6px; line-height: 1.4; }
.qt-group-count { font-size: .78rem; color: var(--primary); font-weight: 500;
                  background: rgba(26,127,55,.08); padding: 2px 10px; border-radius: 20px; display: inline-block; }

/* Viewer */
.qt-viewer-wrap { padding: 0; }
.qt-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
    color: var(--text-mute);
    gap: 10px;
    flex-wrap: wrap;
}
.qt-viewer-container {
    position: relative;
    min-height: 400px;
    background: #f9f9f9;
}
.qt-viewer-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(249,249,249,.9);
    gap: 12px;
    font-size: .9rem;
    color: var(--text-mute);
    z-index: 5;
}
.qt-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: qt-spin .8s linear infinite;
}
@keyframes qt-spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
    .qt-hero h1 { font-size: 1.35rem; }
    .qt-groups-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .qt-viewer-container iframe { height: 420px !important; }
}
@media (max-width: 480px) {
    .qt-groups-grid { grid-template-columns: repeat(2, 1fr); }
    .qt-viewer-container iframe { height: 300px !important; }
}
