/* ============================================================
   花键塞规 / 环规 计算器 - 现代简约设计系统
   ------------------------------------------------------------
   设计风格: Notion / Linear 风格
   主色调  : 工业蓝灰 (#2C5282)
   圆角    : 12-16px 卡片 / 8-10px 按钮
   阴影    : 柔和分层
   动画    : 微动效，统一 var(--t-base)
   适配    : 桌面 1024+ / 平板 768-1023 / 移动 <768
   ============================================================ */


/* ============================================================
   1. 设计 Tokens (CSS 变量)
   ============================================================ */
:root {
    /* ---------- 主色调 工业蓝灰系 ---------- */
    --primary: #2C5282;
    --primary-dark: #1E3A5F;
    --primary-light: #3B82F6;
    --primary-50: #EFF6FF;
    --primary-100: #DBEAFE;
    --primary-200: #BFDBFE;
    --primary-500: #3B82F6;
    --primary-600: #2563EB;
    --primary-700: #1D4ED8;

    /* ---------- 通端 / 止端 / 校对 ---------- */
    --go: #059669;
    --go-dark: #047857;
    --go-bg: #ECFDF5;
    --go-border: #A7F3D0;
    --stop: #DC2626;
    --stop-dark: #B91C1C;
    --stop-bg: #FEF2F2;
    --stop-border: #FECACA;
    --jc: #7C3AED;
    --jc-dark: #6D28D9;
    --jc-bg: #F5F3FF;
    --jc-border: #DDD6FE;

    /* ---------- 中性色 ---------- */
    --bg-page: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-input: #F8FAFC;
    --bg-input-hover: #F1F5F9;
    --bg-elevated: #FFFFFF;
    --bg-overlay: rgba(15, 23, 42, 0.45);

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    --text-disabled: #CBD5E1;
    --text-inverse: #FFFFFF;

    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --border-focus: #3B82F6;

    --divider: #F1F5F9;

    /* ---------- 状态色 ---------- */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;

    /* ---------- 圆角 ---------- */
    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 18px;
    --r-2xl: 22px;
    --r-full: 9999px;

    /* ---------- 阴影 (柔和分层) ---------- */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(15, 23, 42, 0.18);
    --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.18);
    --shadow-focus-primary: 0 0 0 3px rgba(44, 82, 130, 0.18);
    --shadow-inner: inset 0 1px 2px rgba(15, 23, 42, 0.04);

    /* ---------- 间距 (8 点网格) ---------- */
    --s-0: 0;
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-7: 28px;
    --s-8: 32px;
    --s-10: 40px;
    --s-12: 48px;
    --s-16: 64px;

    /* ---------- 字号 ---------- */
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 15px;
    --fs-lg: 17px;
    --fs-xl: 20px;
    --fs-2xl: 24px;
    --fs-3xl: 30px;
    --fs-4xl: 36px;

    /* ---------- 行高 ---------- */
    --lh-tight: 1.2;
    --lh-base: 1.5;
    --lh-relaxed: 1.65;

    /* ---------- 字重 ---------- */
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* ---------- 过渡 ---------- */
    --t-fast: 120ms ease;
    --t-base: 200ms ease;
    --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-spring: 380ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ---------- 层级 ---------- */
    --z-base: 1;
    --z-dropdown: 10;
    --z-sticky: 50;
    --z-fixed: 100;
    --z-modal: 1000;
    --z-toast: 2000;

    /* ---------- 容器尺寸 ---------- */
    --container-max: 1440px;
    --sidebar-width: 380px;
}


/* ============================================================
   2. Reset & Base
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
        sans-serif;
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* 背景装饰齿轮 */
body::before,
body::after {
    content: '';
    position: fixed;
    pointer-events: none;
    z-index: 0;
    opacity: 0.06;
    background-repeat: no-repeat;
    background-size: contain;
}

