/*
 * 定额相关页面的统一 Tailwind 兼容层。
 * 覆盖 dinge-index.html、dinge-jx.html、jk-area.html 和 xz-area.html；
 * 常规布局与视觉样式使用 Tailwind，此处保留动态旧结构、富文本和复杂状态选择器。
 */

/* 旧详情渲染器输出的备注 HTML 无法在构建期附加 Tailwind 工具类。 */
.remark-content table {
    width: 100%;
    margin: 8px 0;
    border-collapse: collapse;
}

.remark-content table,
.remark-content th,
.remark-content td {
    border: 1px solid #d1d5db;
}

.remark-content th,
.remark-content td {
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}

.remark-content th {
    background-color: #f9fafb;
    font-weight: 600;
}

.remark-content tr:nth-child(even) {
    background-color: #f9fafb;
}

.remark-content tr:hover {
    background-color: #f3f4f6;
}

body.dinge-index-page {
    background:
        radial-gradient(circle at 9% 18%, rgba(13, 148, 136, 0.08), transparent 24rem),
        radial-gradient(circle at 92% 11%, rgba(245, 158, 11, 0.06), transparent 22rem),
        #f3f4f6;
}

body.dinge-index-page::before {
    position: fixed;
    inset: 64px 0 auto;
    height: 240px;
    z-index: -1;
    content: "";
    pointer-events: none;
    background-image:
        linear-gradient(rgba(13, 148, 136, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(13, 148, 136, 0.025) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(to bottom, black, transparent);
}

/* 深色导航中的灰色文字需要达到 WCAG AA 对比度。 */
.dinge-main-nav .text-gray-400 {
    color: #d1d5db !important;
}

/* Shared navigation for all quota pages. */
.dinge-main-nav .container {
    gap: 16px;
}

.dinge-nav-left {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
}

.dinge-main-nav .site-logo-name {
    flex: none;
}

.dinge-main-nav .site-logo-name a {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.dinge-main-nav #navbar-menu-tools-component {
    flex: none;
}

.dinge-main-nav #navbar-menu-dinge-component {
    flex: none;
    margin-left: 34px;
}

.dinge-quota-menu-trigger {
    display: inline-flex;
    height: 64px;
    align-items: center;
    border: 0;
    background: transparent;
    color: #d1d5db;
    cursor: pointer;
    font-size: 1rem;
    transition: color 160ms ease;
}

.dinge-quota-menu:hover .dinge-quota-menu-trigger,
.dinge-quota-menu:focus-within .dinge-quota-menu-trigger {
    color: #ffffff;
}

.dinge-quota-menu-trigger:focus-visible {
    border-radius: 3px;
    outline: 2px solid #60a5fa;
    outline-offset: -4px;
}

.dinge-quota-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 30;
    display: none;
    width: 224px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-top: 0;
    border-radius: 0 0 8px 8px;
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

.dinge-quota-menu:hover .dinge-quota-menu-dropdown,
.dinge-quota-menu:focus-within .dinge-quota-menu-dropdown {
    display: block;
}

.dinge-quota-menu-option {
    display: block;
    padding: 10px 16px;
    color: #374151;
    font-size: 0.875rem;
    line-height: 1.35;
    transition: background-color 140ms ease, color 140ms ease;
}

.dinge-quota-menu-option:hover,
.dinge-quota-menu-option:focus-visible {
    background: #f3f4f6;
    color: #111827;
    outline: none;
}

.dinge-quota-menu-option.is-active {
    background: #ecfdf5;
    color: #047857;
    font-weight: 600;
}

/* 结果列表使用 table 语义，但视觉上按卡片流布局。 */
.quota-list-table,
.quota-list-table tbody,
.quota-list-table tr,
.quota-list-table td {
    display: block;
    width: 100%;
}

.quota-list-table {
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
}

/* Shared layout primitives used by all four quota pages. */
.quota-page-shell {
    width: calc(100% - 32px);
    max-width: 1540px;
    margin-inline: auto;
    padding-top: 88px;
    padding-bottom: 34px;
}

.quota-page-intro {
    display: flex;
    min-height: 92px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    padding: 0 4px 20px;
}

.quota-workspace {
    display: grid;
    align-items: stretch;
    gap: 20px;
}

.quota-lookup-panel,
.quota-detail-panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #d1d5db;
    border-radius: 18px;
    background: #ffffff;
}

