/* === Foodaite Tool Page Common Styles (v3 clean corporate) === */
/* Reference: 配料排序检查 page design */

/* --- Reset & Base --- */
:root{
    --blue:#0849df;
    --blue-dark:#073fcb;
    --blue-2:#0b53f0;
    --page:#f4f7fc;
    --card:#ffffff;
    --text:#121d47;
    --muted:#67738f;
    --line:#dce4f2;
    --green:#1a8f60;
    --green-bg:#e9f7ef;
    --blue-pill:#edf4ff;
    --shadow:0 10px 26px rgba(34,66,132,.10);
}

/* --- Background --- */
body {
    background:
        radial-gradient(circle at 10% 20%, rgba(92,136,255,.08), transparent 24%),
        radial-gradient(circle at 88% 8%, rgba(100,127,255,.06), transparent 18%),
        var(--page) !important;
    background-attachment: fixed !important;
    color: var(--text) !important;
    font-family:"Microsoft YaHei","PingFang SC","Noto Sans SC",system-ui,-apple-system,sans-serif !important;
    padding: 0 !important;
}

/* --- Header / Topbar (solid blue bar) --- */
.header {
    max-width: 100% !important;
    width: 100vw !important;
    height: 128px !important;
    min-height: 128px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: linear-gradient(90deg, #054cdb 0%, #0747d6 60%, #0a42ca 100%) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: inset 0 -1px 0 rgba(255,255,255,.08) !important;
    color: #fff !important;
    overflow: visible !important;
    position: relative !important;
    left: 50% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    transform: translateX(-50%) !important;
    box-sizing: border-box !important;
    z-index: 100 !important;
}

/* Header inner content max-width */
.header > * {
    max-width: 1540px;
    margin: 0 auto;
}

/* Header padding for content */
.header h1, .header .back-home, .header > div, .header > p {
    padding-left: 28px !important;
    padding-right: 28px !important;
}

.header h1 {
    color: #fff !important;
    text-shadow: none !important;
    text-align: center !important;
    justify-content: center !important;
    line-height: 1.2 !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    font-size: 28px !important;
    font-weight: 800 !important;
}

.header p {
    color: rgba(255,255,255,.9) !important;
    text-align: center !important;
    font-size: 15px !important;
    opacity: .85 !important;
    line-height: 1.5 !important;
    padding-bottom: 10px !important;
}

/* --- Unified tool header layout --- */
.tool-header-inner {
    position: static;
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
    align-items: center;
    min-height: 128px;
    width: min(100%, 1540px);
    margin: 0 auto;
    padding: 22px 46px !important;
}

.tool-header-left {
    position: absolute;
    top: 0;
    left: 0;
}

.tool-header-center {
    grid-column: 2;
    align-self: center;
    min-width: 0;
    padding: 0 24px;
    text-align: center;
}

.tool-header-right {
    grid-column: 3;
    justify-self: end;
    min-width: 180px;
}

.header-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tool-header-center h1 {
    padding: 0 !important;
    font-size: 28px !important;
    font-weight: 800 !important;
    color: #fff !important;
}

.tool-header-center p {
    margin-top: 10px;
    padding: 0 !important;
    font-size: 15px !important;
    font-weight: 400 !important;
    color: rgba(255,255,255,.9) !important;
}

.header > #foodaiteAuthBar {
    top: 22px !important;
    right: 46px !important;
}

#foodaiteAuthBar > button,
#foodaiteAuthBar #userMenuBtn {
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #fff !important;
    line-height: 1 !important;
}

#foodaiteAuthBar #userMenuBtn {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 6px 14px !important;
    border-radius: 16px !important;
    background: rgba(255,255,255,.25) !important;
    border: 1px solid rgba(255,255,255,.3) !important;
    box-shadow: none !important;
    transform: none !important;
}

.tool-meta-heading-row h1 {
    margin: 0 !important;
}

.header > p {
    margin: 0 !important;
    padding-bottom: 0 !important;
}

