/* ============================================================
   CPT 数控控制管理系统 H5 版
   由 Android (CptSfCtrol) 转换 - 移动端优先样式
   ============================================================ */

:root {
    --primary: #3F51B5;        /* 对应 colorPrimary */
    --primary-dark: #303F9F;   /* 对应 colorPrimaryDark */
    --primary-light: #C5CAE9;
    --accent: #FF4081;         /* 对应 colorAccent */
    --red: #e53935;
    --blue: #1e88e5;
    --purple: #bf12ce;
    --green: #118822;
    --text: #212121;
    --text2: #757575;
    --bg: #f0f2f5;
    --card: #ffffff;
    --line: #e4e7ed;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

/* ---------- 页面容器 ----------
   限制为手机宽度并水平居中：手机上占满全屏，
   浏览器等宽屏上按 480px 宽居中显示（模拟手机） */
.page {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: none;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
    z-index: 10;
    box-shadow: 0 0 26px rgba(0,0,0,.28);
}
.page.active { display: flex; }
.modal-page { z-index: 20; }

/* ---------- 顶部栏（Toolbar 还原） ---------- */
.appbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 52px;
    padding: 0 12px;
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
    padding-top: env(safe-area-inset-top);
    height: calc(52px + env(safe-area-inset-top));
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.appbar-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.icon-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
}
.icon-btn:active { background: rgba(255,255,255,.15); }

/* ---------- Tab（TabLayout 还原） ---------- */
.tabs {
    display: flex;
    background: var(--primary);
    flex-shrink: 0;
}
.tab {
    flex: 1;
    text-align: center;
    padding: 12px 4px;
    color: rgba(255,255,255,.7);
    font-size: 14px;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}
.tab.active {
    color: #fff;
    font-weight: 600;
    border-bottom-color: #fff;
}

.tab-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tab-panel { display: none; padding: 10px; }
.tab-panel.active { display: block; }

/* ---------- 登录页 ---------- */
#page-login {
    background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 55%, #1a237e 100%);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}
