/* TTHC — CSS được định dạng để dễ đọc và bảo trì.*/

/* 01. Biến giao diện và kiểu chữ mặc định */

:root {
    --red: #a6102a;
    --red-dark: #8e0e20;
    --red-soft: #fcecef;
    --paper: #fff;
    --bg: #fafaf9;
    --ink: #262626;
    --muted: #6b6b6b;
    --border: #e7e4e0;
    --nav: #1e4d78;
    --nav-soft: #f1f5f9;
    --nav-hover: #e2ebf3;
    --green: #246747;
    --green-soft: #e7f3ec;
    --amber: #805809;
    --amber-soft: #fff1d8;
    --radius: 18px;
    font-family: 'Be Vietnam Pro',Arial,sans-serif;
    font-size: 100%;
    color: var(--ink);
    background: var(--bg);
}

/* 02. Thiết lập chung và hỗ trợ truy cập */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

button,input,select {
    font: inherit;
}

button,a,input,select {
    -webkit-tap-highlight-color: transparent;
}

button,a {
    touch-action: manipulation;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

button,select,input {
    min-width: 0;
}

button {
    line-height: 1.5;
}

svg {
    display: block;
}

img {
    max-width: 100%;
    display: block;
}

button:disabled {
    cursor: default;
    opacity: .45;
}

a,button,input,select {
    outline-offset: 4px;
}

:focus-visible {
    outline: 3px solid var(--nav);
}

.header :focus-visible {
    outline-color: #fff;
}

button:focus-visible,a:focus-visible {
    position: relative;
    z-index: 2;
}

button svg,a svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

h1,h2,h3,p {
    margin-top: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none!important;
}

.skip-link {
    position: fixed;
    top: -100px;
    left: 12px;
    padding: 12px 18px;
    background: white;
    color: var(--red-dark);
    border-radius: 8px;
    z-index: 100;
}

.skip-link:focus {
    top: 10px;
}

/* 03. Đầu trang, thương hiệu và công cụ */

.header {
    min-height: 88px;
    background: var(--red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 26px;
    box-shadow: 0 3px 12px #72132425;
    position: relative;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    text-decoration: none;
}

.brand-logo {
    width: 54px;
    height: 54px;
    border-radius: 13px;
    background: white;
    overflow: hidden;
    flex: 0 0 54px;
    padding: 2px;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-title {
    display: block;
    font-weight: 800;
    font-size: .875rem;
    line-height: 1.5;
}

.slogan {
    display: block;
    color: #fce1e5;
    font-style: italic;
    font-size: .8125rem;
    margin-top: 2px;
}

/* Bổ sung bố cục và ngắt dòng (giữ vị trí ưu tiên gốc) */

.header-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.hotline {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    padding: 8px 12px;
    border: 1px solid #ffffff4a;
    background: #ffffff15;
    border-radius: 12px;
}

.hotline span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hotline .hotline-label {
    font-size: .75rem;
    font-weight: 500;
    color: #ffe6eb;
}

.hotline strong {
    font-size: .875rem;
    white-space: nowrap;
}

.clock {
    font-size: .8125rem;
    font-variant-numeric: tabular-nums;
    min-width: 61px;
}

.font-tools {
    display: flex;
    gap: 7px;
}

.font-tools button {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    color: white;
    border: 1px solid #ffffff4a;
    background: #ffffff12;
    font-size: .875rem;
    font-weight: 700;
}

.font-tools button:hover:not(:disabled) {
    background: #ffffff25;
}

.home-button {
    background: white;
    color: var(--red-dark);
    border-radius: 12px;
    padding: 11px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .875rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.home-button:hover {
    background: #ffeef1;
}

/* 04. Bố cục và thanh điều hướng */

.workspace {
    display: flex;
    min-height: calc(100dvh - 88px);
}

.sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: var(--paper);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    align-self: flex-start;
    position: sticky;
    top: 0;
    max-height: 100dvh;
    overflow: auto;
    scrollbar-width: thin;
}

.eyebrow {
    font-size: .75rem;
    line-height: 1.5;
    letter-spacing: .08em;
    font-weight: 700;
    color: var(--muted);
    margin: 0 0 12px;
}

.sidebar-heading {
    padding-left: 8px;
}

.departments {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.department {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 13px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    min-height: 96px;
    background: #fff;
    text-decoration: none;
    color: #c95117;
    text-align: left;
    box-shadow: 0 1px 2px rgba(0,0,0,.02);
    transition: transform .2s ease,background-color .2s ease,
        border-color .2s ease,box-shadow .2s ease;
}

.department:hover {
    transform: translateX(5px);
    background: #fff3ed;
    border-color: #93c5fd;
}

.department[aria-current="page"] {
    background: #fff3ed;
    color: #c95117;
    border-color: #c95117;
    box-shadow: inset 4px 0 0 #c95117;
}

.department[aria-current="page"]:hover {
    border-color: #93c5fd;
}

.department:focus-visible {
    background: #fff3ed;
}

.department-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 46px;
    flex: 0 0 45px;
    background: rgba(201,81,23,.1);
    border-radius: 12px;
    font-size: 1.375rem;
}

.department-name {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.35;
}

.department[aria-current="page"] .department-icon {
    background: rgba(201,81,23,.15);
}

.department-name small {
    display: block;
    font-size: .8125rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 5px;
}

.other-links {
    margin-top: 24px;
}

.other-links>.eyebrow {
    padding-left: 8px;
}

.portal-link {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px dashed #debfc6;
    border-radius: 16px;
    padding: 15px 12px;
    color: var(--red-dark);
    font-size: .9375rem;
    line-height: 1.4;
    font-weight: 700;
    text-decoration: none;
}

.portal-link:hover {
    background: var(--red-soft);
}

.portal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 44px;
    flex: 0 0 42px;
    background: #fceef1;
    border-radius: 12px;
    font-size: 1.4rem;
}

.portal-link small {
    display: block;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 500;
    margin-top: 5px;
}

/* 05. Nội dung chính và giới thiệu */

.content {
    flex: 1;
    min-width: 0;
    max-width: 1800px;
    padding: 30px 30px 20px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    padding: 2px 0 27px;
}

.hero-logo {
    display: block;
    width: 106px;
    height: 106px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 0 7px #fceef1,0 12px 22px #900e2012;
    padding: 14px;
    margin: 0 auto 22px;
}

.hero-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.hero h1 {
    color: var(--red-dark);
    font-size: 1.55rem;
    font-weight: 750;
    line-height: 1.45;
    margin: 0 0 9px;
}

.hero .subtitle {
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
}

/* 06. Thẻ truy cập nhanh */

.section-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .065em;
    color: var(--muted);
    text-transform: uppercase;
    margin: 0 0 14px;
}

.section-heading span {
    font-size: 1rem;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 16px;
}

.quick-card {
    background: var(--paper);
    color: var(--ink);
    border-radius: 18px;
    box-shadow: 0 3px 10px #26262608;
    padding: 24px 17px 20px;
    min-height: 288px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    gap: 7px;
    border: 1px solid #debfc6;
    border-top: 3px solid var(--red);
    transition: transform .18s,box-shadow .18s;
}

.quick-card:hover {
    transform: translateY(-3px);
    border-color: var(--red);
    background: #fff9fa;
    box-shadow: 0 6px 16px #8e0e2014;
}

.quick-card:active {
    transform: translateY(0);
}

.quick-logo {
    width: 53px;
    height: 53px;
    object-fit: contain;
    margin: 0 0 10px;
}

.quick-name {
    color: var(--red-dark);
    font-size: .9375rem;
    font-weight: 700;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quick-code {
    font-size: .8125rem;
    color: var(--muted);
    font-weight: 500;
}

.quick-field {
    font-size: .75rem;
    font-style: italic;
    color: var(--muted);
    line-height: 1.5;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    display: inline-block;
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.5;
    border-radius: 20px;
    padding: 3px 11px;
    white-space: nowrap;
    color: #555;
    background: #ecebea;
}

.badge.complete {
    color: var(--green);
    background: var(--green-soft);
}

.badge.partial {
    color: var(--amber);
    background: var(--amber-soft);
}

.quick-card .badge {
    margin-top: 2px;
    font-size: .75rem;
}

.quick-department {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 10px;
    font-size: .75rem;
    line-height: 1.5;
    color: var(--nav);
    text-transform: uppercase;
    width: 92%;
}

/* Thẻ tra cứu nhiều dùng chung cho trang Xã và Sở ngành, theo mẫu TTHCSONGANH1.html. */
.quick-cards-reference .quick-card-slot {
    display: flex;
    min-width: 0;
    position: relative;
}

.quick-cards-reference .quick-card {
    position: relative;
    isolation: isolate;
    flex: 1;
    min-width: 0;
    background: #d2232a;
    color: #fff;
    border: 1px solid #fff;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(65,15,20,.12);
    transition: transform 420ms cubic-bezier(.16,1,.3,1),background-color 300ms ease;
}

/* Bóng hiện dần bằng opacity; vùng nhận chuột không di chuyển theo thẻ. */
.quick-cards-reference .quick-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    box-shadow: 0 18px 32px -10px rgba(90,18,26,.34),0 7px 12px -6px rgba(60,12,18,.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 420ms cubic-bezier(.16,1,.3,1);
}

@media (min-width:761px) {
    .quick-cards-reference .quick-card {
        aspect-ratio: 1 / 1.414;
    }
}

.quick-cards-reference .quick-card::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1.5px solid rgba(255,255,255,.9);
    border-radius: 8px;
    pointer-events: none;
}

.quick-cards-reference .quick-name {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.quick-cards-reference .quick-code,
.quick-cards-reference .quick-field,
.quick-cards-reference .quick-department {
    color: rgba(255,255,255,.9);
}

.quick-cards-reference .quick-department {
    border-top: 1px dashed rgba(255,255,255,.4);
}

.quick-cards-reference .quick-logo {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.2));
}