#foodaiteAuthBar #userMenuBtn:hover {
    background: rgba(255,255,255,.35) !important;
    box-shadow: none !important;
    transform: none !important;
}

#foodaiteAuthBar > button:not(#userMenuBtn) {
    padding: 8px 20px !important;
    border-radius: 20px !important;
    background: rgba(255,255,255,.25) !important;
    border: 1px solid rgba(255,255,255,.35) !important;
    box-shadow: none !important;
}

#foodaiteAuthBar #userMenuBtn > i {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1 !important;
}

#foodaiteAuthBar #userMenuBtn > .fa-chevron-down {
    width: 10px;
    font-size: 10px !important;
    margin: 0 !important;
}

#userDropdown {
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
}

/* --- Back Home button --- */
.back-home {
    color: #fff !important;
    background: rgba(255,255,255,.10) !important;
    border: 1px solid rgba(255,255,255,.15) !important;
    font-weight: 700 !important;
    padding: 8px 16px !important;
    border-radius: 999px !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 14px !important;
    line-height: 1 !important;
    margin-top: 16px !important;
    margin-left: 28px !important;
}

.back-home:hover {
    background: rgba(255,255,255,.20) !important;
}

.header > .back-home {
    position: absolute !important;
    top: 16px !important;
    left: 28px !important;
    margin: 0 !important;
}

.header > .std-badge {
    position: absolute !important;
    right: 28px !important;
    bottom: 12px !important;
    margin: 0 !important;
}

/* --- Main Container --- */
.main, .container {
    max-width: 1540px !important;
    width: min(1540px, calc(100% - 56px)) !important;
    margin: 18px auto !important;
    padding: 0 !important;
}

/* --- Cards --- */
.card, .calc-box, .result-box {
    background: #fff !important;
    border: 1px solid #e1e7f2 !important;
    border-radius: 20px !important;
    box-shadow: var(--shadow) !important;
    color: var(--text) !important;
}

.card h3, .card h2 {
    color: var(--text) !important;
}