body::before {
    width: 420px;
    height: 420px;
    top: -120px;
    right: -120px;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20100%20100%27%20fill%3D%27none%27%20stroke%3D%27%25232C5282%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%0A%3Cpath%20d%3D%27M84.68%2C45.28%20L94.92%2C47.25%20A45%2C45%200%200%2C1%2094.92%2C52.75%20L84.68%2C54.72%20A35%2C35%200%200%2C1%2083.85%2C58.91%20L83.85%2C58.91%20L92.55%2C64.65%20A45%2C45%200%200%2C1%2090.45%2C69.73%20L80.23%2C67.63%20A35%2C35%200%200%2C1%2077.86%2C71.19%20L77.86%2C71.19%20L83.70%2C79.82%20A45%2C45%200%200%2C1%2079.82%2C83.70%20L71.19%2C77.86%20A35%2C35%200%200%2C1%2067.63%2C80.23%20L67.63%2C80.23%20L69.73%2C90.45%20A45%2C45%200%200%2C1%2064.65%2C92.55%20L58.91%2C83.85%20A35%2C35%200%200%2C1%2054.72%2C84.68%20L54.72%2C84.68%20L52.75%2C94.92%20A45%2C45%200%200%2C1%2047.25%2C94.92%20L45.28%2C84.68%20A35%2C35%200%200%2C1%2041.09%2C83.85%20L41.09%2C83.85%20L35.35%2C92.55%20A45%2C45%200%200%2C1%2030.27%2C90.45%20L32.37%2C80.23%20A35%2C35%200%200%2C1%2028.81%2C77.86%20L28.81%2C77.86%20L20.18%2C83.70%20A45%2C45%200%200%2C1%2016.30%2C79.82%20L22.14%2C71.19%20A35%2C35%200%200%2C1%2019.77%2C67.63%20L19.77%2C67.63%20L9.55%2C69.73%20A45%2C45%200%200%2C1%207.45%2C64.65%20L16.15%2C58.91%20A35%2C35%200%200%2C1%2015.32%2C54.72%20L15.32%2C54.72%20L5.08%2C52.75%20A45%2C45%200%200%2C1%205.08%2C47.25%20L15.32%2C45.28%20A35%2C35%200%200%2C1%2016.15%2C41.09%20L16.15%2C41.09%20L7.45%2C35.35%20A45%2C45%200%200%2C1%209.55%2C30.27%20L19.77%2C32.37%20A35%2C35%200%200%2C1%2022.14%2C28.81%20L22.14%2C28.81%20L16.30%2C20.18%20A45%2C45%200%200%2C1%2020.18%2C16.30%20L28.81%2C22.14%20A35%2C35%200%200%2C1%2032.37%2C19.77%20L32.37%2C19.77%20L30.27%2C9.55%20A45%2C45%200%200%2C1%2035.35%2C7.45%20L41.09%2C16.15%20A35%2C35%200%200%2C1%2045.28%2C15.32%20L45.28%2C15.32%20L47.25%2C5.08%20A45%2C45%200%200%2C1%2052.75%2C5.08%20L54.72%2C15.32%20A35%2C35%200%200%2C1%2058.91%2C16.15%20L58.91%2C16.15%20L64.65%2C7.45%20A45%2C45%200%200%2C1%2069.73%2C9.55%20L67.63%2C19.77%20A35%2C35%200%200%2C1%2071.19%2C22.14%20L71.19%2C22.14%20L79.82%2C16.30%20A45%2C45%200%200%2C1%2083.70%2C20.18%20L77.86%2C28.81%20A35%2C35%200%200%2C1%2080.23%2C32.37%20L80.23%2C32.37%20L90.45%2C30.27%20A45%2C45%200%200%2C1%2092.55%2C35.35%20L83.85%2C41.09%20A35%2C35%200%200%2C1%2084.68%2C45.28%20Z%27%2F%3E%0A%3Ccircle%20cx%3D%2750%27%20cy%3D%2750%27%20r%3D%2720%27%2F%3E%0A%3Ccircle%20cx%3D%2750%27%20cy%3D%2750%27%20r%3D%2710%27%2F%3E%0A%3Cpath%20d%3D%27M50%2030V18M50%2082v-12M18%2050h12M82%2050h-12%27%20stroke-width%3D%272.5%27%2F%3E%0A%3C%2Fsvg%3E");
    animation: gearSpin 60s linear infinite;
}

body::after {
    width: 320px;
    height: 320px;
    bottom: -80px;
    left: -80px;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20100%20100%27%20fill%3D%27none%27%20stroke%3D%27%25232C5282%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%0A%3Cpath%20d%3D%27M84.68%2C45.28%20L94.92%2C47.25%20A45%2C45%200%200%2C1%2094.92%2C52.75%20L84.68%2C54.72%20A35%2C35%200%200%2C1%2083.85%2C58.91%20L83.85%2C58.91%20L92.55%2C64.65%20A45%2C45%200%200%2C1%2090.45%2C69.73%20L80.23%2C67.63%20A35%2C35%200%200%2C1%2077.86%2C71.19%20L77.86%2C71.19%20L83.70%2C79.82%20A45%2C45%200%200%2C1%2079.82%2C83.70%20L71.19%2C77.86%20A35%2C35%200%200%2C1%2067.63%2C80.23%20L67.63%2C80.23%20L69.73%2C90.45%20A45%2C45%200%200%2C1%2064.65%2C92.55%20L58.91%2C83.85%20A35%2C35%200%200%2C1%2054.72%2C84.68%20L54.72%2C84.68%20L52.75%2C94.92%20A45%2C45%200%200%2C1%2047.25%2C94.92%20L45.28%2C84.68%20A35%2C35%200%200%2C1%2041.09%2C83.85%20L41.09%2C83.85%20L35.35%2C92.55%20A45%2C45%200%200%2C1%2030.27%2C90.45%20L32.37%2C80.23%20A35%2C35%200%200%2C1%2028.81%2C77.86%20L28.81%2C77.86%20L20.18%2C83.70%20A45%2C45%200%200%2C1%2016.30%2C79.82%20L22.14%2C71.19%20A35%2C35%200%200%2C1%2019.77%2C67.63%20L19.77%2C67.63%20L9.55%2C69.73%20A45%2C45%200%200%2C1%207.45%2C64.65%20L16.15%2C58.91%20A35%2C35%200%200%2C1%2015.32%2C54.72%20L15.32%2C54.72%20L5.08%2C52.75%20A45%2C45%200%200%2C1%205.08%2C47.25%20L15.32%2C45.28%20A35%2C35%200%200%2C1%2016.15%2C41.09%20L16.15%2C41.09%20L7.45%2C35.35%20A45%2C45%200%200%2C1%209.55%2C30.27%20L19.77%2C32.37%20A35%2C35%200%200%2C1%2022.14%2C28.81%20L22.14%2C28.81%20L16.30%2C20.18%20A45%2C45%200%200%2C1%2020.18%2C16.30%20L28.81%2C22.14%20A35%2C35%200%200%2C1%2032.37%2C19.77%20L32.37%2C19.77%20L30.27%2C9.55%20A45%2C45%200%200%2C1%2035.35%2C7.45%20L41.09%2C16.15%20A35%2C35%200%200%2C1%2045.28%2C15.32%20L45.28%2C15.32%20L47.25%2C5.08%20A45%2C45%200%200%2C1%2052.75%2C5.08%20L54.72%2C15.32%20A35%2C35%200%200%2C1%2058.91%2C16.15%20L58.91%2C16.15%20L64.65%2C7.45%20A45%2C45%200%200%2C1%2069.73%2C9.55%20L67.63%2C19.77%20A35%2C35%200%200%2C1%2071.19%2C22.14%20L71.19%2C22.14%20L79.82%2C16.30%20A45%2C45%200%200%2C1%2083.70%2C20.18%20L77.86%2C28.81%20A35%2C35%200%200%2C1%2080.23%2C32.37%20L80.23%2C32.37%20L90.45%2C30.27%20A45%2C45%200%200%2C1%2092.55%2C35.35%20L83.85%2C41.09%20A35%2C35%200%200%2C1%2084.68%2C45.28%20Z%27%2F%3E%0A%3Ccircle%20cx%3D%2750%27%20cy%3D%2750%27%20r%3D%2720%27%2F%3E%0A%3Ccircle%20cx%3D%2750%27%20cy%3D%2750%27%20r%3D%2710%27%2F%3E%0A%3Cpath%20d%3D%27M50%2030V18M50%2082v-12M18%2050h12M82%2050h-12%27%20stroke-width%3D%272.5%27%2F%3E%0A%3C%2Fsvg%3E");
    animation: gearSpinReverse 80s linear infinite;
}