.quick-cards-reference .quick-card .badge {
    color: #d2232a;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.quick-cards-reference .quick-card:focus-visible {
    background: #c31f28;
}

.quick-cards-reference .quick-card:focus-visible::after {
    opacity: 1;
}

@media (hover:hover) and (pointer:fine) {
    .quick-cards-reference .quick-card-slot:hover .quick-card,
    .quick-cards-reference .quick-card-slot:focus-within .quick-card {
        transform: translateY(-8px);
        background: #c31f28;
        box-shadow: 0 2px 5px rgba(65,15,20,.12);
    }

    .quick-cards-reference .quick-card-slot:hover .quick-card::after {
        opacity: 1;
    }
}

.quick-cards-reference .quick-card-slot .quick-card:active {
    transform: translateY(-2px);
    background: #b91c1c;
    box-shadow: 0 2px 4px rgba(80,12,18,.1),0 5px 12px rgba(150,22,30,.16);
    transition-duration: 120ms;
}

@media (prefers-reduced-motion:reduce) {
    .quick-cards-reference .quick-card-slot:hover .quick-card,
    .quick-cards-reference .quick-card-slot:focus-within .quick-card,
    .quick-cards-reference .quick-card-slot .quick-card:active {
        transform: none;
    }

    .quick-cards-reference .quick-card::after {
        transition: none;
    }
}

