/* ==========================================================================
   天赐华裳婚服管理系统 — 设计系统
   风格：钉钉 + 飞书 + Apple HIG，极简、商务、卡片化、浅色背景
   移动端优先（375px 基准），向上兼容平板 / PC
   ========================================================================== */

:root {
    /* 主色：商务蓝（克制、非婚庆风） */
    --color-primary: #2b6cb0;
    --color-primary-dark: #245a92;
    --color-primary-light: #e8eff5;

    /* 功能色 */
    --color-success: #2f9e44;   /* 可选/绿色 */
    --color-warning: #e8893b;   /* 部分可选/橙色 */
    --color-danger: #e03131;    /* 不可选/红色 */
    --color-muted: #9aa5b1;     /* 停用/灰色 */

    /* 中性色 */
    --bg-page: #f5f7fa;
    --bg-card: #ffffff;
    --bg-subtle: #f8fbfd;
    --border: #e6e9ef;
    --border-strong: #d4d9e0;

    --text-main: #1f2733;
    --text-sub: #5b6573;
    --text-placeholder: #aab2bd;

    /* 圆角与阴影 */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 3px rgba(31, 39, 51, 0.06), 0 1px 2px rgba(31, 39, 51, 0.04);
    --shadow-pop: 0 8px 24px rgba(31, 39, 51, 0.12);

    /* 间距 */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;

    --nav-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-main);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 640px;        /* 平板/PC 居中，保持移动端版式 */
    margin: 0 auto;
    min-height: 100%;
    background: var(--bg-page);
    position: relative;
}

/* ---------- 布局：内容区 + 底部导航 ---------- */
.app-main {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-4));
}

.page {
    padding: var(--space-4);
}

/* ---------- 卡片 ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: var(--space-4);
}
.card + .card { margin-top: var(--space-3); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 44px;
    padding: 0 var(--space-5);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
    background: #eef1f5;
    cursor: pointer;
    transition: opacity .15s, background .15s;
    user-select: none;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled {
    background: #e9ecf1;
    color: var(--text-placeholder);
    cursor: not-allowed;
}

/* ---------- 表单 ---------- */
.field { margin-bottom: var(--space-4); }
.field-label {
    display: block;
    font-size: 14px;
    color: var(--text-sub);
    margin-bottom: var(--space-2);
}
.field-label .req { color: var(--color-danger); margin-left: 2px; }
.input, .textarea, .select {
    width: 100%;
    min-height: 44px;
    padding: 10px var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 15px;
    color: var(--text-main);
    outline: none;
    transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--color-primary); }
.input.is-error, .textarea.is-error { border-color: var(--color-danger); }
.input::placeholder { color: var(--text-placeholder); }
.textarea { min-height: 88px; resize: vertical; }

/* ---------- 状态标签 ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 var(--space-2);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1;
}
.tag-success { background: #e7f5ea; color: var(--color-success); }
.tag-warning { background: #fdeee0; color: var(--color-warning); }
.tag-danger { background: #fde8e8; color: var(--color-danger); }
.tag-muted { background: #eef0f3; color: var(--color-muted); }

/* ---------- 底部导航 ---------- */
.tabbar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 640px;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: flex;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
}
.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text-sub);
    text-decoration: none;
}
.tabbar-item.is-active { color: var(--color-primary); }
.tabbar-item .icon { font-size: 20px; line-height: 1; }
.tabbar-item.is-fab .icon {
    width: 40px; height: 40px;
    margin-top: -16px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-pop);
    font-size: 24px;
}

/* ---------- 顶部栏 ---------- */
.navbar {
    position: sticky;
    top: 0;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    font-weight: 600;
    z-index: 50;
}
.navbar .navbar-left, .navbar .navbar-right {
    position: absolute;
    top: 0; height: 48px;
    display: flex; align-items: center;
    padding: 0 var(--space-4);
    color: var(--color-primary);
    font-size: 15px; font-weight: 400;
    cursor: pointer;
}
.navbar .navbar-left { left: 0; }
.navbar .navbar-right { right: 0; }

/* ---------- 空状态 ---------- */
.empty {
    padding: 48px var(--space-4);
    text-align: center;
    color: var(--text-placeholder);
    font-size: 14px;
}

/* ---------- Toast ---------- */
.toast-wrap {
    position: fixed;
    left: 50%; top: 40%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex; flex-direction: column; gap: var(--space-2);
    pointer-events: none;
}
.toast {
    background: rgba(31, 39, 51, .9);
    color: #fff;
    padding: 10px var(--space-4);
    border-radius: var(--radius-sm);
    font-size: 14px;
    max-width: 80vw;
    text-align: center;
    animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- 通用工具类 ---------- */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.text-sub { color: var(--text-sub); }
.text-danger { color: var(--color-danger); }
.text-bold { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-18 { font-size: 18px; }
.flex-1 { flex: 1; }

/* ---------- 首页工作台 ---------- */
.home-banner {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: var(--space-5) var(--space-4) var(--space-6);
}
.home-banner-greet { font-size: 20px; font-weight: 600; }
.home-banner-date { font-size: 13px; opacity: .85; margin-top: var(--space-1); }

/* 概览卡片：上移与 banner 叠压 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    margin-top: calc(-1 * var(--space-5));
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: var(--space-3) var(--space-2);
    text-align: center;
    cursor: pointer;
}
.stat-card:active { opacity: .9; }
.stat-num { font-size: 19px; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--text-sub); margin-top: var(--space-2); }

/* 快捷入口 */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-2);
}
.quick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}
.quick-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--color-primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.quick-label { font-size: 11px; color: var(--text-sub); }