.quota-lookup-panel {
    display: flex;
    flex-direction: column;
}

.quota-detail-panel {
    display: flex;
    height: auto;
    align-self: flex-start;
    flex-direction: column;
}

.guest-preview-note {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin: 11px 16px 0;
    border: 1px solid #fde68a;
    border-radius: 12px;
    background:
        linear-gradient(135deg, rgba(255, 251, 235, 0.99), rgba(254, 243, 199, 0.82));
    padding: 10px 11px;
    color: #92400e;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.guest-preview-note[hidden] {
    display: none;
}

.guest-preview-icon {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: #fde68a;
    color: #b45309;
    font-size: 0.75rem;
}

.guest-preview-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
    font-size: 0.69rem;
    line-height: 1.45;
}

.guest-preview-copy strong {
    color: #78350f;
    font-size: 0.73rem;
    font-weight: 800;
}

.guest-preview-copy span {
    color: #92400e;
}

.guest-preview-login {
    flex: none;
    border: 1px solid #fbbf24;
    border-radius: 999px;
    background: #fbbf24;
    padding: 7px 10px;
    color: #451a03;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.guest-preview-login:hover {
    border-color: #f59e0b;
    background: #f59e0b;
    box-shadow: 0 5px 12px rgba(217, 119, 6, 0.2);
    transform: translateY(-1px);
}

.guest-preview-login:focus-visible {
    outline: 2px solid rgba(245, 158, 11, 0.45);
    outline-offset: 2px;
}

.compact-search-button {
    position: relative;
}

.compact-search-button.is-login-gated::after {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 999px;
    background: #f59e0b;
    color: #ffffff;
    content: "\f023";
    font-family: "Font Awesome 6 Free";
    font-size: 5px;
    font-weight: 900;
    line-height: 10px;
    text-align: center;
}

.lookup-tab[aria-selected="false"] {
    color: #4b5563 !important;
}

#result-range-text {
    color: #6b7280 !important;
}

.quota-result-item.is-active {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
}

.quota-result-item.is-active .quota-result-arrow {
    background: #3b82f6 !important;
    color: #ffffff !important;
    transform: translateX(2px);
}

.quota-result-item.is-active .quota-result-content {
    color: #4b5563 !important;
}

.mobile-back-to-results {
    display: none;
    width: 100%;
    align-items: center;
    gap: 8px;
    border: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #f0fdfa;
    padding: 9px 17px;
    color: #115e59;
    font-size: 0.78rem;
    font-weight: 800;
    text-align: left;
}

.mobile-back-to-results:focus-visible {
    outline: 2px solid rgba(13, 148, 136, 0.3);
    outline-offset: 2px;
}

.detail-panel-header {
    position: relative;
    z-index: 4;
    flex: none;
    border-bottom: 1px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 24px 16px;
}

.quota-detail-title {
    min-width: 0;
    margin: 0;
    color: #111827;
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.375;
}

.quota-detail-title-accent {
    color: #0f766e;
}

.quota-detail-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.quota-metrics {
    display: inline-flex;
    flex: none;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    background: #f9fafb;
    color: #4b5563;
    font-size: 0.68rem;
}

.quota-metrics--compact {
    margin-left: auto;
}

.quota-metric {
    padding: 7px 10px;
}

.quota-metric + .quota-metric {
    border-left: 1px solid #e5e7eb;
}

.quota-metric strong {
    margin-right: 4px;
    font-weight: 800;
}

