/* ============================================================
   保险CRM · base.css
   设计令牌（浅/深色）、字体、重置、断点、Safari 适配
   ============================================================ */

:root {
    --color-primary: #FF6A00;
    --color-primary-dark: #E55F00;
    --color-primary-light: #FF8A33;
    --color-ok: #16A34A;
    --color-warn: #F59E0B;
    --color-danger: #DC2626;
    --color-info: #2563EB;
    /* 粉色：跟进表单「更新标签」胶囊按钮专用（白字对比度 4.6:1） */
    --color-pink: #DB2777;
    --color-pink-dark: #BE185D;

    /* ---------- 次级（软色）按钮 ----------
       主色的「淡一档」版本：保留品牌色、但不与主按钮抢视觉重心。
       用于「保存并记一条跟进」「记跟进」等非首要动作。
       沿用状态胶囊的「浅底深字」语言，白底卡片上依然清晰、深色模式自动反转。 */
    --btn-soft-bg: #FFE9D6;
    --btn-soft-bg-hover: #FFDCC0;
    --btn-soft-border: #FFC79A;
    --btn-soft-fg: #A84100;

    --bg: #F4F5F7;
    --bg-elev: #FFFFFF;
    --bg-sunken: #ECEEF1;
    --bg-hover: #F0F2F5;

    --text: #1F2329;
    --text-2: #5B6570;
    --text-3: #8A929B;
    --text-invert: #FFFFFF;

    --border: #E3E6EA;
    --border-strong: #C9D0D8;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .16);

    --topbar-h: 56px;
    --tabbar-h: 58px;
    --sidebar-w: 220px;

    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);

    /* ---------- 状态胶囊色（13 态「浅底深字」） ----------
       唯一来源：app/helpers/status.php 的 STAGES.bg/fg。
       视图只输出 data-stage，颜色由 app.css 映射到 --st-bg/--st-fg。
       深色模式在下方 dark 区块覆盖为「深底浅字」。 */
    --st-pending_follow-bg: #F3F4F6;          --st-pending_follow-fg: #6B7280;
    --st-following-bg: #E3F0FF;               --st-following-fg: #16588E;
    --st-interested-bg: #E0F7FA;              --st-interested-fg: #0891B2;
    --st-event_invite-bg: #F0E9FF;            --st-event_invite-fg: #7C3AED;
    --st-committed-bg: #E8E7FD;               --st-committed-fg: #4338CA;
    --st-closing-bg: #FFF3E0;                 --st-closing-fg: #D97706;
    --st-signed-bg: #E6F6EC;                  --st-signed-fg: #15803D;
    --st-pending_policy_delivery-bg: #E0F5F1; --st-pending_policy_delivery-fg: #0F766E;
    --st-development_done-bg: #DCFCE7;        --st-development_done-fg: #047857;
    --st-renewal_reminder-bg: #FEF3C7;        --st-renewal_reminder-fg: #B45309;
    --st-claiming-bg: #FFE4E9;                --st-claiming-fg: #BE123C;
    --st-redevelopment-bg: #EDE9FE;           --st-redevelopment-fg: #6D28D9;
    --st-no_interest-bg: #FEE2E2;             --st-no_interest-fg: #B91C1C;

    /* ---------- 性别胶囊色（浅底深字） ---------- */
    --g-male-bg: #E3F0FF;   --g-male-fg: #16588E;
    --g-female-bg: #FDE7F0; --g-female-fg: #A63B6B;
    --g-none-bg: #F3F4F6;   --g-none-fg: #6B7280;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-primary: #FF8A33;
        --color-primary-dark: #FF6A00;
        --bg: #14171A;
        --bg-elev: #1D2126;
        --bg-sunken: #24282E;
        --bg-hover: #262B31;
        --text: #E7EAEE;
        --text-2: #AAB2BC;
        --text-3: #7E8792;
        --border: #2C3238;
        --border-strong: #3A424A;
        --shadow: 0 1px 3px rgba(0, 0, 0, .5);
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, .6);

        /* 次级（软色）按钮：深底浅字 */
        --btn-soft-bg: #46280F;
        --btn-soft-bg-hover: #573214;
        --btn-soft-border: #6E3E18;
        --btn-soft-fg: #FFB273;

        /* 状态胶囊：深底浅字 */
        --st-pending_follow-bg: #2A2F37;          --st-pending_follow-fg: #B6BEC9;
        --st-following-bg: #12314A;               --st-following-fg: #8FD0FF;
        --st-interested-bg: #0A3A44;              --st-interested-fg: #67D7E8;
        --st-event_invite-bg: #2E2153;            --st-event_invite-fg: #C4A9FF;
        --st-committed-bg: #26265C;               --st-committed-fg: #A5A0FF;
        --st-closing-bg: #3D2A0C;                 --st-closing-fg: #FBBF6B;
        --st-signed-bg: #0F3220;                  --st-signed-fg: #6EE7A0;
        --st-pending_policy_delivery-bg: #0C3733; --st-pending_policy_delivery-fg: #5FD6C8;
        --st-development_done-bg: #0C3A26;        --st-development_done-fg: #6EE7A0;
        --st-renewal_reminder-bg: #3D2E0A;        --st-renewal_reminder-fg: #FCD34D;
        --st-claiming-bg: #3D1020;                --st-claiming-fg: #FF8095;
        --st-redevelopment-bg: #2A2153;           --st-redevelopment-fg: #B49CFF;
        --st-no_interest-bg: #3D1212;             --st-no_interest-fg: #FCA5A5;

        --g-male-bg: #12314A;   --g-male-fg: #8FD0FF;
        --g-female-bg: #45152A; --g-female-fg: #F7A8C8;
        --g-none-bg: #2A2F37;   --g-none-fg: #B6BEC9;
    }
}

