﻿@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  color-scheme: light;
  --bg: #f3f6fb; --paper: #ffffff; --ink: #17223a; --muted: #63708a;
  --line: #dce3ee; --line-strong: #c8d2e1; --accent: #2563a8; --accent-2: #194d87;
  --accent-soft: #eaf3ff; --drop: #f7f9fc; --good: #0d7a53; --good-bg: #e9f8f1;
  --warn: #9a5a12; --warn-bg: #fff6e7; --danger: #b13a43; --danger-bg: #fff0f1;
  --shadow: 0 18px 55px rgba(21,44,78,.10);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1520; --paper: #171f2c; --ink: #edf3ff; --muted: #aab6cb;
  --line: #2b3749; --line-strong: #3b4a60; --accent: #66a8f1; --accent-2: #87bdf7;
  --accent-soft: #192e48; --drop: #121a26; --good: #67d2aa; --good-bg: #17352e;
  --warn: #efbc73; --warn-bg: #362a18; --danger: #ff959e; --danger-bg: #3c2026;
  --shadow: 0 18px 55px rgba(0,0,0,.32);
}

* { box-sizing: border-box; }
html { font-family: "Be Vietnam Pro", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
body {
    margin: 0; min-height: 100vh;
    background: linear-gradient(90deg, transparent 0 63px, rgba(37,99,168,.045) 63px 64px, transparent 64px), var(--bg);
}
button, input { font: inherit; }
button { color: inherit; }
.btn { padding: 8px 12px; border: none; border-radius: 4px; cursor: pointer; color: white; display: inline-block; text-decoration: none; font-weight: 500; font-size: 13px; }

/* =========================================
   MENU NAVIGATION & THEME TOGGLE
   ========================================= */
.top-menu-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 15px 20px; background-color: var(--paper); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 1000; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.site-logo { margin-left: 14px; margin-right: 8px; }
.site-logo img { height: 42px; width: auto; display: block; }

.nav-links { display: flex; gap: 10px; align-items: center; flex: 1; justify-content: center; }

.menu-btn {
    text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px;
    padding: 8px 20px; border-radius: 8px; background-color: var(--bg);
    border: 1px solid var(--line-strong); box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease-in-out; cursor: pointer; display: inline-block;
}
.menu-btn:hover {
    background-color: var(--accent); color: #ffffff !important; border-color: var(--accent);
    box-shadow: 0 4px 10px rgba(37, 99, 168, 0.4); transform: translateY(-2px);
}
.menu-btn:active {
    transform: scale(0.92) translateY(2px); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    background-color: var(--accent-2); border-color: var(--accent-2);
}

.right-actions { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
    background: var(--paper); border: 1px solid var(--line-strong); border-radius: 8px;
    cursor: pointer; font-size: 18px; padding: 6px 12px; color: var(--ink);
    transition: all 0.2s ease-in-out; display: flex; align-items: center;
    justify-content: center; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.theme-toggle:hover { background-color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

.menu-toggle { display: none; font-size: 24px; background: none; border: none; cursor: pointer; color: var(--accent); }

@media (max-width: 992px) {
    .menu-toggle { display: block; }
    .nav-links {
        display: none; flex-direction: column; width: 100%; background-color: var(--paper);
        position: absolute; top: 100%; left: 0; padding: 15px 0; border-bottom: 1px solid var(--line);
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
    .nav-links.active { display: flex; }
    .nav-links .menu-btn { width: 90%; text-align: center; }
}

/* =========================================
   LAYOUT & WORKSPACE
   ========================================= */
.shell { max-width: 1280px; margin: 0 auto; padding: clamp(22px, 5vw, 54px) clamp(16px, 4vw, 34px) 48px; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 22px; margin: 0 0 26px; }
.intro h1 { font-size: clamp(26px, 4vw, 43px); line-height: 1.12; letter-spacing: -.035em; margin: 0 0 10px; max-width: 660px; }
.intro p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7; max-width: 660px; }
.privacy {
    display: flex; align-items: center; gap: 9px; padding: 10px 13px; border: 1px solid var(--line);
    background: var(--paper); font-size: 12px; font-weight: 600; color: var(--good); box-shadow: 0 5px 20px rgba(21,44,78,.05);
}
.privacy svg { width: 17px; height: 17px; flex: none; }
.workspace { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }

/* Tabs */
.tabs { display: grid; grid-template-columns: repeat(6, 1fr); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 88%, var(--bg)); }
.tab {
    appearance: none; border: 0; border-right: 1px solid var(--line); background: transparent; padding: 18px 10px;
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); position: relative; display: flex;
    align-items: center; justify-content: center; gap: 8px; min-width: 0;
}
.tab:last-child { border-right: 0; }
.tab svg { width: 17px; height: 17px; flex: none; }
.tab:hover { color: var(--ink); background: var(--paper); }
.tab[aria-selected="true"] { color: var(--accent); background: var(--paper); }
.tab[aria-selected="true"]:after { content: ""; position: absolute; left: 18%; right: 18%; bottom: -1px; height: 3px; background: var(--accent); }

/* Panels */
.panel { display: none; padding: clamp(20px, 4vw, 38px); }
.panel.active { display: block; }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 22px; }
.panel h2 { font-size: 22px; margin: 0 0 7px; letter-spacing: -.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 620px; }
.step { font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--accent); background: var(--accent-soft); padding: 6px 9px; white-space: nowrap; }

