/* ===================== 基础重置 ===================== */
#username {
    width: 120px;          /* 你可以改成 150 或其他大小 */
    padding: 4px 6px;
    border-radius: 4px;
    border: 1px solid #ccc;
}
#logout-btn {
    margin-left: 10px;
}
.user-manage {
    display: flex;
    flex-wrap: wrap; /* 自动换行 */
    align-items: center;
    gap: 8px;
}
.group-title {
    font-weight: bold;
    font-size: 20px;
    color: #FF4500;
}
.user-manage input {
    width: 100px;          /* 🔹缩短宽度，避免太长 */
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 13px;
}

#addUserBtn {
    padding: 6px 12px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.config-info {
    display: flex;
    gap: 10px;          /* 字段间间距 */
    align-items: center;
    flex-wrap: nowrap;  /* 保持在一行 */
}

.config-field {
    display: flex;
    flex-direction: column;
    flex: 1;             /* 自适应宽度占满剩余空间 */
}

.config-field input {
    width: 100%;         /* 输入框自适应容器 */
    box-sizing: border-box;
}

/* Share Password 固定宽度 */
.config-field.share-pwd {
    flex: 0 0 150px;     /* 固定宽度，不会被拉伸 */
}
.stats {
    display: flex;
    flex-wrap: nowrap;      /* 不换行 */
    gap: 20px;              /* 调整间距 */
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;       /* 容器不够宽时显示滚动条 */
}
/* 紧凑下拉框样式，统一宽度和字体 */
.compact-select {
    width: 120px;       /* 和国家/运营商一致 */
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;    /* 防止内容换行 */
}
#button-container {
    display: flex;
    flex-wrap: wrap; /* 屏幕窄时自动换行 */
    gap: 10px;
    align-items: center;
}
#script-ops {
    margin-top: 20px;  /* 比原来的 10px 或 15px 大一些 */
    display: flex;
    gap: 10px;         /* 按钮间距 */
    flex-wrap: wrap;
}
/* 国家选择下拉框 */
#sim-country {
    width: 140px;       /* 调整为适合的长度 */
    padding: 4px 6px;   /* 内边距稍微小一点 */
    font-size: 12px;    /* 字体稍微小一点 */
    border-radius: 4px;
    border: 1px solid #ccc;
}
/* 父容器使用水平排列，但紧凑 */
.sim-row {
    display: flex;
    gap: 10px;          /* 国家和运营商之间的间距 */
    align-items: flex-start;
    margin-bottom: 20px; /* 和下面操作按钮保持距离 */
}

/* 下拉框统一宽度 */
.sim-row select {
    width: 120px;       /* 更短，更紧凑 */
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
}
/* 台湾运营商下拉框 */
#tw-operator {
    width: 140px;       /* 和国家选择保持一致 */
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* 下拉框与操作按钮的间距 */
#script-ops {
    margin-top: 20px;   /* 避免误点 */
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    background: #f5f6f7;
}
.device-filter-wrapper {
    position: relative;
    margin-left: auto; /* 行末靠右 */
}

.device-filter-panel {
    position: absolute;
    top: 100%; /* 在按钮下方 */
    left: 0;   /* 与按钮左边对齐 */
    width: 220px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
}

.device-filter-panel.hidden { display:none; }

.device-filter-item { display:flex; align-items:center; padding:3px 6px; cursor:pointer; border-radius:3px; }
.device-filter-item:hover { background:#f0f0f0; }
.device-filter-item input { margin-right:6px; flex-shrink:0; }

/* 圆点 checkbox 样式 */
.device-checkbox {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid #666;
    border-radius: 50%;
    margin-right: 8px;
    cursor: pointer;
    position: relative;
}

.device-checkbox:checked::after {
    content: "";
    width: 8px;
    height: 8px;
    background: #1677ff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
}
/* ===================== 登录页面 ===================== */
#login-div {
    max-width: 400px;       /* 限制登录框宽度 */
    margin: 100px auto;     /* 页面居中 */
    padding: 30px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    text-align: center;
}

#login-div input[type=text],
#login-div input[type=password] {
    width: 150px;  /* 调整为合适长度，不要太长 */
    padding: 6px 8px;
    margin: 5px 0;
    border-radius: 4px;
    border: 1px solid #ccc;
}

#login-div button {
    display: block;      /* 按钮独占一行 */
    margin: 10px auto;   /* 居中 */
    width: 100px;
    background: #2196F3;
    color: #fff;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