.login-header { text-align: center; color: #fff; margin-bottom: 34px; padding: 0 20px; }
.login-logo {
    width: 88px; height: 88px;
    margin: 0 auto 14px;
    background: rgba(255,255,255,.14);
    border-radius: 22px;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.login-header h1 { font-size: 24px; letter-spacing: 2px; }
.login-header p { margin-top: 8px; font-size: 13px; opacity: .85; }

.login-form {
    width: min(92vw, 380px);
    background: var(--card);
    border-radius: 14px;
    padding: 26px 22px;
    box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.field { margin-bottom: 16px; }
.field input {
    width: 100%;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 15px;
    background: #fafafa;
    outline: none;
    transition: border .2s;
}
.field input:focus { border-color: var(--primary); background: #fff; }
.field-error { display: block; color: var(--red); font-size: 12px; margin-top: 5px; min-height: 14px; }
.remember-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
    margin: -4px 0 16px;
    cursor: pointer;
    user-select: none;
}
.remember-row input { accent-color: var(--primary); width: 16px; height: 16px; }
.login-tip { text-align: center; color: var(--text2); font-size: 12px; margin-top: 14px; }

/* ---------- 按钮 ---------- */
button { font-family: inherit; cursor: pointer; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 4px;
    transition: filter .15s;
}
.btn-primary:active { filter: brightness(.85); }
.btn-block { display: block; width: 100%; }
.flex1 { flex: 1; }

.btn-light {
    background: #fff;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    padding: 9px 10px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: var(--shadow);
}
.btn-light:active { background: var(--primary-light); }

.btn-outline {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    width: 100%;
}
.btn-outline:active { filter: brightness(.95); }
.btn-red { color: var(--red); border-color: rgba(229,57,53,.45); }
.btn-blue { color: var(--blue); border-color: rgba(30,136,229,.45); }

/* ---------- 工具行 ---------- */
.toolbar-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
/* 吸顶工具栏：页面滚动时按钮固定在顶部（列表滚动容器为 .tab-body） */
.sticky-tools {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    /* 抵消 .tab-panel 的内边距，吸顶时铺满滚动区顶部，避免内容从缝隙中穿过 */
    margin: -10px -10px 8px;
    padding: 10px 10px 4px;
    border-bottom: 1px solid var(--line);
}
.list-tip { color: var(--text2); font-size: 12px; text-align: center; margin: 2px 0 8px; }

/* ---------- 卡片列表（ListView 还原） ---------- */
.card-list { list-style: none; }
.card-list > li {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 14px;
    margin-bottom: 10px;
    position: relative;
}
.card-list > li:active { background: #f7f8fc; }
.empty-tip {
    text-align: center;
    color: var(--text2);
    padding: 36px 0 !important;
    font-size: 14px;
}

/* 机器条目（machine_listview_item.xml 还原） */
.mach-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.mach-name { font-size: 19px; font-weight: 700; color: var(--primary); }
.mach-id { font-size: 22px; font-weight: 800; color: var(--red); }
/* 升级/指令状态：条目中间部位第二排（与右侧"已审核"同一高度） */
.mach-state {
    position: absolute;
    left: 50%;
    top: 38px;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    max-width: 40%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.st-on { color: var(--green); }
.st-off { color: #fb8c00; }
.st-sep { color: var(--text2); margin: 0 3px; }
.mach-os { font-size: 13px; color: #aa2200; margin-top: 4px; }
.mach-code { font-size: 13px; color: var(--green); margin-top: 2px; word-break: break-all; }
.mach-login { font-size: 12px; color: var(--purple); margin-top: 2px; }
.mach-version { font-size: 12px; color: #2255ff; margin-top: 2px; }
.mach-right { position: absolute; right: 14px; top: 12px; text-align: right; }
.mach-regdate { font-size: 12px; color: var(--text2); }
.mach-checkval { font-size: 14px; font-weight: 600; margin-top: 2px; }
.mach-shengyu { font-size: 15px; font-weight: 700; color: var(--red); margin-top: 2px; }
.mach-lastshengyu {
    position: absolute;
    right: 14px;
    bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #0000ff;
}
.mach-remark {
    position: absolute;
    left: 50%; top: 16px;
    transform: translateX(-50%);
    font-size: 12px;
    color: var(--purple);
    max-width: 34%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.check-badge { color: var(--green); }
.uncheck-badge { color: var(--orange, #fb8c00); }
.mach-selected {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: #fff5f8;
}

/* 充值条目（chongzhi_listview_item.xml 还原） */
.cz-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.cz-user { font-size: 16px; font-weight: 700; color: var(--primary); }
.cz-liushui { font-size: 10px; color: var(--text2); }
.cz-machinecode {
    margin: 0 auto;
    font-size: 11px;
    color: var(--purple);
    max-width: 40%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cz-remark {
    margin-left: auto;
    font-size: 11px;
    color: var(--purple);
    max-width: 30%;
    white-overflow: hidden;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cz-row { display: flex; justify-content: space-between; margin-top: 6px; }
.cz-mishu { font-size: 14px; font-weight: 600; color: var(--primary); }
.cz-createdate { font-size: 12px; color: var(--purple); }
.cz-rmb { font-size: 14px; font-weight: 600; color: var(--primary); }
.cz-ischeck { font-size: 12px; color: var(--purple); }
.cz-pending { color: #fb8c00; font-weight: 700; }
.cz-pasted { color: var(--green); font-weight: 700; }

/* 提交记录条目（shengyu_mishu_listview_item.xml 还原） */
.ms-shengyu { font-size: 16px; font-weight: 700; color: var(--primary); }
.ms-outline { font-size: 13px; color: var(--purple); margin-top: 2px; }
.ms-createdate { font-size: 12px; color: var(--text2); }
.ms-version {
    font-size: 14px;
    font-weight: 700;
    color: var(--red);
    margin-top: 2px;
    text-align: right;
}

/* ---------- 面板（详情/管理页） ---------- */
.panel { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; }
.personal-head {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 14px;
    position: relative;
    min-height: 92px;
}
.ph-name { font-size: 20px; font-weight: 700; color: var(--primary); }
.ph-code { font-size: 13px; color: var(--purple); margin-top: 6px; text-align: center; }
.ph-remark { font-size: 12px; color: var(--red); margin-top: 4px; text-align: center; }
.ph-meta {
    position: absolute; right: 14px; top: 12px;
    text-align: right;
    font-size: 12px; color: var(--text2);
}
.ph-meta span { display: block; margin-bottom: 4px; }
.ph-meta .ph-checkval { font-size: 14px; font-weight: 600; color: var(--text); }

.section-title { font-size: 14px; color: var(--text2); margin: 6px 0 10px; font-weight: 600; }

/* 开关行 */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    font-size: 15px;
}
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0;
    background: #cfd2da;
    border-radius: 26px;
    transition: .25s;
}
.slider::before {
    content: "";
    position: absolute;
    width: 20px; height: 20px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .25s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* 复选框网格（content_personal_info_manage.xml 还原：
   Android 三行排列为 5个/4个/4个，此处用 5 列网格，
   让第 10 个(CeXie)强制另起一行实现 5/4/4，POS 不再独占一行 */
.chk-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.chk-grid .chk:nth-child(10) { grid-column-start: 1; }
.chk {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 2px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--shadow);
}
.chk input { accent-color: var(--primary); width: 15px; height: 15px; }

/* 输入行 */
.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.input-row label { font-size: 15px; white-space: nowrap; }
.input-row input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
    min-width: 0;
}

/* ---------- 弹窗（ChongZhiCheckActivity 还原） ---------- */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    padding: 24px;
}
.modal-mask.hidden { display: none; }
.modal-card {
    width: min(92vw, 400px);
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.modal-card h3 { font-size: 18px; margin-bottom: 14px; color: var(--primary-dark); }
.check-user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f6fa;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 14px;
}
.czc-rmb { color: var(--red); font-weight: 700; font-size: 17px; }
.modal-btns { display: flex; gap: 10px; margin-top: 6px; }
.modal-btns .btn-outline { margin-bottom: 0; }

/* ---------- Toast（Toast 还原） ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 14%;
    transform: translateX(-50%);
    background: rgba(30,30,30,.88);
    color: #fff;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 14px;
    max-width: 80vw;
    text-align: center;
    z-index: 100;
    box-shadow: 0 4px 14px rgba(0,0,0,.3);
    animation: toast-in .2s ease;
}
.toast.hidden { display: none; }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 加载指示（ProgressDialog 还原） ---------- */
.loading-overlay {
    position: absolute; inset: 0;
    background: rgba(255,255,255,.82);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 50;
    color: var(--text2);
    font-size: 14px;
}
.loading-overlay.hidden { display: none; }
#global-loading { position: fixed; z-index: 90; }
.spinner {
    width: 42px; height: 42px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ---------- 小屏适配 ---------- */
@media (max-width: 360px) {
    .chk-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
    .toolbar-row { flex-wrap: wrap; }
    .toolbar-row .btn-light { flex: 1 1 30%; }
}