/* 订单卡片 */
.order-card { cursor: pointer; }
.order-card:active { opacity: .95; }

/* ---------- 文本按钮 ---------- */
.btn-text {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    padding: 6px 8px;
    cursor: pointer;
}
.btn-text:disabled { color: var(--text-placeholder); cursor: not-allowed; }

/* ---------- 悬浮新增按钮 ---------- */
.fab {
    position: fixed;
    right: max(16px, calc(50% - 320px + 16px));
    bottom: calc(var(--space-6) + var(--safe-bottom));
    width: 52px; height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 28px;
    box-shadow: var(--shadow-pop);
    cursor: pointer;
    z-index: 80;
}

/* ---------- 底部保存条 ---------- */
.footer-bar {
    position: fixed;
    left: 50%; transform: translateX(-50%);
    bottom: 0;
    width: 100%; max-width: 640px;
    padding: var(--space-2) var(--space-4) calc(var(--space-2) + var(--safe-bottom));
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 80;
}
/* 有底部保存条时，主内容预留空间 */
.app-main { padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-4)); }

/* ---------- 分类筛选 chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
    padding: 6px 14px;
    border-radius: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-sub);
    cursor: pointer;
}
.chip.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ---------- 分类管理行 ---------- */
.cat-row { display: flex; align-items: center; gap: 2px; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.cat-row:last-child { border-bottom: none; }

/* ---------- 服饰列表行 ---------- */
.costume-row { display: flex; gap: var(--space-3); cursor: pointer; }
.costume-cover {
    width: 72px; height: 96px;
    flex: none;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle) center/cover no-repeat;
}

/* ---------- 图片上传 ---------- */
.img-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.img-thumb {
    position: relative;
    width: 84px; height: 112px;     /* 3:4 */
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-subtle);
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-del {
    position: absolute; top: 2px; right: 2px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,.5); color: #fff;
    font-size: 14px; line-height: 20px; text-align: center;
    cursor: pointer;
}
.img-add {
    width: 84px; height: 112px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: var(--text-placeholder);
    cursor: pointer;
}

/* ---------- 部件卡片 ---------- */
.comp-card { border: 1px solid var(--border); }
.switch-label { font-size: 13px; color: var(--text-sub); display: inline-flex; align-items: center; gap: 6px; }
.switch-label input { width: 16px; height: 16px; }

/* ---------- 覆盖层（分类管理） ---------- */
.overlay {
    position: fixed;
    inset: 0;
    left: 50%; transform: translateX(-50%);
    max-width: 640px;
    background: var(--bg-page);
    z-index: 200;
    overflow-y: auto;
}

/* ---------- 分段切换（订单三栏 Tab） ---------- */
.seg {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}
.seg-item {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-size: 14px;
    color: var(--text-sub);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.seg-item.is-active {
    color: var(--color-primary);
    font-weight: 600;
    border-bottom-color: var(--color-primary);
}

/* ---------- 不可选行（服饰选择） ---------- */
.is-disabled-row { opacity: .55; }

/* ---------- 底部抽屉（尺码选择 P09） ---------- */
.sheet {
    position: fixed;
    left: 50%; transform: translateX(-50%);
    bottom: 0;
    width: 100%; max-width: 640px;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 80vh;
    display: flex; flex-direction: column;
    animation: sheet-up .2s ease;
}
@keyframes sheet-up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-head { padding: var(--space-4); border-bottom: 1px solid var(--border); }
.sheet-body { padding: 0 var(--space-4) var(--space-4); overflow-y: auto; }
.sheet-foot { padding: var(--space-3) var(--space-4) calc(var(--space-3) + var(--safe-bottom)); border-top: 1px solid var(--border); }
/* 尺码抽屉的遮罩底部对齐 */
.dialog-mask { align-items: center; }

/* ---------- 二次确认弹窗 ---------- */
.dialog-mask {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 9500;
    padding: var(--space-5);
}
.dialog {
    width: 100%; max-width: 320px;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}
.dialog-title { font-size: 16px; font-weight: 600; padding: var(--space-4) var(--space-4) 0; }
.dialog-body { padding: var(--space-4); color: var(--text-sub); font-size: 14px; }
.dialog-actions { display: flex; gap: var(--space-2); padding: 0 var(--space-4) var(--space-4); }
.dialog-actions .btn { flex: 1; }

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100vh;
    padding: 0 var(--space-5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(180deg, #eef3f8 0%, var(--bg-page) 40%);
}
.login-brand { text-align: center; margin-bottom: var(--space-6); }
.login-logo {
    width: 60px; height: 60px;
    margin: 0 auto var(--space-3);
    border-radius: 16px;
    background: var(--color-primary);
    color: #fff;
    font-size: 30px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-pop);
}
.login-title { font-size: 19px; font-weight: 600; color: var(--text-main); }
.login-sub { font-size: 13px; color: var(--text-sub); margin-top: var(--space-1); }
.login-card { padding: var(--space-5); }
.login-card .btn { margin-top: var(--space-2); }

/* ---------- 加载遮罩 ---------- */
.loading-mask {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 9000;
}
.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--color-primary-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
