/* ============================================================
   工单业务支撑系统 · 移动端(H5)样式
   ------------------------------------------------------------
   入口:public/m/index.php → app/Views/m.php
   特点:移动优先、相对单位、底部 tab 栏、安全区适配(iPhone 刘海屏)
        不引入任何外部 CDN / UI 框架,全部手写
   ============================================================ */

/* ---------------- 变量与重置 ---------------- */
:root {
    --m-primary: #2563eb;
    --m-primary-dark: #1d4ed8;
    --m-primary-soft: #eff6ff;
    --m-green: #16a34a;
    --m-orange: #ea580c;
    --m-red: #dc2626;
    --m-gray: #6b7280;
    --m-text: #111827;
    --m-text-2: #4b5563;
    --m-text-3: #9ca3af;
    --m-line: #e5e7eb;
    --m-bg: #f4f5f7;
    --m-card: #ffffff;
    --m-radius: 12px;
    --m-bar-h: 48px;
    --m-tab-h: 54px;
    --m-safe-b: env(safe-area-inset-bottom, 0px);
    --m-safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body { overflow-x: hidden; }

a { color: var(--m-primary); text-decoration: none; }
img { max-width: 100%; display: block; border: 0; }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* ---------------- 启动占位 ---------------- */
.m-boot {
    padding: 40vh 0 0;
    text-align: center;
    color: var(--m-text-3);
    font-size: 14px;
}
.m-spinner {
    width: 26px; height: 26px;
    margin: 0 auto 12px;
    border: 2px solid var(--m-line);
    border-top-color: var(--m-primary);
    border-radius: 50%;
    animation: m-spin .8s linear infinite;
}
@keyframes m-spin { to { transform: rotate(360deg); } }

.m-loading { padding: 28px 0; text-align: center; color: var(--m-text-3); font-size: 14px; }
.m-loading .m-spinner { width: 20px; height: 20px; margin-bottom: 8px; }

/* ---------------- 骨架 ---------------- */
.m-app { min-height: 100vh; display: flex; flex-direction: column; }

.m-bar {
    position: sticky;
    top: 0;
    z-index: 60;
    height: calc(var(--m-bar-h) + var(--m-safe-t));
    padding-top: var(--m-safe-t);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 8px;
    padding-right: 8px;
    background: var(--m-primary);
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}
.m-bar__back {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    border: 0; color: #fff; font-size: 18px; line-height: 1;
    cursor: pointer;
}
.m-bar__title { flex: 1; font-size: 17px; font-weight: 600; text-align: center; }
.m-bar__aside { min-width: 34px; text-align: right; font-size: 13px; }
.m-bar__aside a { color: #fff; opacity: .92; }

.m-body {
    flex: 1;
    padding: 10px 10px calc(var(--m-tab-h) + var(--m-safe-b) + 18px);
}
.m-body--plain { padding-bottom: 20px; }

/* ---------------- 底部 tab 栏 ---------------- */
.m-tab {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 70;
    display: flex;
    height: calc(var(--m-tab-h) + var(--m-safe-b));
    padding-bottom: var(--m-safe-b);
    background: #fff;
    border-top: 1px solid var(--m-line);
}
.m-tab__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--m-text-3);
    position: relative;
}
.m-tab__item.is-active { color: var(--m-primary); }
.m-tab__icon { font-size: 19px; line-height: 1; }
.m-tab__badge {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--m-red);
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

/* ---------------- 卡片 / 区块 ---------------- */
.m-card {
    background: var(--m-card);
    border-radius: var(--m-radius);
    margin-bottom: 10px;
    overflow: hidden;
}
.m-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--m-line);
    font-size: 15px;
    font-weight: 600;
}
.m-card__head .m-more { font-size: 13px; font-weight: 400; color: var(--m-text-3); }
.m-card__body { padding: 14px; }
.m-card__body--tight { padding: 0; }

.m-section-title {
    margin: 4px 2px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--m-text-2);
}

