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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

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

.header {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #333;
    margin-bottom: 16px;
    font-size: 28px;
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-success {
    background: #2196F3;
    color: white;
}

.btn-success:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.status.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status.inactive {
    background: #ffebee;
    color: #c62828;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status.active .status-dot {
    background: #4CAF50;
}

.status.inactive .status-dot {
    background: #f44336;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-card .value {
    color: #333;
    font-size: 32px;
    font-weight: 700;
}

.stat-card .value.local {
    color: #4CAF50;
}

.stat-card .value.foreign {
    color: #ff9800;
}

.main-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.table-header h2 {
    color: #333;
    font-size: 20px;
}

.filter-buttons {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.filter-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #ddd;
    font-size: 14px;
}

td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    white-space: nowrap;
}

/* 時間欄位允許換行（第 2 欄，因為第 1 欄是勾選框） */
td:nth-child(2) {
    white-space: normal;
    line-height: 1.4;
}

/* 域名欄位可以截斷（第 3 欄） */
td:nth-child(3) {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.domain-link {
    color: #667eea;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.domain-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: #f9f9f9;
}

tbody tr.new-record {
    animation: highlight 2s;
}

@keyframes highlight {
    0% { background: #fff3cd; }
    100% { background: white; }
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge.local {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge.foreign {
    background: #fff3e0;
    color: #e65100;
}

.badge.unknown {
    background: #f5f5f5;
    color: #666;
}

.badge.type-a {
    background: #e3f2fd;
    color: #1976d2;
}

.badge.type-cname {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge.type-txt {
    background: #fff3e0;
    color: #f57c00;
}

.badge.provider {
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 600;
}

.badge.provider.aws {
    background: #fff3e0;
    color: #ff6f00;
}

.badge.provider.azure {
    background: #e3f2fd;
    color: #0277bd;
}

.badge.provider.gcp {
    background: #fff9c4;
    color: #f9a825;
}

.badge.provider.cloudflare {
    background: #fce4ec;
    color: #c2185b;
}

.badge.provider.akamai {
    background: #e0f2f1;
    color: #00695c;
}

.badge.os-system {
    background: #e1bee7;
    color: #6a1b9a;
    font-weight: 600;
}

.badge.app {
    background: #bbdefb;
    color: #1565c0;
    font-weight: 600;
}

.app-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.app-icon {
    width: 32px;
    height: 32px;
    border-radius: 6.4px;
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.app-icon:hover {
    transform: scale(1.05);
}

.app-icon-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.app-icon-container:hover {
    opacity: 0.8;
}

.app-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.app-link:hover {
    opacity: 0.8;
}

.app-icon-placeholder {
    width: 20px;
    height: 20px;
    background: #e0e0e0;
    border-radius: 4px;
    display: inline-block;
}

/* Modal 樣式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.modal-app-icon {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-app-info h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}

.modal-link:hover {
    background: #e0e0e0;
    transform: translateX(4px);
}

.modal-link-icon {
    font-size: 24px;
}

.app-name-clickable {
    cursor: pointer;
    color: #667eea;
    text-decoration: underline;
}

.app-name-clickable:hover {
    color: #764ba2;
}

.source-ip-input {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    background: #f5f5f5;
    border-radius: 8px;
}

.source-ip-input label {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.source-ip-input input[type="text"] {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s;
}

.source-ip-input input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.source-ip-input input[type="text"]::placeholder {
    color: #999;
}

.os-selector {
    display: flex;
    gap: 24px;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    background: #f5f5f5;
    border-radius: 8px;
}

.os-selector label {
    font-weight: 600;
    color: #333;
    margin-right: 8px;
}

.os-radio-group {
    display: flex;
    gap: 20px;
    align-items: center;
}

.os-radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.os-radio-item input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

.os-radio-item input[type="radio"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.os-radio-item label {
    font-weight: 500;
    color: #333;
    cursor: pointer;
    margin: 0;
    user-select: none;
}

.os-radio-item input[type="radio"]:disabled + label {
    opacity: 0.6;
    cursor: not-allowed;
}

.flag {
    font-size: 20px;
    margin-right: 8px;
}

.timestamp {
    color: #999;
    font-family: 'Courier New', monospace;
}

.asn-info {
    font-size: 13px;
    color: #666;
}

.asn-number {
    font-family: 'Courier New', monospace;
    color: #333;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* 勾選框樣式 */
th input[type="checkbox"],
td input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

/* 報告模態框樣式 */
.report-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

.report-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="url"] {
    padding: 10px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="url"]:focus {
    outline: none;
    border-color: #667eea;
}

.report-summary {
    background: #f5f5f5;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.report-summary h3 {
    margin-bottom: 12px;
    color: #333;
    font-size: 16px;
}

.report-summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.report-summary-item:last-child {
    border-bottom: none;
}

.report-summary-item strong {
    color: #333;
}

.report-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.report-actions .btn {
    padding: 10px 24px;
}