/* --- Buttons --- */
button:not(.tab-btn):not(.batch-delete):not(.btn-sm):not(.tool-step):not(.tool-date-trigger):not(.tool-date-nav):not(.tool-date-day):not(.tool-select-trigger):not(.tool-select-option):not(.tool-button-plain):not(.example-chip):not(:where(.tool-ui .tool-modal .tool-button)):not(:where(.tool-ui .tool-button)) {
    background: linear-gradient(90deg, #0953e7, #0a45dd) !important;
    color: #fff !important;
    box-shadow: 0 8px 18px rgba(14,83,229,.22) !important;
    border: none !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    padding: 12px 18px !important;
    transition: .18s ease !important;
    cursor: pointer !important;
}

button:not(.tab-btn):not(.batch-delete):not(.tool-step):not(.tool-date-trigger):not(.tool-date-nav):not(.tool-date-day):not(.tool-select-trigger):not(.tool-select-option):not(.tool-button-plain):not(.example-chip):not(:where(.tool-ui .tool-modal .tool-button)):not(:where(.tool-ui .tool-button)):hover {
    transform: translateY(-1px);
    opacity: 1 !important;
}

button.secondary {
    background: #fff !important;
    color: #0a50df !important;
    border: 2px solid #0a50df !important;
    box-shadow: none !important;
}

/* --- Tab Buttons --- */
.tab-btn {
    color: #67738f !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 999px !important;
    font-weight: 600 !important;
    transition: all .2s !important;
}

.tab-btn:hover {
    background: var(--blue-pill) !important;
    color: var(--blue-2) !important;
}

.tab-btn.active {
    background: var(--blue) !important;
    color: #fff !important;
    border-color: var(--blue) !important;
    box-shadow: 0 4px 14px rgba(8,73,223,.25) !important;
}

/* --- Shared arrow step navigation --- */
.tool-steps {
    display: grid !important;
    grid-template-columns: repeat(var(--tool-step-count, 3), minmax(0, 1fr));
    align-items: center;
    gap: 24px;
    margin: 0 0 20px;
    padding: 20px 12% !important;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(34,66,132,.08);
}

.tool-step {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 72px;
    gap: 12px;
    padding: 9px 32px 9px 16px !important;
    background: var(--blue) !important;
    color: #12306b !important;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 50%, calc(100% - 20px) 100%, 0 100%);
    border: 0 !important;
    border-radius: 14px 0 0 14px !important;
    box-shadow: none !important;
    cursor: pointer !important;
    position: relative;
    transform: none !important;
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease !important;
}

.tool-step::before {
    content: "";
    position: absolute;
    inset: 2px;
    background: var(--blue-pill);
    clip-path: polygon(0 0, calc(100% - 19px) 0, 100% 50%, calc(100% - 19px) 100%, 0 100%);
    border-radius: 12px 0 0 12px;
    transition: background .18s ease;
}

.tool-step:not(.active)::before { background: #fff; }

.tool-step:hover {
    color: var(--blue) !important;
    box-shadow: 0 6px 14px rgba(8,73,223,.16) !important;
    transform: translateY(-2px) !important;
}

.tool-step:hover::before { background: #e2edff; }

.tool-step.active {
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(8,73,223,.3) !important;
}

.tool-step.active::before { background: var(--blue); }
.tool-step:disabled { cursor: not-allowed !important; opacity: 1 !important; }
body .tool-steps button.tool-step:not(.active) { color: #12306b !important; }
body .tool-steps button.tool-step:hover { color: var(--blue) !important; }
body .tool-steps button.tool-step.active { color: #fff !important; }

.tool-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    color: var(--blue);
    background: #fff;
    border: 2px solid var(--blue);
    border-radius: 50%;
    font-size: 18px;
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.tool-step-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.tool-step-label {
    color: inherit;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
}

.tool-step-description {
    color: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.35;
    white-space: nowrap;
}

.tool-step.active .tool-step-number {
    color: var(--blue);
    background: #fff;
    border-color: #fff;
}

/* --- Boxed step navigation variant --- */
.tool-steps--boxed {
    gap: 24px;
    margin-bottom: 18px;
    padding: 0 !important;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.tool-steps--boxed .tool-step {
    min-height: 72px;
    gap: 12px;
    padding: 9px 16px !important;
    border: 2px solid #0849df !important;
    border-radius: 12px !important;
    background: #eaf2ff !important;
    color: #12306b !important;
    clip-path: none;
}

.tool-steps--boxed .tool-step::before { display: none; }

.tool-steps--boxed .tool-step:hover {
    border-color: var(--blue) !important;
    background: #e2edff !important;
    color: var(--blue) !important;
    transform: translateY(-2px) !important;
}

.tool-steps--boxed .tool-step.active {
    border-color: #0849df !important;
    background: #0849df !important;
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(8,73,223,.3) !important;
}

.tool-steps--boxed .tool-step.active .tool-step-number {
    border-color: #fff;
    background: #fff;
    color: #0849df;
}

/* State selectors intentionally outrank the legacy global button theme. */
body .tool-steps.tool-steps--boxed > .tool-step:not(.active) {
    border: 2px solid #0849df !important;
    background: #eaf2ff !important;
    box-shadow: none !important;
    color: #12306b !important;
}

body .tool-steps.tool-steps--boxed > .tool-step.active {
    border: 2px solid #0849df !important;
    background: #0849df !important;
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(8,73,223,.3) !important;
}

.tool-steps--boxed > .tool-step:focus:not(:focus-visible) {
    outline: none !important;
}

.tool-steps--boxed > .tool-step:focus-visible {
    outline: 2px solid #84adff !important;
    outline-offset: 2px !important;
}

@media (max-width: 760px) {
    .tool-steps {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px 6px !important;
    }

    .tool-step {
        min-height: 70px;
        gap: 10px;
        padding: 9px 34px 9px 16px !important;
    }

    .tool-step-label { font-size: 16px; }
    .tool-step-description { font-size: 12px; white-space: normal; }
    .tool-steps--boxed { padding: 0 !important; }
    .tool-steps--boxed .tool-step { min-height: 72px; padding: 9px 16px !important; }
}

/* --- Inputs --- */
input, select, textarea:not(.tool-composer-input) {
    border: 1.5px solid #bac8e6 !important;
    border-radius: 14px !important;
    color: #263556 !important;
    background: #fff !important;
}

input:focus, select:focus, textarea:focus:not(.tool-composer-input) {
    border-color: #3870f0 !important;
    box-shadow: 0 0 0 4px rgba(43,103,236,.08) !important;
    outline: none !important;
}

/* --- Links --- */
a {
    color: var(--blue-2) !important;
}

a[style*="color:#667eea"], a[style*="color: #667eea"] {
    color: var(--blue-2) !important;
}

/* --- Table --- */
table th {
    background: #f0f3ff !important;
    color: #4a5580 !important;
}

table td {
    color: var(--text) !important;
}

/* --- Result/NRV highlights --- */
.result-box {
    border: 1px solid #abdcc3 !important;
    background: linear-gradient(180deg, #f4fcf7, #f7fcf9) !important;
    border-radius: 13px !important;
}

/* --- Status colors --- */
.status-safe { background: #E8F5E9 !important; color: #2E7D32 !important; }
.status-warn { background: #edf4ff !important; color: #0849df !important; }
.status-danger, .status-expired { background: #FFEBEE !important; color: #C62828 !important; }

/* --- Footer --- */
footer, .page-footer, .footer {
    color: #98a2b3 !important;
    text-align: center !important;
    padding: 24px 8px 0 !important;
    margin-top: 0 !important;
    margin-bottom: max(20px, env(safe-area-inset-bottom)) !important;
    text-shadow: none !important;
    font-size: .8rem !important;
    line-height: 1.5 !important;
}

footer a, .page-footer a, .footer a {
    color: #98a2b3 !important;
}

/* --- Small buttons --- */
.btn-sm {
    padding: 6px 14px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
}

/* --- Warning text --- */
.warning-text { color: #b45309 !important; }

/* --- Free badge --- */
.badge-free, .free-tag {
    background: var(--green-bg) !important;
    color: var(--green) !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    padding: 4px 12px !important;
    border-radius: 999px !important;
}

/* --- Responsive --- */
@media (max-width: 720px) {
    .header h1 { font-size: 22px !important; padding-left: 16px !important; padding-right: 16px !important; }
    .main, .container { width: calc(100% - 24px) !important; }
    .header { height: 154px !important; min-height: 154px !important; }
    .header > .back-home { top: 12px !important; left: 16px !important; margin: 0 !important; }
    .header > .std-badge { right: 16px !important; bottom: 10px !important; }
    .header .tool-header-left .back-home { margin-top: 12px !important; margin-left: 16px !important; margin-bottom: 8px !important; }
    .tool-header-inner { grid-template-columns: 1fr; min-height: 154px; padding: 62px 18px 20px !important; }
    .tool-header-center { grid-column: 1; padding: 0; }
    .tool-header-right { display: none; }
    .tool-header-center h1 { font-size: 1.35rem !important; padding: 0 !important; }
    .tool-header > #foodaiteAuthBar { top: 18px !important; right: 18px !important; }
}

.back-home i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin: 0 !important;
    font-size: 13px;
    line-height: 1 !important;
}

/* --- Shared tool version, history and contributors --- */
.tool-meta-heading-row {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    flex-wrap: wrap !important;
    margin-bottom: 8px !important;
}

.header > .tool-meta-heading-row {
    padding-left: 28px !important;
    padding-right: 28px !important;
}

.tool-meta-heading-row > h1 {
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.tool-meta-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tool-version {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 10px;
    border: 1px solid rgba(255,255,255,.32);
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

button.update-history-button {
    min-height: 38px !important;
    padding: 7px 16px !important;
    border: 1px solid rgba(255,255,255,.5) !important;
    border-radius: 10px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    font-size: 13px !important;
}

button.update-history-button:hover {
    background: rgba(255,255,255,.12) !important;
    transform: none !important;
}

.update-history-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15,23,42,.5);
}

.update-history-modal.show {
    display: flex;
}

.update-history-dialog {
    width: min(520px,100%);
    max-height: min(640px,80vh);
    overflow: auto;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15,23,42,.25);
}

.update-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid #eaecf0;
}

.update-history-header h2 {
    color: #1f2937;
    font-size: 1rem;
}

button.update-history-close {
    position: relative;
    display: block !important;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    min-height: 32px !important;
    padding: 0 !important;
    border: 1px solid #e4e7ec !important;
    border-radius: 8px !important;
    outline: none !important;
    background: #f8fafc !important;
    box-shadow: none !important;
    color: #667085 !important;
    font-size: 0 !important;
}

.update-history-close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    transform: translate(-50%,-50%);
}

button.update-history-close:hover,
button.update-history-close:active {
    background: #eaecf0 !important;
    box-shadow: none !important;
    transform: none !important;
}

.update-history-close:focus-visible {
    outline: 2px solid #84adff !important;
    outline-offset: 2px !important;
}

.update-history-body {
    padding: 18px 20px;
    color: #475467;
    font-size: .88rem;
}

.update-history-item {
    display: grid;
    grid-template-columns: 72px 96px 1fr;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f2f5;
}

.update-history-item:last-child {
    border-bottom: 0;
}

.tool-meta {
    width: min(1280px,calc(100% - 56px));
    margin: 28px auto 0;
    padding: 34px 0 12px;
    color: #667085;
    font-family:"Microsoft YaHei","PingFang SC","Noto Sans SC",system-ui,-apple-system,sans-serif !important;
    line-height: 1.5;
}

.tool-meta-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    color: #17213b;
    font-size: 1.08rem;
    font-weight: 750;
    line-height: 26px;
}

.tool-meta-title::before {
    width: 5px;
    height: 26px;
    border-radius: 3px;
    background: #1261f3;
    content: "";
}

.contributor-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.contributor-intro {
    margin: 0;
    color: #7d89a3;
    font-size: .82rem;
    line-height: 26px;
}

.contributor-list {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(300px,1fr));
    gap: 12px;
}

.contributor-card {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 74px;
    padding: 14px 16px;
    border: 1px solid #dfe6f2;
    border-radius: 12px;
    background: rgba(255,255,255,.82);
    box-shadow: 0 5px 14px rgba(39,72,130,.07);
}

.contributor-icon {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #edf3ff;
    color: #1261f3;
    font-size: 1.1rem;
}

.contributor-copy {
    min-width: 0;
}

.contributor-badge {
    position: absolute;
    top: 10px;
    right: -40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 112px;
    padding: 4px 0;
    transform: rotate(45deg);
    background: linear-gradient(90deg, #0953e7, #1261f3);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.35;
    pointer-events: none;
}

.tool-meta-content {
    margin-bottom: 2px;
    color: #344054;
    font-size: .9rem;
    white-space: nowrap;
}

.contributor-invite {
    color: #7d89a3;
    font-size: .76rem;
    line-height: 1.45;
}

@media (min-width: 721px) and (max-width: 900px) {
    .header {
        height: 176px !important;
        min-height: 176px !important;
    }

    .header > .tool-meta-heading-row {
        margin-top: 48px !important;
        margin-bottom: 4px !important;
    }
}

@media (max-width: 720px) {
    .header {
        height: auto !important;
        padding-bottom: 16px !important;
    }

    .header:has(> .tool-header-inner) {
        padding-bottom: 0 !important;
    }

    .tool-meta-heading-row {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .header > .tool-meta-heading-row {
        margin-top: 48px !important;
        margin-bottom: 4px !important;
    }

    .tool-meta {
        width: calc(100% - 36px);
        padding-top: 24px;
    }

    .contributor-list {
        grid-template-columns: 1fr;
    }

    .contributor-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .contributor-intro {
        line-height: 1.6;
    }

    .update-history-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

@media print {
    .tool-meta-actions,
    .tool-meta,
    .update-history-modal {
        display: none !important;
    }
}