.quota-detail-switcher {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.quota-detail-switcher-label {
    flex: none;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 700;
}

.quota-detail-switcher-options {
    display: flex;
    min-width: 0;
    flex: 1 1 0%;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.quota-detail-body {
    min-height: 0;
    flex: none;
    overflow: visible;
    padding: 20px 22px 26px;
}

.quota-table-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    column-gap: 20px;
    row-gap: 4px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    padding: 10px 20px;
}

.quota-table-title {
    flex: none;
    margin: 0;
    color: #374151;
    font-size: 1rem;
    font-weight: 500;
}

.quota-table-caption {
    margin: 0 0 0 auto;
    color: #6b7280;
    font-size: 0.75rem;
    line-height: 1.25rem;
    text-align: right;
}

.quota-results-scroll {
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-width: thin;
}

.quota-results-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.quota-results-scroll::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: #cbd5e1;
    background-clip: padding-box;
}

.quota-results-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* Shared heading for the regional price tables in jk-area.html and xz-area.html. */
@media (max-width: 520px) {
    .quota-table-heading {
        flex-direction: column;
        align-items: flex-start;
        row-gap: 0.25rem;
    }

    .quota-table-caption {
        width: 100%;
        margin-left: 0;
        text-align: left;
    }
}

/* 动态详情渲染器输出的红色强调类需要覆盖旧版颜色。 */
.detail-page-info .text-red-500,
.quota-details-table td .text-red-500,
.quota-details-table td.text-red-500 {
    color: #ef4444 !important;
}

/* 旧详情渲染器生成的结构仍使用公共类，需要在新页面内做作用域适配。 */
.quota-details-table > .space-y-6 {
    display: grid;
    gap: 18px;
}

.quota-details-table > .space-y-6 > * {
    margin: 0 !important;
}

.quota-details-table .bg-white.rounded-lg.shadow {
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: 13px;
    box-shadow: none !important;
}

.quota-details-table .bg-gray-50.border-b {
    border-color: #e5e7eb !important;
    background: #f9fafb !important;
}

.quota-details-table h3 {
    color: #4b5563 !important;
}

.quota-details-table h3 .text-red-500 {
    color: #ef4444 !important;
    font-weight: 800;
}

.quota-detail-project-title {
    font-size: 0.9375rem;
    line-height: 1.375rem;
}

.quota-details-table table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate !important;
    border-spacing: 0;
}

.quota-details-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f9fafb !important;
}

.quota-details-table th {
    color: #4b5563 !important;
    font-size: 0.82rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.02em !important;
    text-transform: none !important;
}

.quota-details-table td {
    color: #374151 !important;
    font-size: 0.82rem !important;
}

.quota-details-table th:first-child,
.quota-details-table td:first-child {
    width: 55%;
}

.quota-details-table th:nth-child(2),
.quota-details-table td:nth-child(2),
.quota-details-table th:nth-child(3),
.quota-details-table td:nth-child(3),
.quota-details-table th:nth-child(4),
.quota-details-table td:nth-child(4) {
    width: 15%;
}

.quota-details-table tbody tr:hover {
    background: #eff6ff !important;
}

.quota-details-table .jx-btn {
    background: #ef4444 !important;
    box-shadow: none;
}

/* JSON 备注是原始 HTML，无法在构建期直接附加 Tailwind 工具类。 */
.remark-content {
    line-height: 1.4 !important;
}

.quota-details-table .remark-content table {
    width: 100% !important;
    max-width: 100%;
    table-layout: fixed;
}