@keyframes gearSpinReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

/* 隐藏 body.gauge-type-internal / external 兼容类 */
body.gauge-type-internal { /* 内部花键 默认 */ }
body.gauge-type-external { /* 外部花键 */ }

img,
svg {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--t-fast);
}
a:hover { color: var(--primary-light); }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

input,
select,
textarea {
    font: inherit;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    outline: none;
}

input[type="number"] {
    -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

ul, ol { list-style: none; }

::selection {
    background: var(--primary-100);
    color: var(--primary-dark);
}


/* ============================================================
   3. 滚动条
   ============================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-full);
    transition: background var(--t-base);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}


/* ============================================================
   4. 布局  桌面端 380px + 1fr
   ============================================================ */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--s-6);
}

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
        "brand brand"
        "params result"
        "mobile mobile";
    gap: var(--s-5);
    align-items: start;
    position: relative;
    z-index: 1;
}

/* 左右互换：参数仍在窄列，结果在宽列 */
body.layout-swapped .app-layout {
    grid-template-columns: 1fr var(--sidebar-width);
    grid-template-areas:
        "brand brand"
        "result params"
        "mobile mobile";
}

.app-layout > .brand-bar { grid-area: brand; }
.app-layout > .params-panel { grid-area: params; }
.app-layout > .result-panel { grid-area: result; }
.app-layout > .action-bar-mobile { grid-area: mobile; }

.params-panel {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    position: relative;
}

.result-panel {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    min-width: 0;
    position: relative;
}


/* ============================================================
   5. 品牌区 / 顶部栏
   ============================================================ */
.brand-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-5) var(--s-6);
    background: var(--bg-card);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--s-6);
    gap: var(--s-4);
    flex-wrap: wrap;
}

.brand-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-left: auto;
}

/* 互换按钮：默认普通态 */
#btnSwapLayout {
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid transparent;
    transition: all var(--t-base);
}

#btnSwapLayout:hover {
    color: var(--primary);
    background: var(--primary-50);
    border-color: var(--primary-100);
    transform: rotate(180deg);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.brand-logo {
    width: 52px;
    height: 52px;
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-weight: var(--fw-bold);
    font-size: var(--fs-lg);
    box-shadow: 0 6px 14px -2px rgba(44, 82, 130, 0.35), 0 2px 6px -1px rgba(44, 82, 130, 0.2);
    position: relative;
    overflow: hidden;
}

.brand-logo::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25) 0%, transparent 60%);
    pointer-events: none;
}

@keyframes gearSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

.brand-meta {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.brand-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--primary-50);
    color: var(--primary);
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
}

.brand-tag::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.18);
}


/* ============================================================
   6. 面板 (Panel) 头 / 体
   ============================================================ */
.panel {
    background: var(--bg-card);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--t-base);
}
.panel:hover { box-shadow: var(--shadow-md); }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--divider);
    background: linear-gradient(to bottom, var(--bg-card), var(--bg-page));
}

.panel-title {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.panel-title-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--r-sm);
    background: var(--primary-50);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-sm);
}

.panel-body {
    padding: var(--s-5);
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}


/* ============================================================
   7. 卡片 (Card)
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--s-4);
    transition: box-shadow var(--t-base), transform var(--t-base);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
}

.card-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.card-subtitle {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    margin-top: 2px;
}

.card-body { /* 内容区 */ }

.card-footer {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--s-2);
}