/* 07. Tiện ích và chân trang */

.utilities {
    margin-top: 32px;
}

.utility-grid {
    display: grid;
    grid-template-columns: repeat(5,minmax(0,1fr));
    gap: 12px;
}

.utility {
    background: white;
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    text-decoration: none;
    position: relative;
}

.utility:hover {
    border-color: #d1a0aa;
    background: #fff9fa;
}

.utility-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--utility-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.utility-label {
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.5;
}

.external-mark {
    position: absolute;
    right: 10px;
    top: 8px;
    color: #96908f;
    font-size: .875rem;
}

.footer {
    color: #77716f;
    font-size: .75rem;
    line-height: 1.85;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 35px;
    text-align: center;
}

.footer a {
    text-decoration-color: #bbb;
    text-underline-offset: 3px;
}

/* 08. Điều hướng và tiêu đề danh mục */

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
    font-size: .875rem;
    line-height: 1.6;
    color: var(--muted);
}

.breadcrumb a {
    display: flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--red-dark);
    font-weight: 600;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb svg {
    width: 18px;
    height: 18px;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 10px 14px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--red-dark);
    text-decoration: none;
}

.back-button:hover {
    border-color: #cd9ba6;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.category-title-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 15px;
    background: var(--nav-soft);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.category-title h1 {
    font-size: 1.5rem;
    line-height: 1.5;
    color: var(--red-dark);
    margin-bottom: 4px;
}

.category-title p {
    font-size: .875rem;
    color: var(--muted);
    margin: 0;
}

/* 09. Tìm kiếm và bộ lọc */

.filters {
    display: grid;
    grid-template-columns: minmax(220px,1fr) minmax(190px,.55fr);
    gap: 12px;
    margin: 0 0 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 0 11px 0 16px;
    min-height: 53px;
    color: var(--muted);
}

.search-box:focus-within {
    border-color: var(--nav);
    box-shadow: 0 0 0 2px var(--nav);
}

.search-box>svg {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.search-box input {
    border: 0;
    outline: none;
    background: transparent;
    min-width: 0;
    width: 100%;
    font-size: 1rem;
    padding: 14px 0;
    color: var(--ink);
}

.search-box input::placeholder {
    color: var(--muted);
}

.search-box input::-webkit-search-cancel-button {
    display: none;
}

.clear-search,.keyboard-toggle {
    border: 0;
    background: transparent;
    color: var(--muted);
    width: 36px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
}

.clear-search:hover,.keyboard-toggle:hover,.keyboard-toggle[aria-expanded="true"] {
    background: var(--red-soft);
    color: var(--red);
}

.filters select {
    min-width: 0;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: white;
    color: var(--ink);
    padding: 12px 34px 12px 14px;
    font-size: .875rem;
    text-overflow: ellipsis;
}

.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: .8125rem;
    color: var(--muted);
    padding: 0 2px 12px;
    min-height: 32px;
}

.reset-filters {
    background: none;
    border: 0;
    color: var(--red-dark);
    font-size: .8125rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* 10. Danh sách thủ tục */

.procedure-list {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.procedure {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 17px 18px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 15px;
    text-decoration: none;
    min-height: 89px;
    transition: border-color .16s,background .16s;
}

.procedure:hover {
    border-color: #d7a7b1;
    background: #fffafb;
}

.procedure .row-icon {
    width: 43px;
    height: 44px;
    border-radius: 11px;
    background: var(--nav-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.procedure-copy {
    flex: 1;
    min-width: 0;
}

.procedure-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.6;
    display: block;
    margin-bottom: 4px;
}

.procedure-meta {
    color: var(--muted);
    font-size: .8125rem;
    line-height: 1.6;
}

.procedure>svg {
    width: 20px;
    height: 20px;
    color: var(--red);
    flex-shrink: 0;
}

.empty {
    padding: 42px 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    text-align: center;
    color: var(--muted);
    line-height: 1.7;
}

.empty h2 {
    font-size: 1.125rem;
    color: var(--ink);
    margin: 0 0 10px;
}

.empty p {
    margin: 0 0 16px;
}

.empty-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 12px;
}

/* 11. Chi tiết thủ tục và mã QR */

.detail {
    max-width: 1060px;
    margin: 0 auto;
}

.info-card {
    background: white;
    border: 1px solid var(--border);
    border-top: 4px solid var(--red);
    border-radius: 18px;
    padding: 27px 28px 29px;
    margin-bottom: 24px;
}

.detail-kicker {
    font-size: .75rem;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 13px;
}

.info-card h1 {
    font-size: 1.5rem;
    line-height: 1.6;
    color: var(--red-dark);
    margin: 0 0 24px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px 28px;
    margin: 0;
}

.info-grid dt {
    font-size: .75rem;
    line-height: 1.5;
    letter-spacing: .035em;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 7px;
}

.info-grid dd {
    font-size: 1rem;
    line-height: 1.6;
    font-weight: 600;
    margin: 0;
    overflow-wrap: anywhere;
}

.qr-panel {
    background: white;
    border: 2px solid var(--red);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    gap: 35px;
    align-items: center;
    box-shadow: 0 6px 20px #c8102e0a;
}

.qr-code {
    width: 224px;
    flex: 0 0 224px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.qr-code img,.qr-code svg {
    width: 224px;
    height: 224px;
    max-width: 100%;
    background: white;
}

.qr-caption {
    font-size: .8125rem;
    color: var(--muted);
    text-align: center;
}

.qr-copy {
    flex: 1;
    min-width: 0;
}

.qr-copy h2 {
    font-size: 1.25rem;
    line-height: 1.55;
    color: var(--red-dark);
    margin: 0 0 12px;
}

.qr-copy p {
    font-size: 1rem;
    color: #555;
    line-height: 1.8;
    margin-bottom: 20px;
}

.primary-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    background: var(--red);
    border: 1px solid var(--red);
    border-radius: 12px;
    padding: 13px 19px;
    color: white;
    font-size: .9375rem;
    line-height: 1.6;
    font-weight: 600;
    text-decoration: none;
}

.primary-button:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}

.support {
    margin-top: 20px;
    padding: 15px 18px;
    border-radius: 12px;
    background: var(--red-soft);
    color: var(--red-dark);
    font-size: .875rem;
    line-height: 1.8;
}

.support a {
    font-weight: 700;
    text-underline-offset: 3px;
}

.source-note {
    font-size: .8125rem;
    color: var(--muted);
    line-height: 1.7;
    margin-top: 18px;
}

/* 12. Bàn phím ảo */

.keyboard {
    position: fixed;
    bottom: 0;
    left: 240px;
    right: 0;
    background: white;
    border-top: 2px solid var(--border);
    padding: 12px 18px 16px;
    z-index: 20;
    box-shadow: 0 -6px 20px #00000010;
}

.keyboard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 auto 10px;
    max-width: 880px;
    font-size: .875rem;
    color: var(--muted);
    font-weight: 600;
}

.keyboard-head button {
    border: 0;
    background: var(--red);
    color: white;
    border-radius: 8px;
    padding: 7px 15px;
    font-size: .875rem;
}

.key-row {
    display: flex;
    gap: 6px;
    max-width: 880px;
    margin: 6px auto 0;
}

.key {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--ink);
    border-radius: 8px;
    min-height: 44px;
    font-size: 1rem;
    padding: 5px 0;
}