.quota-details-table .remark-content td {
    width: auto !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.quota-details-table .remark-content td:first-child {
    width: 22% !important;
}

.quota-details-table .bg-white.rounded-lg.shadow:has(.remark-content) {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent !important;
}

.quota-details-table .bg-white.rounded-lg.shadow:has(.remark-content) > .bg-gray-50.border-b {
    padding: 2px 2px 0 !important;
    border: 0 !important;
    background: transparent !important;
}

@media (min-width: 768px) {
    .quota-detail-title {
        font-size: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .quota-detail-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 1180px) {
    .dinge-main-nav .site-logo-name {
        display: none !important;
    }

    .dinge-main-nav .navbar-tools-menu {
        margin-left: 0;
    }

    .dinge-main-nav #navbar-menu-dinge-component {
        margin-left: 28px;
    }

    .quota-page-shell {
        width: calc(100% - 28px);
    }

    .quota-workspace {
        gap: 14px;
    }
}

@media (max-width: 1023px) {
    .quota-page-shell {
        width: calc(100% - 24px);
        max-width: 780px;
        padding-top: 82px;
    }

    .quota-page-intro {
        min-height: 0;
        padding-bottom: 15px;
    }

    .quota-workspace {
        display: block;
    }

    .quota-lookup-panel {
        width: 100%;
        height: auto;
        min-height: 650px;
    }

    .quota-detail-panel {
        display: none;
        width: 100%;
        min-height: 650px;
    }

    .mobile-back-to-results {
        min-height: 45px;
    }

    .detail-panel-header {
        position: sticky;
    }

    .detail-panel-header--query {
        top: 64px;
    }

    .detail-panel-header--region {
        top: 45px;
    }

    .quota-workspace.mobile-detail-open .quota-lookup-panel {
        display: none;
    }

    .quota-workspace.mobile-detail-open .quota-detail-panel {
        display: flex;
    }

    .quota-workspace.mobile-detail-open .mobile-back-to-results {
        display: flex;
    }

}

@media (max-width: 767px) {
    .quota-page-shell {
        width: calc(100% - 18px);
        padding-top: 72px;
        padding-bottom: 22px;
    }

    .quota-page-intro {
        padding-right: 5px;
        padding-bottom: 13px;
        padding-left: 5px;
    }

    .quota-lookup-panel,
    .quota-detail-panel {
        min-height: 590px;
        border-radius: 15px;
    }

    .guest-preview-note {
        grid-template-columns: auto minmax(0, 1fr);
        margin-right: 12px;
        margin-left: 12px;
    }

    .guest-preview-login {
        grid-column: 1 / -1;
        width: 100%;
        min-height: 34px;
    }

    .detail-panel-header {
        padding: 8px 14px 13px;
    }

    .detail-panel-header--query {
        top: 58px;
    }

    .detail-panel-header--region {
        padding-top: 16px;
    }

    .quota-detail-heading-row {
        flex-wrap: wrap;
        gap: 12px;
    }

    .quota-metrics--overview {
        width: 100%;
    }

    .quota-metrics--overview .quota-metric {
        flex: 1 1 0%;
        text-align: center;
    }

    .quota-detail-switcher-label {
        display: none;
    }

    .quota-detail-switcher-options {
        justify-content: flex-start;
    }

    .quota-detail-body {
        padding: 16px 10px 20px;
    }

    .quota-table-heading {
        padding: 9px 12px;
    }

    .dinge-main-nav .container {
        height: 58px;
    }

    body.dinge-index-page::before {
        inset-block-start: 58px;
    }

    .dinge-main-nav .site-logo-name {
        display: none !important;
    }

    .dinge-main-nav .nav-menu {
        display: block;
    }

    .dinge-main-nav .container {
        gap: 10px;
        padding-right: 10px;
        padding-left: 10px;
    }

    .dinge-main-nav .navbar-tools-menu {
        margin-left: 0;
    }

    .dinge-main-nav .navbar-tools-menu ul {
        gap: 16px;
    }

    .dinge-main-nav .navbar-tools-menu ul > * + * {
        margin-left: 0 !important;
    }

    .dinge-main-nav #navbar-menu-dinge-component {
        margin-left: 16px;
    }

    .dinge-quota-menu-trigger {
        height: 58px;
        font-size: 0.875rem;
    }

    .dinge-quota-menu-dropdown {
        width: 208px;
    }

    .quota-details-table .bg-gray-50.border-b {
        padding: 12px !important;
    }

    .quota-details-table th,
    .quota-details-table td {
        padding-left: 8px !important;
        padding-right: 8px !important;
        font-size: 0.76rem !important;
    }

    .quota-details-table th:first-child,
    .quota-details-table td:first-child {
        width: 50%;
    }

    .quota-details-table th:nth-child(2),
    .quota-details-table td:nth-child(2) {
        width: 14%;
    }

    .quota-details-table th:nth-child(3),
    .quota-details-table td:nth-child(3) {
        width: 16%;
    }

    .quota-details-table th:nth-child(4),
    .quota-details-table td:nth-child(4) {
        width: 20%;
    }

    .quota-details-table td:nth-child(4) span {
        white-space: nowrap;
    }
}