/* ============================================================
   8. 表单 (Form)
   ============================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
}

.form-group:last-child { margin-bottom: 0; }

.form-row {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: 5px 0;
    border-bottom: 1px solid var(--divider);
    transition: background var(--t-fast);
}
.form-row:last-child { border-bottom: none; }
.form-row:hover { background: var(--bg-input); border-radius: var(--r-sm); padding-left: 6px; padding-right: 6px; }

.form-label {
    min-width: 80px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-weight: var(--fw-medium);
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-label .required {
    color: var(--stop);
    font-size: var(--fs-xs);
}

.form-label-tip {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: help;
    transition: all var(--t-fast);
}
.form-label-tip:hover { background: var(--primary-50); color: var(--primary); }

.form-control {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-width: 0;
}

.form-input,
.form-select {
    width: 100%;
    height: 38px;
    padding: 0 var(--s-3);
    font-size: var(--fs-sm);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: all var(--t-base);
    font-variant-numeric: tabular-nums;
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-input:hover,
.form-select:hover {
    background: var(--bg-input-hover);
    border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus {
    background: var(--bg-card);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

.form-input:disabled,
.form-select:disabled {
    background: var(--bg-page);
    color: var(--text-disabled);
    cursor: not-allowed;
}

.form-input.is-invalid,
.form-select.is-invalid {
    border-color: var(--stop);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-input.is-valid,
.form-select.is-valid {
    border-color: var(--go);
}

.form-input-with-unit {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: all var(--t-base);
    flex: 1;
}
.form-input-with-unit:hover { background: var(--bg-input-hover); border-color: var(--border-strong); }
.form-input-with-unit:focus-within {
    background: var(--bg-card);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}
.form-input-with-unit .form-input {
    border: none;
    background: transparent;
    box-shadow: none;
    flex: 1;
}
.form-input-with-unit .form-input:focus { box-shadow: none; }
.form-input-with-unit .form-unit {
    padding: 0 var(--s-3);
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    border-left: 1px solid var(--border);
    height: 100%;
    display: flex;
    align-items: center;
    user-select: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px;
    cursor: pointer;
}

.form-hint {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    margin-top: 4px;
    line-height: 1.4;
}

.form-error {
    font-size: var(--fs-xs);
    color: var(--stop);
    margin-top: 4px;
}

/* 表单分组容器（垂直堆叠form-row） */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.preset-btn {
    height: 36px;
    padding: 0 var(--s-3);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--t-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.preset-btn:hover {
    background: var(--primary-50);
    border-color: var(--primary-200);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.preset-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}
.preset-btn.active:hover { background: var(--primary-dark); border-color: var(--primary-dark); }


/* ============================================================
   9. 按钮 (Button)
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 var(--s-4);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all var(--t-base);
    user-select: none;
    white-space: nowrap;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: var(--bg-input-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-icon { padding: 0; width: 40px; }
.btn-icon.btn-sm { width: 32px; }

.btn-sm {
    height: 32px;
    padding: 0 var(--s-3);
    font-size: var(--fs-xs);
    border-radius: var(--r-sm);
}

.btn-lg {
    height: 48px;
    padding: 0 var(--s-6);
    font-size: var(--fs-md);
    border-radius: var(--r-md);
}

.btn-block { width: 100%; }

/* 主按钮 蓝 */
.btn-primary {
    color: var(--text-inverse);
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}
.btn-primary:active { background: var(--primary-dark); }

/* 次按钮 浅灰 */
.btn-secondary {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--primary-50);
    color: var(--primary);
    border-color: var(--primary-200);
}

/* 文字按钮 */
.btn-ghost {
    color: var(--text-secondary);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}
.btn-ghost:hover {
    color: var(--primary);
    background: var(--primary-50);
    border-color: transparent;
    box-shadow: none;
}

/* 通端 / 止端 / 校对按钮 */
.btn-go {
    color: var(--text-inverse);
    background: var(--go);
    border-color: var(--go);
    box-shadow: var(--shadow-sm);
}
.btn-go:hover { background: var(--go-dark); border-color: var(--go-dark); }

.btn-stop {
    color: var(--text-inverse);
    background: var(--stop);
    border-color: var(--stop);
    box-shadow: var(--shadow-sm);
}
.btn-stop:hover { background: var(--stop-dark); border-color: var(--stop-dark); }

.btn-jc {
    color: var(--text-inverse);
    background: var(--jc);
    border-color: var(--jc);
    box-shadow: var(--shadow-sm);
}
.btn-jc:hover { background: var(--jc-dark); border-color: var(--jc-dark); }

/* 危险 / 警告 */
.btn-danger {
    color: var(--text-inverse);
    background: var(--stop);
    border-color: var(--stop);
}
.btn-danger:hover { background: var(--stop-dark); border-color: var(--stop-dark); }


/* ============================================================
   10. 标签页 (Tabs)
   ============================================================ */
.tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: #F1F5F9;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}

.tabs.tabs-block {
    display: flex;
    width: 100%;
}

.tab-btn {
    flex: 1;
    padding: var(--s-2) var(--s-4);
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--t-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    position: relative;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab-btn .tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    background: var(--bg-input);
    color: var(--text-tertiary);
    border-radius: var(--r-full);
    margin-left: 2px;
}
.tab-btn.active .tab-badge {
    background: var(--primary-50);
    color: var(--primary);
}

/* 子 Tab */
.sub-tabs {
    display: flex;
    gap: var(--s-1);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--s-4);
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px 2px 0;
}
.sub-tabs::-webkit-scrollbar { display: none; }

.sub-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--s-2) var(--s-4);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--t-base);
    position: relative;
    white-space: nowrap;
    border-radius: var(--r-md) var(--r-md) 0 0;
    min-height: 38px;
}
.sub-tab-btn:hover {
    color: var(--primary);
    background: var(--primary-50);
    transform: translateY(-1px);
}
.sub-tab-btn:active { transform: translateY(0); }

.sub-tab-btn.active {
    color: var(--primary);
    background: linear-gradient(180deg, rgba(59,130,246,0.08) 0%, rgba(59,130,246,0.16) 100%);
    font-weight: var(--fw-semibold);
}
.sub-tab-btn.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 3px 3px 0 0;
    box-shadow: 0 -2px 8px rgba(44, 82, 130, 0.25);
}

.sub-tab-panel { display: none; }
.sub-tab-panel.active { display: block; animation: fadeIn 220ms ease; }


/* ============================================================
   11. 输入模式切换 (Mode Tabs)
   ============================================================ */
.mode-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: #F1F5F9;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    width: 100%;
    margin-bottom: var(--s-3);
}