:root[data-theme="dark"] {
    --color-primary: #FF8A33;
    --color-primary-dark: #FF6A00;
    --bg: #14171A;
    --bg-elev: #1D2126;
    --bg-sunken: #24282E;
    --bg-hover: #262B31;
    --text: #E7EAEE;
    --text-2: #AAB2BC;
    --text-3: #7E8792;
    --border: #2C3238;
    --border-strong: #3A424A;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .6);

    --btn-soft-bg: #46280F;
    --btn-soft-bg-hover: #573214;
    --btn-soft-border: #6E3E18;
    --btn-soft-fg: #FFB273;

    --st-pending_follow-bg: #2A2F37;          --st-pending_follow-fg: #B6BEC9;
    --st-following-bg: #12314A;               --st-following-fg: #8FD0FF;
    --st-interested-bg: #0A3A44;              --st-interested-fg: #67D7E8;
    --st-event_invite-bg: #2E2153;            --st-event_invite-fg: #C4A9FF;
    --st-committed-bg: #26265C;               --st-committed-fg: #A5A0FF;
    --st-closing-bg: #3D2A0C;                 --st-closing-fg: #FBBF6B;
    --st-signed-bg: #0F3220;                  --st-signed-fg: #6EE7A0;
    --st-pending_policy_delivery-bg: #0C3733; --st-pending_policy_delivery-fg: #5FD6C8;
    --st-development_done-bg: #0C3A26;        --st-development_done-fg: #6EE7A0;
    --st-renewal_reminder-bg: #3D2E0A;        --st-renewal_reminder-fg: #FCD34D;
    --st-claiming-bg: #3D1020;                --st-claiming-fg: #FF8095;
    --st-redevelopment-bg: #2A2153;           --st-redevelopment-fg: #B49CFF;
    --st-no_interest-bg: #3D1212;             --st-no_interest-fg: #FCA5A5;

    --g-male-bg: #12314A;   --g-male-fg: #8FD0FF;
    --g-female-bg: #45152A; --g-female-fg: #F7A8C8;
    --g-none-bg: #2A2F37;   --g-none-fg: #B6BEC9;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

input, select, textarea, button {
    font-family: inherit;
    /* Safari：≥16px 防自动放大 */
    font-size: 16px;
    color: var(--text);
}

/* 统一去除原生外观（Safari） */
input[type="text"], input[type="search"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="email"], input[type="tel"],
select, textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

textarea { min-height: 84px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(255, 106, 0, .14);
}

::placeholder { color: var(--text-3); }

.muted { color: var(--text-3); }
.text-ok { color: var(--color-ok); }
.text-danger { color: var(--color-danger); }
.nowrap { white-space: nowrap; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

@media (max-width: 767px) {
    body { font-size: 15px; }
}

/* 安全区与视口高度工具类 */
.safe-bottom { padding-bottom: calc(12px + var(--safe-b)); }
.app-main-height { height: 100vh; height: 100dvh; }