/* dinge-jx.html：机械定额动态表格。 */
.machine-details-table table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

.machine-details-table th,
.machine-details-table td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.machine-details-table th:first-child,
.machine-details-table td:first-child {
    width: 58%;
}

.machine-details-table th:nth-child(2),
.machine-details-table td:nth-child(2) {
    width: 18%;
}

.machine-details-table th:nth-child(3),
.machine-details-table td:nth-child(3) {
    width: 24%;
}

/* 地区查询页：隐藏浏览器原生清除按钮，统一使用页面内按钮。 */
#district-search-input::-webkit-search-cancel-button,
#xz-search-input::-webkit-search-cancel-button {
    display: none;
    appearance: none;
    -webkit-appearance: none;
}

#district-search-input::-ms-clear,
#district-search-input::-ms-reveal,
#xz-search-input::-ms-clear,
#xz-search-input::-ms-reveal {
    display: none;
    width: 0;
    height: 0;
}

/* jk-area.html：地图和动态类别按钮。 */
.area-map,
.area-map > div,
.area-map canvas,
.area-map svg {
    max-width: 100%;
}

.area-category-button[data-level="1"] {
    --area-category-color: #60a5fa;
    --area-category-border: #3b82f6;
    --area-category-hover: #3b82f6;
}

.area-category-button[data-level="2"],
.xz-category-button[data-level="2"] {
    --area-category-color: #22c55e;
    --area-category-border: #16a34a;
    --area-category-hover: #16a34a;
}

.area-category-button[data-level="3"],
.xz-category-button[data-level="3"] {
    --area-category-color: #facc15;
    --area-category-border: #eab308;
    --area-category-hover: #eab308;
}

.area-category-button[data-level="4"],
.xz-category-button[data-level="4"] {
    --area-category-color: #fb923c;
    --area-category-border: #f97316;
    --area-category-hover: #f97316;
}

.area-category-button[data-level="5"] {
    --area-category-color: #2dd4bf;
    --area-category-border: #14b8a6;
    --area-category-hover: #14b8a6;
}

.area-category-button[data-level="6"] {
    --area-category-color: #c084fc;
    --area-category-border: #a855f7;
    --area-category-hover: #a855f7;
}

.area-category-button.is-active,
.xz-category-button.is-active {
    border-color: var(--area-category-border);
    background: var(--area-category-color);
    color: #ffffff;
    font-weight: 700;
}

.area-category-button.is-active:hover,
.xz-category-button.is-active:hover {
    border-color: var(--area-category-hover);
    background: var(--area-category-hover);
}

.area-category-button.is-active span,
.xz-category-button.is-active span {
    color: #ffffff;
}

.area-category-button:not(:disabled):not(.is-active):hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.area-province-button.is-active {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
}

.area-province-button.is-active .text-gray-500 {
    color: #4b5563;
}

.xz-category-button:not(:disabled):not(.is-active):hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

@media (max-width: 767px) {
    .machine-details-table th,
    .machine-details-table td {
        padding-right: 8px !important;
        padding-left: 8px !important;
        font-size: 0.76rem !important;
    }

    .machine-details-table th:first-child,
    .machine-details-table td:first-child {
        width: 54%;
    }

    .machine-details-table th:nth-child(3),
    .machine-details-table td:nth-child(3) {
        width: 28%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