.key:hover {
    background: var(--red-soft);
}

.key.accent {
    background: var(--red-soft);
    color: var(--red-dark);
}

.key.wide {
    flex: 2;
}

.key.space {
    flex: 5;
}

.keyboard-open .content {
    padding-bottom: 400px;
}

/* 13. Hộp thoại và trạng thái tải */

.idle-dialog {
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 20px;
    max-width: 430px;
    width: calc(100% - 32px);
    text-align: center;
    box-shadow: 0 20px 70px #0003;
}

.idle-dialog::backdrop {
    background: #210a12a0;
}

.idle-dialog h2 {
    font-size: 1.25rem;
    color: var(--red-dark);
    line-height: 1.6;
    margin-bottom: 12px;
}

.idle-dialog p {
    font-size: 1rem;
    line-height: 1.8;
}

.loading {
    padding: 80px 20px;
    text-align: center;
    color: var(--muted);
}

/* Giao diện thích ứng: (min-width:1600px) */

@media(min-width:1600px) {
    .quick-grid {
        grid-template-columns: repeat(5,minmax(0,1fr));
    }

    .content {
        padding-left: 40px;
        padding-right: 40px;
    }

    .hero {
        padding-bottom: 32px;
    }

}

/* Giao diện thích ứng: (max-width:1200px) */

