/* =====================================================================
   危废标签称重打印系统 全局样式
   ===================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: "Microsoft YaHei", "SimHei", "PingFang SC", sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
}

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100vh; }
.sidebar {
    width: 210px;
    background: #1f2d3d;
    color: #c0ccda;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.sidebar .logo {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    background: #263445;
    border-bottom: 1px solid #1a2634;
    letter-spacing: 1px;
}
.sidebar .menu-group-title {
    padding: 12px 16px 4px;
    font-size: 12px;
    color: #7f8ea0;
}
.sidebar .menu-item {
    display: block;
    padding: 11px 20px;
    color: #c0ccda;
    text-decoration: none;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .2s;
}
.sidebar .menu-item:hover { background: #33445c; color: #fff; }
.sidebar .menu-item.active { background: #3a5a80; color: #fff; border-left-color: #409eff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e6e8eb;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.topbar .topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar .topbar-title { font-size: 16px; font-weight: 600; }
.topbar .topbar-right { display: flex; align-items: center; gap: 12px; }
/* 汉堡按钮（手机端显示） */
.btn-sidebar {
    display: none;
    background: #409eff; color: #fff; border: none;
    width: 36px; height: 36px; border-radius: 8px;
    font-size: 18px; line-height: 1; cursor: pointer; align-items: center; justify-content: center;
}
.btn-sidebar:active { opacity: .8; }
.topbar .unit-badge {
    background: #ecf5ff; color: #409eff;
    padding: 4px 12px; border-radius: 12px; font-size: 12px;
}
.topbar .remain-badge {
    padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.remain-badge.rb-ok { background: #f0f9eb; color: #67c23a; }
.remain-badge.rb-warn { background: #fdf6ec; color: #e6a23c; animation: rblink 1.6s infinite; }
.remain-badge.rb-expired { background: #fef0f0; color: #f56c6c; animation: rblink 1.2s infinite; }
@keyframes rblink { 0%,100% { opacity: 1; } 50% { opacity: .6; } }
.topbar .user-info { color: #606266; }

.content { flex: 1; overflow-y: auto; padding: 20px; }

/* ---------- 卡片 ---------- */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    padding: 20px;
    margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #1f2d3d; }

/* ---------- 表单 ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.form-group { display: flex; align-items: center; gap: 6px; }
.form-group label { min-width: 80px; text-align: right; color: #606266; }
label.required::before { content: '*'; color: #f56c6c; margin-right: 2px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
select, textarea {
    padding: 7px 10px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    background: #fff;
    color: #333;
    min-width: 160px;
}
input:focus, select:focus, textarea:focus { border-color: #409eff; }
textarea { min-height: 60px; resize: vertical; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
    background: #fff;
}
.btn-primary { background: #409eff; color: #fff; border-color: #409eff; }
.btn-primary:hover { background: #66b1ff; }
.btn-success { background: #67c23a; color: #fff; border-color: #67c23a; }
.btn-success:hover { background: #85ce61; }
.btn-danger { background: #f56c6c; color: #fff; border-color: #f56c6c; }
.btn-danger:hover { background: #f78989; }
.btn-warning { background: #e6a23c; color: #fff; border-color: #e6a23c; }
.btn-warning:hover { background: #ebb563; }
.btn-teal { background: #0f9d8a; color: #fff; border-color: #0f9d8a; }
.btn-teal:hover { background: #14b3a0; }
.btn-plain { background: #fff; color: #606266; border-color: #dcdfe6; }
.btn-plain:hover { border-color: #409eff; color: #409eff; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td {
    border: 1px solid #ebeef5;
    padding: 9px 10px;
    text-align: left;
    white-space: nowrap;
}
table.grid th { background: #f5f7fa; color: #606266; font-weight: 600; }
table.grid tr:hover td { background: #fafafa; }

/* ---------- 状态标签 ---------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; }
.tag-green { background: #f0f9eb; color: #67c23a; }
.tag-red { background: #fef0f0; color: #f56c6c; }
.tag-blue { background: #ecf5ff; color: #409eff; }
.tag-orange { background: #fdf6ec; color: #e6a23c; }
.tag-gray { background: #f4f4f5; color: #909399; }

/* ---------- 称重大屏数字 ---------- */
.weigh-display {
    text-align: center;
    padding: 20px;
    background: #0b2137;
    border-radius: 8px;
    color: #0fe0a0;
}
.weigh-display .weight-num { font-size: 64px; font-weight: bold; font-family: "Consolas", monospace; }
.weigh-display .weight-unit { font-size: 20px; margin-left: 8px; }
.weigh-display .weight-state { font-size: 16px; margin-top: 6px; }

/* ---------- 设备状态 ---------- */
.device-status {
    display: flex; gap: 20px; flex-wrap: wrap;
}
.device-card {
    flex: 1; min-width: 260px;
    border: 1px solid #ebeef5;
    border-radius: 8px;
    padding: 16px;
}
.device-card .dev-name { font-weight: 600; margin-bottom: 8px; }
.device-card .dev-state { font-size: 13px; color: #606266; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot-green { background: #67c23a; }
.dot-red { background: #f56c6c; }
.dot-gray { background: #909399; }

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-mask.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 8px;
    width: 640px;
    max-width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal-footer { margin-top: 16px; text-align: right; }

/* ---------- 标签预览 ---------- */
.label-preview {
    width: 320px; height: 320px;
    border: 2px solid #333;
    margin: 0 auto;
    position: relative;
    background: #fff;
    overflow: hidden;
}
.label-preview canvas { display: block; width: 100%; height: 100%; }

/* ---------- 提示 ---------- */
.toast {
    position: fixed; top: 70px; left: 50%;
    transform: translateX(-50%);
    background: #303133; color: #fff;
    padding: 10px 20px; border-radius: 4px;
    z-index: 2000; display: none;
}
.toast.show { display: block; }
.toast-success { background: #67c23a; }
.toast-error { background: #f56c6c; }

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pagination .page-btn {
    padding: 4px 10px; border: 1px solid #dcdfe6; border-radius: 3px;
    cursor: pointer; background: #fff; color: #606266;
}
.pagination .page-btn.active { background: #409eff; color: #fff; border-color: #409eff; }
.pagination .page-btn:disabled { opacity: .5; cursor: not-allowed; }
.pagination .pg-info { color: #909399; font-size: 13px; }
.pagination .pg-jump, .pagination .pg-size { color: #606266; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.pagination .pg-jump input, .pagination .pg-size select { padding: 4px 6px; border: 1px solid #dcdfe6; border-radius: 3px; }

/* ---------- 可排序表头 ---------- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: #409eff; }
th .sort-arrow { color: #409eff; font-size: 10px; }

/* ---------- 菜单标签页 ---------- */
.tab-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px 0;
    background: #f0f2f5;
    border-bottom: 1px solid #e6e8eb;
    overflow-x: auto;
    min-height: 38px;
}
.tab-bar .tab-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: #fff;
    border: 1px solid #e6e8eb;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    color: #606266;
    font-size: 13px;
    white-space: nowrap;
}
.tab-bar .tab-item.active { color: #409eff; font-weight: 600; background: #fff; box-shadow: 0 -2px 0 #409eff inset; }
.tab-bar .tab-item .tab-close { color: #c0c4cc; font-size: 15px; line-height: 1; margin-left: 4px; }
.tab-bar .tab-item .tab-close:hover { color: #f56c6c; }

/* ---------- 标签页内容 iframe ---------- */
#tabContainer { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.tab-frame {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: none;
    background: #f0f2f5;
    display: none;
}
.tab-frame.active { display: block; }

/* 内嵌模式（iframe 内容页） */
.embed-wrap { min-height: 100vh; padding: 16px; }
.embed-wrap .content { padding: 0; }

/* ---------- 单位选择器（下拉+模糊搜索） ---------- */
.unit-picker { position: relative; width: 100%; }
.unit-picker > input[type=text] { width: 100%; min-width: 220px; }
.unit-picker-drop {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
    max-height: 200px; overflow-y: auto; background: #fff;
    border: 1px solid #dcdfe6; border-radius: 4px; box-shadow: 0 2px 12px rgba(0,0,0,.1);
    display: none;
}
.unit-picker-drop .up-item { padding: 8px 12px; cursor: pointer; color: #333; }
.unit-picker-drop .up-item:hover { background: #ecf5ff; color: #409eff; }
.unit-picker-drop .up-empty { padding: 10px 12px; color: #909399; font-size: 13px; }
.unit-picker-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.up-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #ecf5ff; color: #409eff; border-radius: 12px; padding: 3px 10px; font-size: 12px;
}
.up-chip i { cursor: pointer; font-style: normal; color: #a0cfff; }
.up-chip i:hover { color: #f56c6c; }

/* ---------- 操作权限勾选 ---------- */
.perm-box { display: flex; flex-wrap: wrap; gap: 8px; }
.perm-item {
    display: inline-flex; align-items: center; gap: 4px;
    background: #f4f4f5; border-radius: 4px; padding: 5px 10px; cursor: pointer; font-size: 13px;
}
.perm-item input { accent-color: #409eff; }

/* ---------- 打印状态 ---------- */
.print-preview-box { border: 1px dashed #909399; padding: 10px; border-radius: 4px; background: #fafafa; }

/* ---------- 统计卡片 ---------- */
.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 180px; background: #fff; border-radius: 8px; padding: 16px 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.stat-card .stat-value { font-size: 26px; font-weight: bold; color: #409eff; }
.stat-card .stat-label { color: #909399; margin-top: 4px; }

.empty-tip { text-align: center; color: #909399; padding: 40px 0; }

/* ==================== 收益明细（支付宝基金式） ==================== */
.up { color: #f56c6c; }        /* 收益为正：红色 */
.down { color: #67c23a; }      /* 退款/负收益：绿色 */

.rv-range, .rv-view { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.rv-btn {
    padding: 5px 14px; border: 1px solid #dcdfe6; border-radius: 14px;
    background: #fff; color: #606266; cursor: pointer; font-size: 13px; transition: all .2s;
}
.rv-btn:hover { border-color: #409eff; color: #409eff; }
.rv-btn.active { background: #409eff; border-color: #409eff; color: #fff; }

.rev-overview { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0 4px; }
.rev-main { flex: 1; min-width: 320px; }
.rev-net-label { color: #909399; font-size: 13px; }
.rev-net-label span { color: #409eff; margin-left: 4px; }
.rev-net-num { font-size: 42px; font-weight: 800; color: #1f2d3d; margin: 6px 0 4px; }
.rev-sub { display: flex; gap: 18px; flex-wrap: wrap; color: #606266; font-size: 13px; }
.rev-sub b { font-size: 15px; }

.rev-tiles { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.rev-tile {
    flex: 1; min-width: 150px; background: #f8f9fb; border: 1px solid #ebeef5;
    border-radius: 8px; padding: 14px 16px;
}
.rev-tile .rt-label { color: #909399; font-size: 13px; }
.rev-tile .rt-val { font-size: 24px; font-weight: 700; margin-top: 6px; }

.rev-chart { margin-top: 8px; }
.rv-bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; overflow-x: auto; padding-top: 8px; border-bottom: 1px solid #ebeef5; }
.rv-bar-item { flex: 1; min-width: 18px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.rv-bar { width: 70%; border-radius: 3px 3px 0 0; min-height: 2px; }
.rv-bar-label { font-size: 10px; color: #909399; margin-top: 4px; white-space: nowrap; transform: rotate(-45deg); transform-origin: top left; }

.rev-cal-head { display: flex; align-items: center; gap: 16px; justify-content: center; margin: 12px 0 16px; }
.rev-cal-title { font-size: 18px; font-weight: 700; min-width: 140px; text-align: center; }
.rv-arrow {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid #dcdfe6;
    background: #fff; color: #606266; font-size: 20px; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.rv-arrow:hover { border-color: #409eff; color: #409eff; }

.rev-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.rc-head { text-align: center; color: #909399; font-size: 12px; padding: 6px 0; }
.rc-cell {
    min-height: 68px; border: 1px solid #ebeef5; border-radius: 6px; padding: 6px;
    cursor: pointer; background: #fff; transition: all .15s;
}
.rc-cell:hover { border-color: #409eff; }
.rc-cell.rc-today { border-color: #409eff; box-shadow: 0 0 0 1px #409eff inset; }
.rc-cell.rc-sel { background: #ecf5ff; }
.rc-cell.rc-blank { cursor: default; border-color: transparent; background: transparent; }
.rc-cell .rc-day { color: #606266; font-weight: 600; }
.rc-cell.rc-today .rc-day { color: #409eff; }
.rc-income { color: #f56c6c; font-size: 12px; font-weight: 700; }
.rc-refund { color: #67c23a; font-size: 12px; font-weight: 700; }

.rev-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rv-card {
    border: 1px solid #ebeef5; border-radius: 10px; padding: 14px; cursor: pointer;
    background: #fff; transition: all .15s; text-align: center;
}
.rv-card:hover { border-color: #409eff; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(64,158,255,.12); }
.rv-card.rv-cur { border-color: #409eff; background: #ecf5ff; }
.rv-card.rv-sel { background: #ecf5ff; }
.rv-card .rc-label { font-weight: 600; color: #1f2d3d; font-size: 14px; }
.rv-card .rc-net { font-size: 20px; font-weight: 800; margin: 8px 0 4px; }
.rv-card .rc-mini { color: #909399; font-size: 11px; }

/* ==================== 首页单位状态卡片 ==================== */
.ustat-cards { display: flex; gap: 14px; flex-wrap: wrap; }
.ustat-card {
    flex: 1; min-width: 150px; display: flex; align-items: center; gap: 12px;
    background: #fff; border: 1px solid #ebeef5; border-radius: 10px; padding: 14px 16px;
    cursor: pointer; transition: all .15s;
}
.ustat-card:hover { border-color: #409eff; box-shadow: 0 4px 12px rgba(64,158,255,.12); }
.ustat-card.us-active { border-color: #409eff; background: #f7fbff; }
.ustat-card .us-ico { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.ustat-card .us-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.ustat-card .us-label { color: #909399; font-size: 12px; margin-top: 2px; }

/* ==================== 手机端响应式：左侧菜单可折叠 ==================== */
@media (max-width: 768px) {
    .layout { position: relative; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000;
        width: 220px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 2px 0 14px rgba(0,0,0,.25);
    }
    .layout.sidebar-open .sidebar { transform: translateX(0); }
    .btn-sidebar { display: inline-flex; }
    .topbar { padding: 0 10px; }
    .topbar .topbar-title { font-size: 14px; }
    .topbar .topbar-right { gap: 6px; }
    .topbar .unit-badge, .topbar .remain-badge { padding: 3px 8px; font-size: 11px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tab-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