.mode-tab {
    flex: 1;
    padding: var(--s-2) var(--s-3);
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--t-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.mode-tab:hover { color: var(--text-primary); }
.mode-tab.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.conditional-inputs {
    display: none;
    animation: fadeIn 200ms ease;
}
.conditional-inputs.active { display: block; }


/* ============================================================
   12. 量规类型选择 (Gauge Type)
   ============================================================ */
.gauge-type-row {
    display: flex;
    gap: var(--s-2);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    flex: 1;
    transition: all var(--t-base);
    user-select: none;
}
.radio-label:hover {
    border-color: var(--primary-200);
    background: var(--primary-50);
    color: var(--primary);
}
.radio-label.active {
    border-color: var(--primary);
    background: var(--primary-50);
    color: var(--primary);
    box-shadow: var(--shadow-focus-primary);
}
.radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    transition: border-color var(--t-base);
}
.radio-label.active .radio-custom { border-color: var(--primary); }
.radio-label.active .radio-custom::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pop 200ms ease;
}

.radio-text { line-height: 1.2; }


/* ============================================================
   13. 结果卡片 (Result Card)
   ============================================================ */
.result-card {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--t-base), transform var(--t-base);
}
.result-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.result-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--divider);
    background: linear-gradient(to bottom, var(--bg-card) 0%, var(--bg-input) 100%);
}

.result-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    flex: 1;
}

.result-title .badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: var(--fs-xs);
    background: var(--primary-50);
    color: var(--primary);
    border-radius: var(--r-full);
    font-weight: var(--fw-medium);
    vertical-align: middle;
}

.result-card-body { padding: 0; }

.result-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.result-table tr {
    border-bottom: 1px solid var(--divider);
    transition: background var(--t-fast);
}
.result-table tr:last-child { border-bottom: none; }
.result-table tr:hover { background: var(--bg-input); }

.result-table .label-cell {
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    width: 40%;
    font-weight: var(--fw-regular);
}

.result-table .value-cell {
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    text-align: right;
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

.result-table .value-cell .unit {
    color: var(--text-tertiary);
    font-size: var(--fs-xs);
    margin-left: 4px;
    font-weight: var(--fw-regular);
}

.result-table .value-cell.is-highlight {
    color: var(--primary);
    font-weight: var(--fw-semibold);
}

.result-table tr.group-header {
    background: var(--bg-input);
}
.result-table tr.group-header .label-cell {
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    padding: 10px 20px;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.result-table tr.group-header:hover { background: var(--bg-input); }

.row-divider td {
    padding: 0 !important;
    height: 8px;
    background: var(--bg-page);
    border-bottom: none !important;
}
.row-divider:hover { background: var(--bg-page) !important; }


/* ============================================================
   14. 公差显示  上标 / 下标
   ============================================================ */
.tol-value {
    display: inline-flex;
    align-items: center;
    font-variant-numeric: tabular-nums;
}

.tol-base {
    font-weight: var(--fw-medium);
    color: var(--text-primary);
}

.tol-stack {
    display: inline-flex;
    flex-direction: column;
    margin-left: 6px;
    font-size: 0.7em;
    line-height: 1;
    vertical-align: middle;
    font-weight: var(--fw-medium);
}

.tol-sup,
.tol-sub {
    color: var(--primary);
    line-height: 1.1;
    font-weight: var(--fw-medium);
}
.tol-sup { transform: translateY(-2px); padding-bottom: 1px; }
.tol-sub { transform: translateY(2px); padding-top: 1px; }

.tol-sym {
    color: var(--primary);
    margin-left: 4px;
    font-weight: var(--fw-medium);
}

.tol-value-large {
    font-size: var(--fs-md);
}
.tol-value-large .tol-stack { font-size: 0.7em; }


/* ============================================================
   15. 分组 (Group) 与图标
   ============================================================ */
.group-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 4px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    margin-right: 6px;
    font-weight: var(--fw-bold);
    flex-shrink: 0;
    vertical-align: middle;
}

.group-icon.go { background: var(--go); }
.group-icon.stop { background: var(--stop); }
.group-icon.jc { background: var(--jc); }


/* ============================================================
   16. 中间结果 (Intermediate)
   ============================================================ */
.intermediate-row {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--divider);
    transition: background var(--t-fast);
}
.intermediate-row:last-child { border-bottom: none; }
.intermediate-row:hover { background: var(--bg-input); border-radius: var(--r-sm); padding-left: 6px; padding-right: 6px; }