/* Upload Zone */
.dropzone {
    min-height: 188px; border: 1.5px dashed var(--line-strong); background: var(--drop); display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center; padding: 28px; cursor: pointer; transition: border-color .18s, background .18s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: block; order: 2; max-width: 100%; margin: 16px auto 0; color: var(--muted); font-size: 11px; }
.dropzone input::file-selector-button { border: 1px solid var(--line-strong); background: var(--paper); color: var(--accent); font-weight: 700; padding: 8px 10px; margin-right: 8px; cursor: pointer; }
.drop-icon { width: 46px; height: 54px; margin: 0 auto 13px; color: var(--accent); }
.dropzone strong { display: block; font-size: 15px; margin-bottom: 5px; }
.dropzone small { display: block; color: var(--muted); line-height: 1.6; }
.browse { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* File List & Controls */
.picked { margin-top: 15px; display: grid; gap: 8px; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); background: var(--paper); }
.file-type { font-family: "IBM Plex Mono", monospace; font-size: 10px; font-weight: 700; color: var(--danger); background: var(--danger-bg); padding: 5px 7px; }
.file-main { min-width: 0; }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.file-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.file-actions { display: flex; gap: 4px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 7px; cursor: pointer; }
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.icon-btn svg { display: block; width: 16px; height: 16px; }

