* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    padding: 10px;
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    color: #333;
    margin-bottom: 15px;
    font-size: 20px;
}

.input-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    font-size: 18px;
    line-height: 1;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.input-clear:hover {
    color: #333;
}

.input-wrapper {
    position: relative;
}

.input-wrapper .form-control {
    padding-right: 35px;
}

#message {
    display: none;
}

#message.show {
    display: block;
}

.monospace {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.stats-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.stats-card .stat-item {
    display: inline-block;
    margin-right: 2rem;
    font-size: 0.9rem;
}

.stats-card .stat-label {
    color: #666;
    margin-right: 0.5rem;
}

.stats-card .stat-value {
    font-weight: 600;
    color: #333;
}

.ip-table {
    font-size: 14px;
    table-layout: fixed;
    width: 100%;
}

.ip-table th {
    font-weight: 600;
    background-color: #f8f9fa;
}

.ip-table td {
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 固定各列宽度 */
.ip-table th:nth-child(1),
.ip-table td:nth-child(1) {
    width: 50px;
    min-width: 50px;
}

.ip-table th:nth-child(2),
.ip-table td:nth-child(2) {
    width: 180px;
    min-width: 180px;
}

.ip-table th:nth-child(3),
.ip-table td:nth-child(3) {
    width: 100px;
    min-width: 100px;
}

.ip-table th:nth-child(4),
.ip-table td:nth-child(4) {
    width: 200px;
    min-width: 200px;
}

.ip-table th:nth-child(5),
.ip-table td:nth-child(5) {
    width: 150px;
    min-width: 150px;
}

.ip-table th:nth-child(6),
.ip-table td:nth-child(6) {
    width: 100px;
    min-width: 100px;
}

.ip-table th:nth-child(7),
.ip-table td:nth-child(7) {
    width: 120px;
    min-width: 120px;
}

.ip-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.ip-card-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.ip-card-row:last-child {
    margin-bottom: 0;
}

.ip-card-label {
    color: #666;
    font-weight: 500;
    min-width: 80px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 10px;
}

.ip-card-value {
    color: #333;
    text-align: left;
    flex: 1;
    word-break: break-all;
}

.ip-card-value.monospace {
    font-family: monospace;
    font-size: 12px;
}

.badge-danger {
    background-color: #dc3545;
}

.badge-warning {
    background-color: #ffc107;
    color: #000;
}

.segment-info {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

/* 移动端适配 */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    h1 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .ip-table-container {
        display: none;
    }

    .ip-card-container {
        display: block;
    }

    .stats-card .stat-item {
        display: block;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
}

/* 桌面端显示表格，隐藏卡片 */
@media (min-width: 769px) {
    .ip-card-container {
        display: none;
    }

    .ip-table-container {
        display: block;
    }
}

/* 所有规则列表样式 */
.rules-section {
    margin-bottom: 20px;
}

.rules-section h2 {
    color: #333;
    font-size: 16px;
    margin-bottom: 12px;
}

.rule-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.rule-card-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.rule-card-row:last-child {
    margin-bottom: 0;
}

.rule-card-label {
    color: #666;
    font-weight: 500;
    min-width: 80px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 10px;
}

.rule-card-value {
    color: #333;
    text-align: left;
    flex: 1;
    word-break: break-all;
}

.rule-card-value.monospace {
    font-family: monospace;
    font-size: 12px;
}

.rule-card-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.region-header {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    margin: 1rem 0 0.75rem 0;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
    border-left: 4px solid #0d6efd;
}

.direction-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.direction-ingress {
    background-color: #d1ecf1;
    color: #0c5460;
}

.direction-egress {
    background-color: #d4edda;
    color: #155724;
}

.protocol-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.protocol-tcp {
    background-color: #cfe2ff;
    color: #084298;
}

.protocol-udp {
    background-color: #fff3cd;
    color: #856404;
}

.protocol-icmp {
    background-color: #f8d7da;
    color: #842029;
}

.protocol-all {
    background-color: #e2e3e5;
    color: #41464b;
}

/* Drop策略规则行/卡片高亮 */
.rule-drop {
    background-color: #fff5f5 !important;
    border-left: 4px solid #dc3545;
}

.rule-drop:hover {
    background-color: #ffe0e0 !important;
}

.table tbody tr.rule-drop {
    background-color: #fff5f5;
}

.table tbody tr.rule-drop:hover {
    background-color: #ffe0e0;
}

.rules-container-mobile {
    display: none;
}

.rules-container-desktop {
    display: block;
}

@media (max-width: 768px) {
    .rules-container-mobile {
        display: block;
    }
    .rules-container-desktop {
        display: none;
    }
}

/* 已存在的IP样式 */
.table-secondary {
    background-color: #f8f9fa !important;
    opacity: 0.7;
}

.ip-card.bg-light {
    background-color: #f8f9fa !important;
    opacity: 0.7;
}

.ip-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* 禁用状态的控件样式 */
#scanConfigCard input:disabled,
#scanConfigCard select:disabled,
#scanConfigCard button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

#rulesLoadingTip {
    display: flex;
    align-items: center;
}

/* IP段聚合表格固定宽度 */
.table-sm.table-bordered {
    table-layout: fixed;
    width: 100%;
}

.table-sm.table-bordered th,
.table-sm.table-bordered td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* IP段聚合表格列宽 */
.table-sm.table-bordered th:nth-child(1),
.table-sm.table-bordered td:nth-child(1) {
    width: 50px;
    min-width: 50px;
}

.table-sm.table-bordered th:nth-child(2),
.table-sm.table-bordered td:nth-child(2) {
    width: 180px;
    min-width: 180px;
}

.table-sm.table-bordered th:nth-child(3),
.table-sm.table-bordered td:nth-child(3) {
    width: 100px;
    min-width: 100px;
}

.table-sm.table-bordered th:nth-child(4),
.table-sm.table-bordered td:nth-child(4) {
    width: 120px;
    min-width: 120px;
}

.table-sm.table-bordered th:nth-child(5),
.table-sm.table-bordered td:nth-child(5) {
    width: 100px;
    min-width: 100px;
}

.table-sm.table-bordered th:nth-child(6),
.table-sm.table-bordered td:nth-child(6) {
    width: auto;
    min-width: 200px;
}

/* 所有规则表格固定宽度 */
.rules-container-desktop .table {
    table-layout: fixed;
    width: 100%;
}

.rules-container-desktop .table th,
.rules-container-desktop .table td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 规则表格列宽 */
.rules-container-desktop .table th:nth-child(1),
.rules-container-desktop .table td:nth-child(1) {
    width: 150px;
    min-width: 150px;
}

.rules-container-desktop .table th:nth-child(2),
.rules-container-desktop .table td:nth-child(2) {
    width: 80px;
    min-width: 80px;
}

.rules-container-desktop .table th:nth-child(3),
.rules-container-desktop .table td:nth-child(3) {
    width: 80px;
    min-width: 80px;
}

.rules-container-desktop .table th:nth-child(4),
.rules-container-desktop .table td:nth-child(4) {
    width: 120px;
    min-width: 120px;
}

.rules-container-desktop .table th:nth-child(5),
.rules-container-desktop .table td:nth-child(5) {
    width: 150px;
    min-width: 150px;
}

.rules-container-desktop .table th:nth-child(6),
.rules-container-desktop .table td:nth-child(6) {
    width: 80px;
    min-width: 80px;
}

.rules-container-desktop .table th:nth-child(7),
.rules-container-desktop .table td:nth-child(7) {
    width: 80px;
    min-width: 80px;
}

.rules-container-desktop .table th:nth-child(8),
.rules-container-desktop .table td:nth-child(8) {
    width: auto;
    min-width: 200px;
}

.rules-container-desktop .table th:nth-child(9),
.rules-container-desktop .table td:nth-child(9) {
    width: 120px;
    min-width: 120px;
}