.intermediate-label {
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    font-size: var(--fs-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.intermediate-values {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-variant-numeric: tabular-nums;
}

.intermediate-value {
    padding: 4px 8px;
    background: var(--bg-input);
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    color: var(--text-primary);
    min-width: 56px;
    text-align: center;
    border: 1px solid transparent;
    transition: all var(--t-base);
}
.intermediate-value.is-editable {
    cursor: text;
    background: var(--bg-card);
    border-color: var(--border);
}
.intermediate-value.is-editable:hover {
    background: var(--bg-input);
    border-color: var(--border-strong);
}
.intermediate-value.is-editable:focus-within {
    background: var(--bg-card);
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.intermediate-sep {
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    user-select: none;
}

.reset-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-tertiary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-base);
    flex-shrink: 0;
}
.reset-btn:hover {
    background: var(--stop-bg);
    border-color: var(--stop-border);
    color: var(--stop);
    transform: rotate(-90deg);
}


/* ============================================================
   17. 操作栏 (Action Bar)
   ============================================================ */
.action-bar {
    display: flex;
    gap: var(--s-3);
    padding: var(--s-4) 0;
    align-items: center;
    flex-wrap: wrap;
}

.action-bar .btn { flex: 0 0 auto; }
.action-bar .btn-flex { flex: 1; }

.action-group {
    display: flex;
    gap: var(--s-2);
    margin-left: auto;
}

/* 桌面端操作栏：默认显示，置于左侧面板底部，粘性固定在视口底部 */
.action-bar-desktop {
    display: flex;
    margin-top: auto;
    padding: 16px 0;
    position: sticky;
    bottom: 0;
    background: var(--bg-page);
    z-index: 10;
    border-top: 1px solid var(--border);
}

/* 移动端操作栏：默认隐藏（仅移动端显示） */
.action-bar-mobile { display: none; }


/* ============================================================
   18. 校对塞规专用 (环规子tab)
   ============================================================ */
.sub-tab-ring-only { display: none; }
body.gauge-type-external .sub-tab-ring-only { display: flex; }

/* 内/外部花键文字切换 */
[data-internal-label],
[data-external-label] { /* JS 控制 innerText */ }


/* ============================================================
   19. 提示 / 徽章 / 标签
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    border-radius: var(--r-full);
    background: var(--bg-input);
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: nowrap;
}
.badge-primary { background: var(--primary-50); color: var(--primary); }
.badge-go { background: var(--go-bg); color: var(--go); }
.badge-stop { background: var(--stop-bg); color: var(--stop); }
.badge-jc { background: var(--jc-bg); color: var(--jc); }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-info { background: #E0F2FE; color: #0369A1; }
.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.tag {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: var(--r-xs);
    background: var(--primary-50);
    color: var(--primary);
    font-weight: var(--fw-medium);
    line-height: 1.3;
}

.empty-state {
    text-align: center;
    padding: var(--s-12) var(--s-4);
    color: var(--text-tertiary);
}
.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--s-3);
    border-radius: var(--r-lg);
    background: var(--bg-input);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.empty-state-title {
    font-size: var(--fs-md);
    color: var(--text-secondary);
    font-weight: var(--fw-medium);
    margin-bottom: var(--s-1);
}
.empty-state-desc {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
}


/* ============================================================
   20. 工具: 间距 / 文字 / 弹性 / 显隐
   ============================================================ */
/* 文字 */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-go { color: var(--go) !important; }
.text-stop { color: var(--stop) !important; }
.text-jc { color: var(--jc) !important; }
.text-bold { font-weight: var(--fw-bold) !important; }
.text-medium { font-weight: var(--fw-medium) !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.text-num { font-variant-numeric: tabular-nums; }
.text-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); }
.text-md { font-size: var(--fs-md); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-2xl { font-size: var(--fs-2xl); }

/* 间距 */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--s-1) !important; }
.mt-2 { margin-top: var(--s-2) !important; }
.mt-3 { margin-top: var(--s-3) !important; }
.mt-4 { margin-top: var(--s-4) !important; }
.mt-5 { margin-top: var(--s-5) !important; }
.mt-6 { margin-top: var(--s-6) !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--s-1) !important; }
.mb-2 { margin-bottom: var(--s-2) !important; }
.mb-3 { margin-bottom: var(--s-3) !important; }
.mb-4 { margin-bottom: var(--s-4) !important; }
.mb-5 { margin-bottom: var(--s-5) !important; }
.mb-6 { margin-bottom: var(--s-6) !important; }
.mx-1 { margin-left: var(--s-1); margin-right: var(--s-1); }
.mx-2 { margin-left: var(--s-2); margin-right: var(--s-2); }
.mx-3 { margin-left: var(--s-3); margin-right: var(--s-3); }
.my-1 { margin-top: var(--s-1); margin-bottom: var(--s-1); }
.my-2 { margin-top: var(--s-2); margin-bottom: var(--s-2); }
.my-3 { margin-top: var(--s-3); margin-bottom: var(--s-3); }
.my-4 { margin-top: var(--s-4); margin-bottom: var(--s-4); }
.m-0 { margin: 0 !important; }
.m-auto { margin: auto !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--s-1) !important; }
.p-2 { padding: var(--s-2) !important; }
.p-3 { padding: var(--s-3) !important; }
.p-4 { padding: var(--s-4) !important; }
.p-5 { padding: var(--s-5) !important; }
.p-6 { padding: var(--s-6) !important; }

/* Flex */
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-block { display: block !important; }
.d-none { display: none !important; }
.d-grid { display: grid !important; }
.flex-1 { flex: 1 !important; }
.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.flex-wrap { flex-wrap: wrap !important; }
.justify-start { justify-content: flex-start !important; }
.justify-center { justify-content: center !important; }
.justify-end { justify-content: flex-end !important; }
.justify-between { justify-content: space-between !important; }
.justify-around { justify-content: space-around !important; }
.align-start { align-items: flex-start !important; }
.align-center { align-items: center !important; }
.align-end { align-items: flex-end !important; }
.align-baseline { align-items: baseline !important; }
.align-stretch { align-items: stretch !important; }
.gap-1 { gap: var(--s-1) !important; }
.gap-2 { gap: var(--s-2) !important; }
.gap-3 { gap: var(--s-3) !important; }
.gap-4 { gap: var(--s-4) !important; }
.gap-5 { gap: var(--s-5) !important; }
.gap-6 { gap: var(--s-6) !important; }

/* 显隐 */
.is-hidden { display: none !important; }
.is-invisible { visibility: hidden !important; opacity: 0; }

/* 宽度 */
.w-full { width: 100% !important; }
.h-full { height: 100% !important; }


/* ============================================================
   21. 动画
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pop {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.55; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade { animation: fadeIn 280ms ease both; }
.animate-slide-up { animation: slideInUp 320ms cubic-bezier(0.4,0,0.2,1) both; }
.animate-pop { animation: pop 280ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.animate-pulse { animation: pulse 1.6s ease-in-out infinite; }
.animate-spin { animation: spin 0.8s linear infinite; }

.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 0%, var(--bg-input-hover) 50%, var(--bg-input) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    border-radius: var(--r-sm);
}


/* ============================================================
   22. 通知 / Toast
   ============================================================ */