/* ---------------- 首页 ---------------- */
.m-hero {
    margin: -10px -10px 10px;
    padding: 18px 16px 22px;
    background: linear-gradient(135deg, var(--m-primary), #4f8ef7);
    color: #fff;
    border-radius: 0 0 16px 16px;
}
.m-hero__hi { font-size: 13px; opacity: .9; }
.m-hero__name { margin-top: 2px; font-size: 20px; font-weight: 600; }
.m-hero__stat { display: flex; margin-top: 14px; gap: 8px; }
.m-hero__stat > div { flex: 1; background: rgba(255, 255, 255, .16); border-radius: 10px; padding: 8px 10px; }
.m-hero__stat b { display: block; font-size: 17px; }
.m-hero__stat span { font-size: 11px; opacity: .9; }

.m-banner { position: relative; margin-bottom: 10px; border-radius: var(--m-radius); overflow: hidden; background: #fff; }
.m-banner__track { display: flex; transition: transform .35s ease; }
.m-banner__item { flex: 0 0 100%; height: 158px; }
.m-banner__item img { width: 100%; height: 100%; object-fit: cover; }
.m-banner__ph {
    height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    color: var(--m-primary);
    font-size: 15px;
    padding: 0 16px;
    text-align: center;
}
.m-banner__dots { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; justify-content: center; gap: 5px; }
.m-banner__dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .55); }
.m-banner__dots i.is-on { background: #fff; width: 14px; border-radius: 3px; }

.m-notice {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; margin-bottom: 10px;
    background: #fff7ed; border-radius: var(--m-radius);
    color: #9a3412; font-size: 13px;
}
.m-notice__tag { flex: 0 0 auto; font-weight: 600; }
.m-notice__text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.m-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.m-grid__item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 4px; border-radius: 10px; color: var(--m-text-2); font-size: 12px;
    text-align: center;
}
.m-grid__item:active { background: var(--m-primary-soft); }
.m-grid__icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--m-primary-soft); color: var(--m-primary);
    font-size: 20px; overflow: hidden;
}
.m-grid__icon img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------- 列表 ---------------- */
.m-list { background: #fff; border-radius: var(--m-radius); overflow: hidden; }
.m-item {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid var(--m-line);
    color: inherit;
}
.m-item:last-child { border-bottom: 0; }
.m-item:active { background: #f9fafb; }
.m-item__top { display: flex; align-items: center; gap: 8px; }
.m-item__title {
    flex: 1;
    font-size: 15px; font-weight: 500;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.m-item__no { margin-top: 3px; font-size: 12px; color: var(--m-text-3); }
.m-item__meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--m-text-3); }
.m-item__foot { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.m-tabs {
    display: flex; gap: 6px; overflow-x: auto;
    padding: 0 0 8px; margin: 0 -2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.m-tabs::-webkit-scrollbar { display: none; }
.m-tabs__item {
    flex: 0 0 auto;
    padding: 5px 12px;
    border-radius: 14px;
    background: #fff;
    color: var(--m-text-2);
    font-size: 13px;
    border: 1px solid var(--m-line);
    cursor: pointer;
}
.m-tabs__item.is-active { background: var(--m-primary); border-color: var(--m-primary); color: #fff; }

/* ---------------- 状态标签 ---------------- */
.m-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11px;
    line-height: 17px;
    white-space: nowrap;
    background: #eef2ff; color: var(--m-primary);
}
.m-tag--green { background: #dcfce7; color: #15803d; }
.m-tag--orange { background: #ffedd5; color: #c2410c; }
.m-tag--red { background: #fee2e2; color: #b91c1c; }
.m-tag--gray { background: #f3f4f6; color: #4b5563; }
.m-tag--blue { background: #dbeafe; color: #1d4ed8; }

/* ---------------- 表单 ---------------- */
.m-field { margin-bottom: 14px; }
.m-field__label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--m-text-2); }
.m-field__label .req { color: var(--m-red); margin-left: 2px; }
.m-input, .m-textarea, .m-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--m-line);
    border-radius: 10px;
    background: #fff;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.m-textarea { min-height: 88px; resize: vertical; }
.m-input:focus, .m-textarea:focus, .m-select:focus { border-color: var(--m-primary); }
.m-field__hint { margin-top: 4px; font-size: 12px; color: var(--m-text-3); }

.m-radio-group, .m-check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.m-opt {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px; border: 1px solid var(--m-line); border-radius: 18px;
    background: #fff; font-size: 13px; cursor: pointer;
}
.m-opt input { margin: 0; }
.m-opt.is-on { border-color: var(--m-primary); background: var(--m-primary-soft); color: var(--m-primary-dark); }

.m-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

.m-upload {
    display: flex; align-items: center; justify-content: center;
    height: 84px; border: 1px dashed var(--m-line); border-radius: 10px;
    background: #fafafa; color: var(--m-text-3); font-size: 13px; cursor: pointer;
}
.m-upload__preview { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.m-upload__preview a, .m-upload__preview img {
    width: 72px; height: 72px; border-radius: 8px; object-fit: cover;
    border: 1px solid var(--m-line); background: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: var(--m-text-2); text-align: center; padding: 4px; overflow: hidden;
}

/* ---------------- 按钮 ---------------- */
.m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--m-line);
    border-radius: 10px;
    background: #fff;
    color: var(--m-text);
    font-size: 15px;
    cursor: pointer;
}
.m-btn:active { opacity: .85; }
.m-btn[disabled] { opacity: .55; cursor: not-allowed; }
.m-btn--primary { background: var(--m-primary); border-color: var(--m-primary); color: #fff; }
.m-btn--danger { background: var(--m-red); border-color: var(--m-red); color: #fff; }
.m-btn--ghost { background: #fff; color: var(--m-primary); border-color: var(--m-primary); }
.m-btn--block { width: 100%; }
.m-btn--sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.m-btn-row { display: flex; gap: 8px; margin-top: 14px; }
.m-btn-row .m-btn { flex: 1; }

.m-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------- 详情 ---------------- */
.m-detail-head {
    padding: 14px;
    background: #fff;
    border-radius: var(--m-radius);
    margin-bottom: 10px;
}
.m-detail-head__title { font-size: 17px; font-weight: 600; }
.m-detail-head__line { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--m-text-3); }

.m-kv { display: flex; padding: 9px 0; border-bottom: 1px dashed var(--m-line); font-size: 14px; }
.m-kv:last-child { border-bottom: 0; }
.m-kv__k { flex: 0 0 42%; color: var(--m-text-3); }
.m-kv__v { flex: 1; word-break: break-all; }

.m-timeline { padding: 4px 0 0; }
.m-timeline__item { position: relative; padding: 0 0 14px 18px; border-left: 1px solid var(--m-line); }
.m-timeline__item:last-child { border-left-color: transparent; padding-bottom: 0; }
.m-timeline__item::before {
    content: ''; position: absolute; left: -4px; top: 5px;
    width: 7px; height: 7px; border-radius: 50%; background: var(--m-primary);
}
.m-timeline__title { font-size: 14px; font-weight: 500; }
.m-timeline__meta { margin-top: 2px; font-size: 12px; color: var(--m-text-3); }
.m-timeline__remark { margin-top: 4px; font-size: 13px; color: var(--m-text-2); white-space: pre-wrap; word-break: break-word; }

.m-attach { display: flex; flex-wrap: wrap; gap: 8px; }
.m-attach__item {
    width: 76px; height: 76px; border-radius: 8px; border: 1px solid var(--m-line);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; font-size: 11px; color: var(--m-text-2); background: #fff;
    padding: 4px; overflow: hidden; text-align: center;
}
.m-attach__item img { width: 100%; height: 52px; object-fit: cover; border-radius: 6px; }
.m-attach__item span { width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.m-stars { display: flex; gap: 6px; font-size: 26px; color: #d1d5db; }
.m-stars i { cursor: pointer; line-height: 1; font-style: normal; }
.m-stars i.is-on { color: #f59e0b; }

/* ---------------- 个人中心 ---------------- */
.m-me {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 14px; margin: -10px -10px 10px;
    background: linear-gradient(135deg, var(--m-primary), #4f8ef7);
    color: #fff;
    border-radius: 0 0 16px 16px;
}
.m-me__avatar {
    width: 54px; height: 54px; border-radius: 50%;
    background: rgba(255, 255, 255, .25);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; overflow: hidden;
}
.m-me__avatar img { width: 100%; height: 100%; object-fit: cover; }
.m-me__name { font-size: 17px; font-weight: 600; }
.m-me__sub { margin-top: 2px; font-size: 12px; opacity: .9; }

.m-wallet { display: flex; background: #fff; border-radius: var(--m-radius); margin-bottom: 10px; overflow: hidden; }
.m-wallet__cell { flex: 1; padding: 12px 6px; text-align: center; border-right: 1px solid var(--m-line); }
.m-wallet__cell:last-child { border-right: 0; }
.m-wallet__cell b { display: block; font-size: 18px; color: var(--m-primary); }
.m-wallet__cell span { font-size: 12px; color: var(--m-text-3); }

.m-cells { background: #fff; border-radius: var(--m-radius); overflow: hidden; margin-bottom: 10px; }
.m-cell {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 14px; border-bottom: 1px solid var(--m-line);
    color: inherit; font-size: 15px;
}
.m-cell:last-child { border-bottom: 0; }
.m-cell:active { background: #f9fafb; }
.m-cell__icon { width: 22px; text-align: center; color: var(--m-primary); }
.m-cell__label { flex: 1; }
.m-cell__value { font-size: 13px; color: var(--m-text-3); }
.m-cell__arrow { color: var(--m-text-3); font-size: 13px; }

/* ---------------- 空态 / 提示 ---------------- */
.m-empty { padding: 46px 16px; text-align: center; color: var(--m-text-3); font-size: 14px; }
.m-empty__icon { font-size: 34px; opacity: .35; margin-bottom: 8px; }
.m-hint { font-size: 12px; color: var(--m-text-3); }
.m-error { padding: 30px 16px; text-align: center; color: var(--m-red); font-size: 14px; }

.m-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 0 4px; font-size: 13px; color: var(--m-text-3); }

/* ---------------- 登录 / 注册 ---------------- */
.m-auth { min-height: 100vh; padding: 46px 22px 30px; background: #fff; }
.m-auth__logo { text-align: center; margin-bottom: 26px; }
.m-auth__logo .mark {
    width: 62px; height: 62px; margin: 0 auto 10px; border-radius: 18px;
    background: linear-gradient(135deg, var(--m-primary), #60a5fa);
    color: #fff; font-size: 28px; display: flex; align-items: center; justify-content: center;
}
.m-auth__logo h1 { font-size: 19px; font-weight: 600; }
.m-auth__logo p { margin-top: 4px; font-size: 12px; color: var(--m-text-3); }
.m-auth__switch { margin-top: 18px; text-align: center; font-size: 13px; color: var(--m-text-3); }
.m-auth__switch a { margin-left: 4px; }
.m-auth__tip { margin-bottom: 14px; padding: 9px 12px; border-radius: 8px; background: #fff7ed; color: #9a3412; font-size: 13px; }
.m-auth__foot { margin-top: 26px; text-align: center; font-size: 12px; color: var(--m-text-3); }
.m-code-row { display: flex; gap: 8px; }
.m-code-row .m-input { flex: 1; }
.m-code-row .m-btn { flex: 0 0 auto; white-space: nowrap; }

/* ---------------- 弹窗 / Toast ---------------- */
.m-modal-mask {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0, 0, 0, .45);
    display: flex; align-items: flex-end; justify-content: center;
}
.m-modal {
    width: 100%; max-height: 82vh; overflow-y: auto;
    background: #fff; border-radius: 16px 16px 0 0;
    padding-bottom: var(--m-safe-b);
    animation: m-up .22s ease;
}
@keyframes m-up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.m-modal__head { padding: 15px 16px 10px; font-size: 16px; font-weight: 600; text-align: center; }
.m-modal__body { padding: 0 16px 6px; font-size: 14px; color: var(--m-text-2); }
.m-modal__foot { display: flex; gap: 10px; padding: 12px 16px 16px; }
.m-modal__foot .m-btn { flex: 1; }

.m-toast-wrap {
    position: fixed; left: 0; right: 0; top: 30%; z-index: 300;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    pointer-events: none;
}
.m-toast {
    max-width: 78%;
    padding: 9px 14px; border-radius: 10px;
    background: rgba(17, 24, 39, .88); color: #fff; font-size: 14px;
    word-break: break-word; text-align: center;
}

/* ---------------- 富文本内容 ---------------- */
.m-richtext { font-size: 15px; color: var(--m-text-2); line-height: 1.75; word-break: break-word; }
.m-richtext img { margin: 8px 0; border-radius: 8px; }
.m-richtext p { margin: 0 0 10px; }
.m-richtext h1, .m-richtext h2, .m-richtext h3 { margin: 12px 0 8px; font-size: 16px; color: var(--m-text); }
.m-richtext table { width: 100%; border-collapse: collapse; font-size: 13px; }
.m-richtext td, .m-richtext th { border: 1px solid var(--m-line); padding: 5px 7px; }
.m-richtext pre { overflow-x: auto; background: #f3f4f6; padding: 10px; border-radius: 8px; font-size: 13px; }
.m-rich-preview { max-height: 320px; overflow-y: auto; padding: 12px; background: #fafafa; border-radius: 10px; }

/* ---------------- 大屏(平板/桌面预览) ---------------- */
@media (min-width: 640px) {
    .m-app, .m-auth { max-width: 520px; margin: 0 auto; background: var(--m-bg); box-shadow: 0 0 22px rgba(0, 0, 0, .07); }
    .m-auth { background: #fff; }
    .m-tab { left: 50%; right: auto; width: 520px; transform: translateX(-50%); }
    .m-modal-mask { align-items: center; }
    .m-modal { max-width: 460px; border-radius: 16px; }
}