.controls { margin-top: 22px; display: grid; gap: 18px; }
.label { font-size: 12px; font-weight: 700; margin-bottom: 9px; display: block; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice { position: relative; border: 1px solid var(--line); padding: 13px 12px; background: var(--paper); cursor: pointer; min-height: 65px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { position: absolute; right: 10px; top: 10px; width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.choice b { font-size: 13px; display: block; margin: 0 25px 4px 0; }
.choice span { font-size: 11px; color: var(--muted); line-height: 1.45; display: block; }
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.field label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.field input { width: 100%; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); padding: 13px 14px; outline: 0; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Buttons & Status */
.actionbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.55; }
.hint strong { color: var(--ink); }
.primary, .secondary { appearance: none; border: 0; padding: 13px 18px; font-weight: 700; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 45px; text-decoration: none; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-2); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.secondary { background: var(--paper); border: 1px solid var(--line); color: var(--ink); }
.secondary:hover { border-color: var(--accent); color: var(--accent); }
.primary svg, .secondary svg { width: 17px; height: 17px; }

.status { display: none; margin-top: 16px; padding: 12px 14px; font-size: 12px; line-height: 1.55; border: 1px solid var(--line); }
.status.show { display: block; }
.status.busy { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.status.ok { background: var(--good-bg); color: var(--good); }
.status.error { background: var(--danger-bg); color: var(--danger); }
.loader { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   CSS RIÊNG CHO TAB XML THUẾ
   ========================================= */
.tax-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--paper); border: 1px solid var(--line); padding: 12px 20px; margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04); border-radius: 8px;
}
.toolbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-title { font-weight: 700; font-size: 15px; color: var(--accent); }
.file-status { font-size: 13px; color: var(--muted); background: var(--bg); padding: 6px 12px; border: 1px solid var(--line); border-radius: 4px; }
.btn-upload { background: var(--accent); color: #fff; border-radius: 6px; }
.btn-upload:hover { background: var(--accent-2); }
.btn-print { background: var(--good); color: #fff; border-radius: 6px; }
.btn-print:hover:not(:disabled) { background: #0b6243; }
.search-input { padding: 8px 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); font-size: 13px; min-width: 200px; outline: none; }
.search-input:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="file"].tax-file-input { display: none; }

.page-wrapper { display: none; justify-content: center; width: 100%; overflow-x: auto; }
.tax-page { background: #ffffff; color: #000000; width: 297mm; min-height: 210mm; padding: 12mm; box-shadow: var(--shadow); font-family: "Times New Roman", Times, serif; font-size: 12pt; }
.tax-page.portrait { width: 210mm; min-height: 297mm; }

.header-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.header-center { flex: 1; text-align: center; padding: 0 10px; }
.header-box { width: 230px; border: 1px solid #000; padding: 8px; text-align: center; font-size: 10pt; line-height: 1.35; background: #fff; color: #000; }
.quoc-hieu { font-weight: bold; font-size: 12pt; text-transform: uppercase; margin: 0; color: #000; }
.doc-lap { font-weight: bold; font-size: 11.5pt; margin: 2px 0 6px 0; text-decoration: underline; color: #000; }
.ten-to-khai { font-weight: bold; font-size: 13pt; text-transform: uppercase; margin: 8px 0 4px 0; color: #000; }
.sub-to-khai { font-style: italic; font-size: 9.5pt; margin: 2px auto; max-width: 800px; line-height: 1.3; color: #000; }
.ky-thue-line { font-weight: bold; font-size: 11pt; margin-top: 6px; color: #000; }

.nnt-info { margin: 10px 0 14px 0; font-size: 11pt; line-height: 1.55; color: #000; }
.nnt-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.nnt-item { flex: 1; min-width: 240px; }
.bold { font-weight: bold; }
.unit-note { text-align: right; font-style: italic; font-size: 10pt; margin-bottom: 4px; color: #000; }

table.tax-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9pt; background: #fff; }
table.tax-table th, table.tax-table td { border: 1px solid #000; padding: 4px; vertical-align: middle; word-wrap: break-word; overflow-wrap: break-word; color: #000; }
table.tax-table thead th { background-color: #f8fafc; font-weight: bold; text-align: center; line-height: 1.25; }
table.tax-table .col-code { font-style: italic; font-weight: normal; font-size: 8.5pt; background-color: #f1f5f9; }

.text-center { text-align: center; }
.text-right { text-align: right; font-variant-numeric: tabular-nums; }
.text-left { text-align: left; }
.total-row td { font-weight: bold; background-color: #f8fafc; }

.footer-section { margin-top: 14px; font-size: 10.5pt; page-break-inside: avoid; color: #000; }
.amount-in-words { margin: 8px 0 12px 0; font-weight: bold; }
.cam-doan { font-style: italic; margin-bottom: 12px; }

.sign-grid { display: flex; justify-content: space-between; margin-top: 10px; gap: 20px; }
.sign-left { width: 48%; font-size: 10pt; }
.sign-right { width: 48%; text-align: center; }
.digital-sig-box { margin-top: 12px; display: inline-block; text-align: left; border: 2px solid #16a34a; background-color: #f0fdf4; color: #166534; padding: 8px 12px; border-radius: 4px; font-size: 9.5pt; line-height: 1.4; max-width: 100%; }
.digital-sig-title { font-weight: bold; color: #15803d; text-transform: uppercase; margin-bottom: 4px; }

.form-section-title { font-weight: bold; background: #e2e8f0; padding: 6px 10px; border: 1px solid #000; border-bottom: none; font-size: 10.5pt; margin-top: 10px; color: #000; }
table.form-table { width: 100%; border-collapse: collapse; font-size: 10pt; background: #fff; }
table.form-table th, table.form-table td { border: 1px solid #000; padding: 5px 8px; vertical-align: middle; color: #000; }
table.form-table th { background-color: #f8fafc; text-align: center; }

/* Responsive adjustments */
@media(max-width: 720px) {
    body { background: var(--bg); }
    .shell { padding: 20px 12px 34px; }
    .intro { grid-template-columns: 1fr; align-items: start; margin-bottom: 18px; }
    .privacy { width: max-content; }
    .tabs { grid-template-columns: repeat(3, 1fr); }
    .tab:nth-child(n+4) { border-top: 1px solid var(--line); }
    .tab:nth-child(3) { border-right: 0; }
    .tab { padding: 13px 6px; gap: 6px; font-size: 11px; }
    .panel { padding: 20px 14px 24px; }
    .panel-head { display: block; }
    .dropzone { min-height: 165px; padding: 21px 14px; }
    .choices { grid-template-columns: 1fr; }
    .actionbar { align-items: stretch; flex-direction: column; }
    .primary, .secondary { width: 100%; }
    .range-row { grid-template-columns: 1fr; }
    .file-row { grid-template-columns: auto minmax(0, 1fr); }
    .file-actions { grid-column: 2; justify-content: flex-end; }
}
@media(prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } .loader { animation: none; } }

/* =========================================
   IN ẤN (PRINT)
   ========================================= */
@page { margin: 10mm; }
@media print {
    body { background: #fff !important; color: #000 !important; margin: 0; padding: 0; }
    .panel-head, .top-menu-bar, .intro, .workspace > .tabs, .tax-toolbar, .empty-state-wrapper, footer, .actionbar, .dropzone, .picked, .controls { display: none !important; }
    .shell { padding: 0 !important; margin: 0 !important; max-width: none !important; }
    .panel { display: none !important; padding: 0 !important; }
    #panel-tax.panel { display: block !important; padding: 0 !important; }
    .page-wrapper { display: block !important; padding: 0 !important; }
    .tax-page { width: 100% !important; min-height: auto !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; }
}