.toast-container {
    position: fixed;
    top: var(--s-5);
    right: var(--s-5);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-width: 280px;
    max-width: 420px;
    padding: var(--s-3) var(--s-4);
    background: var(--bg-card);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    border-left: 3px solid var(--primary);
    color: var(--text-primary);
    font-size: var(--fs-sm);
    pointer-events: auto;
    animation: slideInRight 320ms cubic-bezier(0.4,0,0.2,1);
}
.toast.is-success { border-left-color: var(--go); }
.toast.is-error   { border-left-color: var(--stop); }
.toast.is-warning { border-left-color: var(--warning); }

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-50);
    color: var(--primary);
}
.toast.is-success .toast-icon { background: var(--go-bg); color: var(--go); }
.toast.is-error   .toast-icon { background: var(--stop-bg); color: var(--stop); }


/* ============================================================
   23. 模态 / 弹层
   ============================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-4);
    animation: fadeIn 200ms ease;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2xl);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideInUp 280ms cubic-bezier(0.4,0,0.2,1);
}

.modal-header {
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast);
}
.modal-close:hover { background: var(--bg-input); color: var(--text-primary); }

.modal-body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.modal-footer {
    padding: var(--s-3) var(--s-5);
    border-top: 1px solid var(--divider);
    display: flex;
    gap: var(--s-2);
    justify-content: flex-end;
}


/* ============================================================
   24. 提示 / Tooltip
   ============================================================ */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::before,
[data-tooltip]::after {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    opacity: 0;
    pointer-events: none;
    transition: all var(--t-base);
    z-index: var(--z-dropdown);
    white-space: nowrap;
}
[data-tooltip]::before {
    content: attr(data-tooltip);
    bottom: calc(100% + 6px);
    padding: 6px 10px;
    background: var(--text-primary);
    color: var(--text-inverse);
    font-size: var(--fs-xs);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
}
[data-tooltip]::after {
    content: '';
    bottom: calc(100% + 2px);
    border: 4px solid transparent;
    border-top-color: var(--text-primary);
}
[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ============================================================
   25. 分割线 / 描述列表
   ============================================================ */
.divider {
    height: 1px;
    background: var(--divider);
    margin: var(--s-3) 0;
    border: none;
}
.divider-vertical {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 var(--s-2);
}

.description-list {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: var(--s-2) var(--s-3);
    font-size: var(--fs-sm);
}
.description-list dt {
    color: var(--text-secondary);
}
.description-list dd {
    color: var(--text-primary);
    font-weight: var(--fw-medium);
}


/* ============================================================
   26. 加载 / Loading
   ============================================================ */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-sticky);
    border-radius: inherit;
}


/* ============================================================
   27. 结果区内的特殊标记
   ============================================================ */
.highlight-box {
    background: linear-gradient(135deg, var(--primary-50) 0%, #EEF2FF 100%);
    border: 1px solid var(--primary-100);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    color: var(--primary-dark);
    font-size: var(--fs-sm);
    line-height: 1.55;
}

.info-box {
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    color: var(--primary-dark);
    font-size: var(--fs-sm);
    line-height: 1.55;
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
}
.info-box-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-inverse);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--fw-bold);
    flex-shrink: 0;
    margin-top: 1px;
}

.warning-box {
    background: #FEF3C7;
    border: 1px solid #FDE68A;
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    color: #92400E;
    font-size: var(--fs-sm);
    line-height: 1.55;
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
}

.error-box {
    background: var(--stop-bg);
    border: 1px solid var(--stop-border);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    color: var(--stop-dark);
    font-size: var(--fs-sm);
    line-height: 1.55;
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
}

.success-box {
    background: var(--go-bg);
    border: 1px solid var(--go-border);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    color: var(--go-dark);
    font-size: var(--fs-sm);
    line-height: 1.55;
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
}


/* ============================================================
   28. 步骤条 (Steps)
   ============================================================ */
.steps {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.step {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    transition: all var(--t-base);
}
.step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    flex-shrink: 0;
    transition: all var(--t-base);
}
.step.active { color: var(--primary); }
.step.active .step-num {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 0 0 3px var(--primary-100);
}
.step.done { color: var(--go); }
.step.done .step-num {
    background: var(--go);
    color: var(--text-inverse);
}
.step-sep {
    flex: 1;
    height: 2px;
    background: var(--border);
    border-radius: 1px;
}


/* ============================================================
   29. 状态点 (Status dot)
   ============================================================ */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}