/* ===================== 主容器 ===================== */
#main-div {
    min-height: 100vh;        /* 至少撑满整个可视高度 */
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    box-sizing: border-box;
}

/* ===================== 通用布局 ===================== */
.flex-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.flex-row > div {
    flex: 1;
    min-width: 200px;
}

/* ===================== 卡片风格 ===================== */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    padding: 20px;
    overflow: hidden;
}

.card h2 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

.card-content {
    padding: 20px 0 0 0;
}

/* ===================== 表格 ===================== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: #fff;
}

thead {
    background: #fafafa;
    position: sticky;
    top: 0;
    z-index: 10;
}

th, td {
    border: 1px solid #ccc;
    padding: 6px 10px;
    text-align: center;
    color: #666;
}

th {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

tbody tr:hover {
    background: #f5f5f5;
}

/* ===================== 输入框 ===================== */
input[type=text], input[type=password], select, textarea {
    width: 100%;
    padding: 6px 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 12px;
    box-sizing: border-box;
}

input[type=text]:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102,126,234,0.1);
}

input[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
}

/* ===================== 按钮 ===================== */
button, .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    margin-right: 8px;
    color: #fff;
}

.btn-primary { background: #1890ff; }
.btn-primary:hover { background: #40a9ff; }

.btn-success { background: #28a745; }
.btn-success:hover { background: #218838; }

.btn-warning { background: #ffc107; color: #212529; }
.btn-warning:hover { background: #e0a800; }

.btn-danger { background: #ff4d4f; }
.btn-danger:hover { background: #ff7875; }

.btn-info { background: #17a2b8; }
.btn-info:hover { background: #138496; }

.btn-occupy { background: #faad14; }
.btn-occupy:hover { background: #ffc53d; }

.btn-use { background: #52c41a; }
.btn-use:hover { background: #73d13d; }

.btn-sm { padding: 2px 8px; font-size: 11px; }

/* ===================== 设备卡片 ===================== */
.device-chip {
    padding: 5px 10px;
    background: #fde2e2;
    color: #d32f2f;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.devices-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.device-card {
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    width: 160px;
    cursor: pointer;
    background-color: #f9f9f9;
    font-size: 12px;
    transition: all 0.2s;
}

.device-card.selected {
    border-color: #007bff;
    background-color: #e0f0ff;
}

.device-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ===================== 模态弹窗 ===================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
}

.modal-header h3 {
    margin: 0;
    color: #495057;
}

.close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}
/* ===================== Line 表头 ===================== */
.line-header {
    background-color: #f1f3f4;
    border-left: 4px solid #6c757d;
}

.line-header-info {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr; /* 对应 Line ID/状态 | 目标数量 | 备注 | 操作 */
    padding: 8px 12px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
    align-items: center;
}

.line-header-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===================== Line 内容行 ===================== */
.line-info {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
}

/* Line ID + 状态 */
.line-id-status {
    width: 50%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* 在线/离线颜色 */
.status-badge.online {
    color: #28a745;
    background-color: #d4edda;
    border: 1px solid #155724;
}

.status-badge.offline {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #721c24;
}

/* 目标数量 */
.line-target {
    font-size: 16px;
    font-weight: bold;
}

/* 备注 */
.line-remark {
    font-size: 20px;      /* 字体加大 */
    color: #dc3545;       /* 红色 */
    font-weight: 600;     /* 可选，加粗一点更醒目 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 操作按钮 */
.line-actions {
    display: flex;
    gap: 6px;
}

/* 按钮统一样式 */
.line-actions button {
    padding: 4px 8px;
    font-size: 12px;
}
/* 分组颜色 */
.group-color-0 { background-color: #f0f9ff; }
.group-color-1 { background-color: #fef6ff; }
.group-color-2 { background-color: #fff7ed; }
.group-color-3 { background-color: #f0fdf4; }
.group-color-4 { background-color: #fff1f2; }

/* 点击选中高亮 */
.device-card.selected {
    border: 2px solid #3b82f6;
    box-shadow: 0 0 6px rgba(59,130,246,0.5);
}
/* ===================== 响应式 ===================== */
@media (max-width: 768px) {
    .flex-row {
        flex-direction: column;
    }
    .table-container {
        max-height: 400px;
        overflow-y: auto;
    }
    .input-row {
        flex-direction: column;
    }
    button, .btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    #config-table th, #config-table td {
        font-size: 0.8em;
        padding: 6px 8px;
    }
}