* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    color: #333;
}
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
header h1 { margin: 0; font-size: 22px; }

.status-badge {
    padding: 6px 14px; border-radius: 16px;
    font-size: 13px; font-weight: 500;
    background: #e0e0e0; color: #666;
}
.status-badge.state-running { background: #e6f7ed; color: #2b8a3e; }
.status-badge.state-error { background: #fde8e8; color: #c92a2a; }
.status-badge.state-starting, .status-badge.state-logging_in { background: #fff3bf; color: #946c00; }

.card {
    background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card h2 { margin: 0 0 16px; font-size: 16px; color: #555; }

.task-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hint { color: #666; font-size: 13px; }

.btn {
    padding: 8px 16px; border: none; border-radius: 4px;
    cursor: pointer; font-size: 14px; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #228be6; color: #fff; }
.btn-danger { background: #e03131; color: #fff; }
.btn-secondary { background: #e9ecef; color: #333; }
.btn-small { padding: 4px 10px; font-size: 12px; }

.config-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.form-row { display: flex; flex-direction: column; }
.form-row label { font-size: 12px; color: #666; margin-bottom: 4px; }
.form-row input, .form-row select {
    padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px;
}
.config-form button { grid-column: 1 / -1; justify-self: start; margin-top: 8px; }

.devices-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.device-row { display: flex; gap: 8px; align-items: center; }
.device-row input {
    flex: 1; padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px;
}
.device-row input[type="number"] { flex: 0 0 180px; }
.device-actions { display: flex; gap: 10px; }

.status-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.status-table th {
    text-align: left; padding: 10px 8px; background: #f8f9fa;
    border-bottom: 2px solid #dee2e6; font-weight: 600;
}
.status-table td { padding: 10px 8px; border-bottom: 1px solid #f1f3f5; }
.status-table .empty { text-align: center; color: #999; padding: 24px; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #e9ecef; color: #666; }
.badge-ok { background: #d3f9d8; color: #2b8a3e; }
.badge-fail { background: #ffe3e3; color: #c92a2a; }
.badge-running { background: #fff3bf; color: #946c00; }
.ok { color: #2b8a3e; font-weight: 600; }
.fail { color: #c92a2a; font-weight: 600; }

.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 999; justify-content: center; align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: #fff; border-radius: 8px; width: 85%; max-width: 900px;
    max-height: 85vh; display: flex; flex-direction: column;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid #eee;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.close-btn {
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: #999; padding: 0 4px;
}
.log-view {
    flex: 1; overflow: auto; padding: 16px 20px; margin: 0;
    background: #1e1e1e; color: #d4d4d4; font-family: Consolas, monospace;
    font-size: 12px; line-height: 1.5; border-radius: 0 0 8px 8px;
    white-space: pre-wrap; word-break: break-all;
}

/* ---------- 实时日志 ---------- */
.live-log-card {
    padding: 0;
    overflow: hidden;
}
.live-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.live-log-header h2 { margin: 0; }
.live-log-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.live-log-view {
    height: 280px;
    overflow-y: auto;
    background: #1e1e1e;
    padding: 12px 16px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.5;
}
.live-log-view .log-line {
    color: #d4d4d4;
    white-space: pre-wrap;
    word-break: break-all;
    padding: 1px 0;
}
.live-log-view .log-line.log-error { color: #ff6b6b; }
.live-log-view .log-line.log-warn { color: #ffd43b; }
.live-log-view .log-line.log-info { color: #d4d4d4; }

/* ---------- 设备列表 tabs ---------- */
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.section-header h2 { margin: 0; }
.section-actions { display: flex; gap: 8px; }

.devices-tabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.devices-tabs .tab {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: #f1f3f5;
    border: 1px solid #dee2e6;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 13px;
    color: #495057;
    user-select: none;
    transition: background 0.15s;
}
.devices-tabs .tab:hover { background: #e9ecef; }
.devices-tabs .tab.active {
    background: #fff;
    color: #228be6;
    font-weight: 600;
    position: relative;
    top: 1px;
    border-bottom: 1px solid #fff;
}
.devices-tabs .tab-count {
    background: #dee2e6;
    color: #495057;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: normal;
}
.devices-tabs .tab.active .tab-count {
    background: #d0ebff; color: #1864ab;
}
.devices-tabs .tab-close {
    margin-left: 2px;
    padding: 0 4px;
    color: #adb5bd;
    font-weight: bold;
    border-radius: 3px;
}
.devices-tabs .tab-close:hover {
    background: #ffc9c9;
    color: #c92a2a;
}

.devices-tab-content {
    border: 1px solid #e9ecef;
    border-radius: 0 6px 6px 6px;
    padding: 12px;
}
.tab-toolbar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 10px;
}
.devices-panel { display: flex; flex-direction: column; gap: 8px; }

/* ---------- 状态表分组标签 ---------- */
.group-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e7f5ff;
    color: #1864ab;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}
/* ---------- iframe 弹框 ---------- */
.iframe-modal-content {
    width: 90%;
    max-width: 1100px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.iframe-modal-content .modal-header {
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.iframe-modal-content iframe {
    flex: 1;
    border: none;
    width: 100%;
    background: #f5f7fa;
}

/* ---------- 登录页 ---------- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e7f5ff 0%, #f5f7fa 100%);
}
.login-card {
    background: #fff;
    padding: 40px 36px;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    margin: 0 0 8px;
    font-size: 22px;
    color: #228be6;
    text-align: center;
}
.login-subtitle {
    margin: 0 0 24px;
    text-align: center;
    color: #999;
    font-size: 13px;
}
.login-field {
    margin-bottom: 16px;
}
.login-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #555;
}
.login-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}
.login-field input:focus {
    outline: none;
    border-color: #228be6;
    box-shadow: 0 0 0 2px rgba(34,139,230,0.1);
}
.login-error {
    padding: 8px 12px;
    margin-bottom: 16px;
    background: #ffe3e3;
    color: #c92a2a;
    border-radius: 4px;
    font-size: 13px;
}
.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logout-link {
    color: #e03131;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background 0.15s;
}
.logout-link:hover {
    background: #ffe3e3;
}