@media(max-width:1200px) {
    .clock {
        display: none;
    }

    .header {
        padding-left: 20px;
        padding-right: 20px;
        gap: 14px;
    }

    .brand-title {
        font-size: .8125rem;
    }

    .hotline {
        padding: 7px 10px;
    }

    .header-tools {
        gap: 7px;
    }

    .sidebar {
        width: 220px;
        flex-basis: 220px;
    }

    .department {
        gap: 10px;
        padding: 13px 10px;
    }

    .department-icon {
        width: 38px;
        height: 40px;
        flex-basis: 38px;
    }

    .department-name {
        font-size: .9375rem;
    }

    .content {
        padding: 26px 23px 20px;
    }

    .quick-grid {
        gap: 13px;
    }

    .quick-card {
        padding-left: 12px;
        padding-right: 12px;
    }

    .quick-name {
        font-size: .9375rem;
    }

    .utility-grid {
        grid-template-columns: repeat(4,minmax(0,1fr));
    }

    .keyboard {
        left: 220px;
    }

}

/* Giao diện thích ứng: (max-width:1000px) */

@media(max-width:1000px) {
    .header {
        flex-wrap: wrap;
        padding: 12px 20px;
        gap: 12px;
    }

    .header-tools {
        margin-left: auto;
    }

    .brand {
        flex: 1 1 400px;
    }

    .brand-title {
        font-size: .875rem;
    }

    .quick-grid {
        grid-template-columns: repeat(3,minmax(0,1fr));
    }

    .quick-card {
        min-height: 275px;
    }

    .hero h1 {
        font-size: 1.375rem;
    }

    .hero .subtitle {
        font-size: .9375rem;
    }

    .procedure {
        gap: 11px;
        padding: 15px;
    }

    .procedure>.badge {
        font-size: .75rem;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .qr-panel {
        gap: 22px;
        padding: 24px;
    }

    .qr-code {
        flex-basis: 190px;
        width: 190px;
    }

    .qr-code img,.qr-code svg {
        width: 190px;
        height: 190px;
    }

    .utility-grid {
        grid-template-columns: repeat(3,minmax(0,1fr));
    }

}

/* Giao diện thích ứng: (max-width:760px) */

@media(max-width:760px) {
    .header {
        padding: 12px 15px;
        gap: 11px;
    }

    .brand {
        flex-basis: 100%;
        gap: 10px;
    }

    .brand-logo {
        width: 45px;
        height: 45px;
        flex-basis: 45px;
        border-radius: 11px;
    }

    .brand-title {
        font-size: .8125rem;
        line-height: 1.55;
    }

    .slogan {
        font-size: .75rem;
    }

    .header-tools {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .hotline {
        padding: 7px 10px;
        flex-direction: row;
        gap: 7px;
    }

    .hotline span {
        flex-direction: row;
        align-items: center;
    }

    .hotline-label {
        display: none!important;
    }

    .hotline strong {
        font-size: .8125rem;
    }

    .hotline svg {
        width: 16px;
        height: 16px;
    }

    .clock {
        display: block;
        font-size: .75rem;
        min-width: 58px;
    }

    .font-tools button {
        width: 35px;
        height: 36px;
        font-size: .8125rem;
    }

    .home-button {
        padding: 8px 11px;
        font-size: .8125rem;
        gap: 5px;
    }

    .home-button svg {
        width: 17px;
        height: 17px;
    }

    .workspace {
        display: block;
        min-height: 0;
    }

    .sidebar {
        position: relative;
        width: 100%;
        max-height: none;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        overflow: hidden;
    }

    .sidebar-heading {
        font-size: .75rem;
        margin-bottom: 8px;
        padding-left: 2px;
    }

    .departments {
        flex-direction: row;
        gap: 10px;
        overflow-x: auto;
        padding: 3px 3px 8px;
        scroll-snap-type: x proximity;
        scrollbar-width: thin;
    }

    .department {
        flex: 0 0 190px;
        min-height: 94px;
        align-items: center;
        scroll-snap-align: start;
        padding: 11px 12px;
        border-radius: 13px;
        gap: 10px;
    }

    .department:hover {
        transform: none;
    }

    .department-name {
        font-size: .875rem;
    }

    .department-name small {
        font-size: .75rem;
        margin-top: 4px;
    }

    .department-icon {
        width: 34px;
        height: 38px;
        flex-basis: 34px;
        font-size: 1.125rem;
    }

    .other-links {
        display: none;
    }

    .content {
        padding: 24px 16px 20px;
    }

    .hero {
        padding: 0 0 25px;
    }

    .hero-logo {
        width: 85px;
        height: 85px;
        padding: 12px;
        margin-bottom: 22px;
    }

    .hero h1 {
        font-size: 1.375rem;
        line-height: 1.5;
    }

    .hero .subtitle {
        font-size: .9375rem;
        line-height: 1.7;
        max-width: 400px;
        margin: 0 auto;
    }

    .quick-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
        gap: 12px;
    }

    .quick-card {
        min-height: 275px;
        padding: 21px 12px 18px;
    }

    .quick-name {
        font-size: .9375rem;
    }

    .quick-logo {
        width: 44px;
        height: 44px;
        margin-bottom: 7px;
    }

    .quick-department {
        font-size: .75rem;
    }

    .utility-grid {
        grid-template-columns: repeat(3,minmax(0,1fr));
    }

    .utility-label {
        font-size: .8755rem;
    }

    .section-heading {
        font-size: .75rem;
    }

    .category-title {
        gap: 11px;
        margin-bottom: 18px;
    }

    .category-title h1 {
        font-size: 1.25rem;
    }

    .category-title-icon {
        width: 47px;
        height: 48px;
    }

    .breadcrumb {
        font-size: .8125rem;
        margin-bottom: 20px;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .procedure {
        display: grid;
        grid-template-columns: 40px 1fr 16px;
        gap: 8px 11px;
        padding: 16px 13px;
    }

    .procedure .row-icon {
        width: 38px;
        height: 40px;
        grid-column: 1;
        grid-row: 1;
    }

    .procedure-copy {
        grid-column: 2;
        grid-row: 1;
    }

    .procedure-name {
        font-size: 1rem;
    }

    .procedure-meta {
        font-size: .8125rem;
    }

    .procedure>.badge {
        grid-column: 2;
        justify-self: start;
        grid-row: 2;
        margin-top: 2px;
    }

    .procedure>svg {
        grid-column: 3;
        grid-row: 1/3;
        width: 16px;
        height: 16px;
    }

    .info-card {
        padding: 23px 20px;
    }

    .info-card h1 {
        font-size: 1.25rem;
    }

    .info-grid {
        gap: 19px;
        grid-template-columns: 1fr;
    }

    .qr-panel {
        flex-direction: column;
        gap: 22px;
        padding: 25px 20px;
        text-align: center;
    }

    .qr-code {
        flex-basis: auto;
        width: 220px;
    }

    .qr-code img,.qr-code svg {
        width: 220px;
        height: 220px;
    }

    .qr-copy h2 {
        font-size: 1.25rem;
    }

    .qr-copy p {
        font-size: 1rem;
    }

    .primary-button {
        width: 100%;
        font-size: .9375rem;
    }

    .support {
        text-align: center;
    }

    .keyboard {
        left: 0;
        padding: 10px 7px;
    }

    .key-row {
        gap: 4px;
    }

    .key {
        min-height: 42px;
        font-size: .875rem;
    }

    .keyboard-open .content {
        padding-bottom: 400px;
    }

    .footer {
        font-size: .75rem;
        line-height: 1.9;
        margin-top: 30px;
    }

}

/* Giao diện thích ứng: (max-width:400px) */

@media(max-width:400px) {
    .clock {
        display: none;
    }

    .brand-title {
        font-size: .75rem;
    }

    .quick-card {
        padding: 18px 10px;
        min-height: 285px;
    }

    .quick-name {
        font-size: .875rem;
    }

    .quick-code {
        font-size: .75rem;
    }

    .utility-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
    }

    .utility-label {
        font-size: .875rem;
    }

    .content {
        padding-left: 12px;
        padding-right: 12px;
    }

}

/* Bổ sung bố cục và ngắt dòng (giữ vị trí ưu tiên gốc) */

.header-tools {
    flex-wrap: wrap;
}

.font-tools button {
    min-width: 2.25rem;
    min-height: 2.25rem;
}

.home-button {
    min-height: 2.5rem;
}

.quick-card,.department,.utility,.brand-text {
    overflow-wrap: break-word;
}

/* Chuyển động ngắn, đồng nhất; không làm thay đổi kích thước bố cục. */
.quick-card,.utility,.procedure,.primary-button,.home-button,
.font-tools button,.clear-search,.reset-filters {
    transition: transform 180ms ease, background-color 180ms ease,
        border-color 180ms ease, box-shadow 180ms ease;
}

.search-box:focus-within {
    border-color: var(--nav);
    box-shadow: 0 0 0 2px var(--nav);
}

.department:active,.quick-card:active,.utility:active,.primary-button:active {
    transform: scale(.985);
}

@media(hover:none) {
    .department:hover,.quick-card:hover,.utility:hover { transform: none; }
}

@media(max-width:760px) {
    body { min-height: 100dvh; }
    .header { padding-top: max(12px,env(safe-area-inset-top)); }
    .header-tools { flex-shrink: 1; }
    .brand-text,.category-title>div,.qr-code,#qr-image { min-width: 0; }
    .content {
        padding: 20px max(14px,env(safe-area-inset-right)) max(28px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));
    }
    .sidebar { background: #fff; }
    .departments { overscroll-behavior-x: contain; scroll-padding-inline: 3px; }
    .department { flex-basis: 180px; min-height: 80px; }
    .department[aria-current="page"] { box-shadow: inset 4px 0 0 #c95117; }
    .font-tools button,.home-button,.hotline,.clear-search,.reset-filters,
    .breadcrumb a { min-height: 44px; }
    .font-tools button,.clear-search { min-width: 44px; }
    .breadcrumb a { display: inline-flex; align-items: center; }
    .keyboard-toggle { display: none; }
    .search-box input,.filters select { font-size: 1rem; min-height: 50px; }
    .filters { gap: 10px; }
    .quick-grid { grid-template-columns: minmax(0,1fr); }
    .quick-card {
        min-height: 0;
        padding: 18px;
        align-items: flex-start;
        text-align: left;
        gap: 8px;
        border-radius: 16px;
    }
    .quick-name { display: block; overflow: visible; font-size: 1rem; line-height: 1.65; }
    .quick-field { white-space: normal; overflow: visible; }
    .quick-logo { width: 40px; height: 40px; margin-bottom: 2px; }
    .quick-department { width: 100%; }
    .section-heading { font-size: .875rem; line-height: 1.6; }
    .utility-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
    .procedure { grid-template-columns: 34px minmax(0,1fr) 16px; gap: 8px; border-radius: 14px; }
    .procedure .row-icon { width: 32px; height: 36px; }
    .procedure-name { line-height: 1.65; }
    .procedure-name,.procedure-meta,.category-title h1,.info-card h1 { overflow-wrap: anywhere; }
    .badge { max-width: 100%; white-space: normal; }
    .result-bar { flex-wrap: wrap; gap: 8px; }
    .qr-code { max-width: 100%; }
    .qr-code svg,.qr-code img { height: auto; aspect-ratio: 1; }
    .qr-panel { padding: 20px 16px; }
    .info-card { padding: 20px 16px; }
    .primary-button { min-height: 48px; }
}

.mobile-hint {
    display: none;
}

/* Bố cục điện thoại: ưu tiên thao tác chạm và tên thủ tục đầy đủ. */
@media(max-width:760px) {
    .header {
        padding-right: max(14px,env(safe-area-inset-right));
        padding-left: max(14px,env(safe-area-inset-left));
    }
    .header-tools {
        justify-content: flex-end;
        border-top: 1px solid #ffffff30;
        padding-top: 10px;
    }
    .clock { margin-right: auto; }
    .brand-logo { width: 48px; height: 48px; flex-basis: 48px; }
    .brand-text { flex: 1; }
    .brand-title { font-size: .8125rem; }
    .sidebar {
        padding-left: max(14px,env(safe-area-inset-left));
        padding-right: max(14px,env(safe-area-inset-right));
    }
    .mobile-hint {
        display: block;
        margin: 0 0 10px;
        color: var(--muted);
        font-size: .75rem;
        line-height: 1.5;
    }
    .hero { padding-bottom: 22px; }
    .hero-logo { width: 72px; height: 72px; margin-bottom: 18px; }
    .hero h1 { font-size: 1.25rem; }
    .quick-card {
        display: grid;
        grid-template-columns: 36px minmax(0,1fr);
        gap: 6px 12px;
        padding: 16px;
    }
    .quick-logo { grid-column: 1; grid-row: 1; width: 36px; height: 36px; }
    .quick-name { grid-column: 2; grid-row: 1; }
    .quick-code,.quick-field,.quick-card>.badge { grid-column: 2; justify-self: start; }
    .quick-department { grid-column: 1 / -1; margin-top: 6px; padding-top: 10px; }
    .quick-name,.quick-code,.quick-field,.info-grid dd,.qr-caption { overflow-wrap: anywhere; }
    .qr-copy { min-width: 0; width: 100%; }
    .qr-code svg,.qr-code img { max-width: 100%; }
    .primary-button { white-space: normal; text-align: center; }
}

@media(max-width:400px) {
    .header-tools { justify-content: space-between; }
    .brand-title { font-size: .75rem; }
    .quick-card { grid-template-columns: 28px minmax(0,1fr); gap: 6px 10px; padding: 14px; }
    .quick-logo { width: 28px; height: 28px; }
}

/* Giao diện thích ứng: (prefers-reduced-motion:reduce) */

@media(prefers-reduced-motion:reduce) {
    .department:hover,.department:active {
        transform: none;
    }

    * {
        scroll-behavior: auto!important;
        transition: none!important;
        animation: none!important;
    }

}