.status-dot.go { background: var(--go); box-shadow: 0 0 0 3px var(--go-bg); }
.status-dot.stop { background: var(--stop); box-shadow: 0 0 0 3px var(--stop-bg); }
.status-dot.jc { background: var(--jc); box-shadow: 0 0 0 3px var(--jc-bg); }
.status-dot.primary { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 0 3px #FEF3C7; }
.status-dot.is-pulse { animation: pulse 1.6s ease-in-out infinite; }


/* ============================================================
   30. 响应式 - 平板 768-1023
   ============================================================ */
@media (max-width: 1023px) {
    :root {
        --sidebar-width: 320px;
    }

    .app { padding: var(--s-4); }

    .app-layout {
        grid-template-columns: 1fr;
        gap: var(--s-4);
    }

    .params-panel {
        position: static;
        top: auto;
    }

    .result-panel { min-width: 0; }

    /* 移动端：隐藏桌面操作栏，显示移动端操作栏 */
    .action-bar-desktop { display: none; }
    .action-bar-mobile {
        display: flex;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
        margin: 0 calc(-1 * var(--s-4));
        padding: var(--s-3) var(--s-4);
        z-index: var(--z-sticky);
    }

    .brand-bar { padding: var(--s-3) var(--s-4); }
    .brand-logo { width: 40px; height: 40px; font-size: var(--fs-md); }

    .panel-body { padding: var(--s-4); }
    .result-card-header { padding: var(--s-3) var(--s-4); }
    .result-table .label-cell,
    .result-table .value-cell { padding: 10px 14px; }
}


/* ============================================================
   31. 响应式 - 手机 <768
   ============================================================ */
@media (max-width: 767px) {
    :root {
        --sidebar-width: 100%;
    }

    .app { padding: var(--s-3); }

    .brand-bar {
        padding: var(--s-3);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--s-2);
    }
    .brand-meta { width: 100%; justify-content: flex-start; flex-wrap: wrap; }

    .app-layout { gap: var(--s-3); }

    .panel-body { padding: var(--s-3); }

    .card { padding: var(--s-3); }
    .card-header { flex-wrap: wrap; }

    .form-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--s-2);
        padding: var(--s-2) 0;
    }
    .form-label { min-width: 0; }
    .form-control { width: 100%; }

    .gauge-type-row { flex-direction: column; }
    .radio-label { width: 100%; }

    .form-grid { grid-template-columns: 1fr 1fr; }

    .result-table { font-size: var(--fs-xs); }
    .result-table .label-cell,
    .result-table .value-cell {
        padding: 8px 10px;
    }
    .result-table .label-cell { width: 45%; }

    .result-card-header {
        padding: var(--s-3);
        flex-wrap: wrap;
    }
    .result-title { width: 100%; margin-top: 4px; }

    .intermediate-row { flex-wrap: wrap; gap: var(--s-2); }
    .intermediate-label { width: 100%; }
    .intermediate-values { width: 100%; justify-content: space-between; }

    .action-bar {
        flex-direction: column;
        gap: var(--s-2);
    }
    .action-bar .btn { width: 100%; }
    .action-group { margin-left: 0; width: 100%; }
    .action-group .btn { flex: 1; }

    .toast { min-width: 0; max-width: 100%; margin: 0 var(--s-3); }
    .toast-container { left: 0; right: 0; }

    .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 95vh; }

    .tab-btn,
    .sub-tab-btn,
    .mode-tab {
        padding: var(--s-2) var(--s-3);
        font-size: var(--fs-xs);
    }

    .description-list {
        grid-template-columns: 1fr;
        gap: 4px var(--s-3);
    }
    .description-list dt { color: var(--text-tertiary); font-size: var(--fs-xs); }
}


/* ============================================================
   32. 打印样式
   ============================================================ */
@media print {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .action-bar,
    .brand-bar,
    .params-panel,
    .toast-container,
    .modal-backdrop {
        display: none !important;
    }
    .result-card,
    .card,
    .panel {
        box-shadow: none !important;
        border: 1px solid var(--border) !important;
        page-break-inside: avoid;
    }
    body { background: #fff; }
}


/* ============================================================
   33. 暗色模式 (预留接口 - 默认不启用)
   ============================================================ */
@media (prefers-color-scheme: dark) {
    /* 如需暗色主题，可在此覆盖变量。当前保持浅色。 */
}


/* ============================================================
   34. 兼容与微调
   ============================================================ */

/* 输入数字时禁用滚动调节 */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 选中文本样式 */
::selection {
    background: var(--primary-200);
    color: var(--primary-dark);
}

/* 表单 autofill 浏览器默认样式覆盖 */
input.form-input:-webkit-autofill,
input.form-input:-webkit-autofill:hover,
input.form-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px var(--bg-card) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
}

/* 聚焦可见性 */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* 隐藏 outline 当 :focus-visible 不支持时回退到 box-shadow */
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* 错误抖动 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}
.is-shake { animation: shake 360ms ease; }

/* 小三角 (下拉箭头) */
.caret {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 4px;
    vertical-align: middle;
    transition: transform var(--t-base);
}
.caret.is-open { transform: rotate(180deg); }

/* 标签 - tag 系列 */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: var(--fs-xs);
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    line-height: 1.3;
}
.chip-primary { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.chip-go { background: var(--go-bg); color: var(--go); border-color: var(--go-border); }
.chip-stop { background: var(--stop-bg); color: var(--stop); border-color: var(--stop-border); }
.chip-jc { background: var(--jc-bg); color: var(--jc); border-color: var(--jc-border); }

.chip-remove {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
    cursor: pointer;
    transition: background var(--t-fast);
}
.chip-remove:hover { background: rgba(0, 0, 0, 0.08); }

/* 链接样式 */
.link {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color var(--t-fast);
}
.link:hover { border-bottom-color: var(--primary); }

/* 折叠面板 */
.collapse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-3) var(--s-4);
    cursor: pointer;
    background: var(--bg-card);
    border-radius: var(--r-md);
    transition: background var(--t-fast);
}
.collapse-header:hover { background: var(--bg-input); }
.collapse-body {
    padding: var(--s-3) var(--s-4);
    display: none;
    animation: fadeIn 200ms ease;
}
.collapse.is-open .collapse-body { display: block; }
.collapse.is-open .collapse-header .caret { transform: rotate(180deg); }

/* 进度条 */
.progress {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: var(--r-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--r-full);
    transition: width var(--t-slow);
}

/* Switch 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-strong);
    border-radius: var(--r-full);
    transition: all var(--t-base);
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: all var(--t-base);
    box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }

/* 文件结束 */
