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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f8;
    color: #333;
    min-height: 100vh;
}

/* TOPBAR */
.topbar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.topbar-brand { font-size: 1.1em; font-weight: bold; }
.topbar-brand span { opacity: 0.8; font-size: 0.85em; }
.topbar-links { display: flex; gap: 5px; }
.topbar-links a {
    color: white; text-decoration: none;
    padding: 8px 14px; border-radius: 6px;
    font-size: 0.9em; transition: background 0.2s;
}
.topbar-links a:hover { background: rgba(255,255,255,0.15); }
.topbar-links a.active { background: rgba(255,255,255,0.25); font-weight: bold; }

/* PAGE */
.page-container { max-width: 1200px; margin: 0 auto; padding: 30px 20px; }
.page-header { margin-bottom: 25px; }
.page-header h1 { font-size: 2em; color: #667eea; margin-bottom: 8px; }
.page-header p { color: #666; font-size: 1em; }
.actions { margin-top: 15px; display: flex; gap: 10px; }
.actions button {
    background: #667eea; color: white;
    border: none; padding: 8px 16px; border-radius: 6px;
    cursor: pointer; font-size: 0.9em; transition: background 0.2s;
}
.actions button:hover { background: #5a6fd6; }

/* LEGEND */
.legend {
    background: white; border-radius: 10px;
    padding: 20px; margin-bottom: 25px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.legend h3 { color: #667eea; margin-bottom: 15px; font-size: 1.1em; }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.legend-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.9em; color: #555;
    background: #f8f8f8; padding: 8px 12px; border-radius: 6px;
}

/* TREE */
.tree-container {
    background: white; border-radius: 10px;
    padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #e0e0e0;
}
.tree-node { margin: 3px 0; }
.tree-label {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 6px;
    cursor: default; font-size: 0.9em;
    transition: background 0.1s;
}
.tree-label:hover { background: #f5f5f5; }
.root-label { background: #f0f0f8; font-size: 1em; }
.app-label { background: #e8f5e9; border-left: 3px solid #4caf50; }
.stopped-label { background: #fafafa; border-left: 3px solid #ccc; opacity: 0.8; }
.tree-children {
    margin-left: 25px;
    border-left: 2px dashed #ddd;
    padding-left: 15px;
    margin-top: 3px;
    margin-bottom: 3px;
}
.toggle-btn {
    cursor: pointer; font-size: 0.85em; min-width: 18px;
    user-select: none; color: #667eea;
    font-weight: bold;
}
.toggle-btn:hover { color: #5a6fd6; }
.file-item {
    padding: 4px 10px; font-size: 0.85em; color: #555;
    border-radius: 4px; margin: 2px 0;
    display: flex; align-items: center; gap: 6px;
}
.file-item:hover { background: #f9f9f9; }
.desc { color: #999; font-size: 0.85em; margin-left: 5px; }
.desc.muted { font-style: italic; }

/* BADGES */
.badge {
    font-size: 0.75em; padding: 2px 8px; border-radius: 10px;
    font-weight: 600; white-space: nowrap;
}
.badge-online { background: #e8f5e9; color: #2e7d32; }
.badge-stopped { background: #fafafa; color: #999; border: 1px solid #ddd; }
.badge-port { background: #e3f2fd; color: #1565c0; }
.badge-env { background: #fff3e0; color: #e65100; }
.badge-docker { background: #e0f2f1; color: #00695c; }
.badge-pm2 { background: #f3e5f5; color: #6a1b9a; }
.badge-expo { background: #e8eaf6; color: #283593; }
.badge-https { background: #e3f2fd; color: #0d47a1; }
.badge-server { background: #fce4ec; color: #880e4f; }
.badge-public { background: #e8f5e9; color: #1b5e20; }
.badge-internal { background: #fff8e1; color: #f57f17; }
.badge-cert { background: #e3f2fd; color: #1565c0; font-size: 0.8em; padding: 8px 12px; border-radius: 6px; display: block; margin-top: 8px; }

/* CARD */
.card {
    background: white; border-radius: 10px; padding: 25px;
    margin-bottom: 20px; border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.card h2 { color: #667eea; margin-bottom: 15px; }

/* PORTS PAGE */
.ports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(500px, 1fr)); gap: 20px; }
.port-card {
    background: white; border-radius: 10px; padding: 20px;
    border: 1px solid #e0e0e0; border-left: 5px solid #4caf50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex; gap: 20px;
}
.port-card.https { border-left-color: #2196f3; }
.port-card.stopped { border-left-color: #ccc; opacity: 0.8; }
.port-card.internal { border-left-color: #ff9800; }
.port-number {
    font-size: 2em; font-weight: bold; color: #667eea;
    min-width: 80px; text-align: center;
    display: flex; align-items: center; justify-content: center;
    background: #f0f2f8; border-radius: 8px; padding: 10px;
}
.port-name { font-size: 1.1em; font-weight: bold; color: #333; margin-bottom: 8px; }
.port-desc { font-size: 0.9em; color: #666; line-height: 1.5; margin-bottom: 10px; }
.port-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.port-command, .port-info-box {
    background: #f5f5f5; border-radius: 6px;
    padding: 8px 12px; font-family: monospace; font-size: 0.85em;
    color: #333; margin-top: 8px;
}
.port-info-box { font-family: inherit; background: #e8f5e9; }
.flow-diagram {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 10px; padding: 20px; background: #f8f8f8;
    border-radius: 8px; margin-bottom: 10px;
}
.flow-box {
    padding: 12px 20px; border-radius: 8px; text-align: center;
    font-weight: bold; font-size: 0.9em; min-width: 100px;
}
.flow-internet { background: #667eea; color: white; }
.flow-nginx { background: #4caf50; color: white; }
.flow-app { background: #ff9800; color: white; }
.flow-arrow { font-size: 1.5em; color: #667eea; font-weight: bold; }
.flow-note { text-align: center; color: #666; font-size: 0.9em; }
.dot-green { color: #4caf50; font-size: 1.3em; }
.dot-red { color: #f44336; font-size: 1.3em; }
.dot-blue { color: #2196f3; font-size: 1.3em; }

/* PM2 & DOCKER CARDS */
.pm2-app-card {
    background: white; border-radius: 10px; margin-bottom: 15px;
    border: 1px solid #e0e0e0; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.pm2-app-card.online { border-left: 5px solid #4caf50; }
.pm2-app-card.stopped { border-left: 5px solid #ccc; opacity: 0.85; }
.pm2-app-header {
    display: flex; align-items: center; gap: 15px;
    padding: 15px 20px; background: #fafafa;
    border-bottom: 1px solid #eee;
}
.pm2-app-id {
    background: #667eea; color: white; border-radius: 6px;
    padding: 4px 12px; font-weight: bold; font-size: 0.9em;
    min-width: 50px; text-align: center;
}
.docker-id { background: #00acc1; }
.pm2-app-name { font-size: 1.1em; font-weight: bold; flex: 1; }
.online-badge { color: #2e7d32; font-weight: bold; font-size: 0.9em; }
.stopped-badge { color: #999; font-weight: bold; font-size: 0.9em; }
.pm2-app-uptime { color: #888; font-size: 0.9em; }
.pm2-app-details { padding: 15px 20px; }
.pm2-detail-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px; margin-bottom: 12px;
}
.pm2-detail-grid div { font-size: 0.85em; color: #555; background: #f8f8f8; padding: 6px 10px; border-radius: 5px; }
.pm2-app-desc { font-size: 0.9em; color: #555; line-height: 1.6; margin-bottom: 12px; }
.pm2-commands { display: flex; gap: 8px; flex-wrap: wrap; }
.pm2-commands code {
    background: #2d2d2d; color: #f8f8f2;
    padding: 4px 10px; border-radius: 4px; font-size: 0.8em;
}
.pm2-features { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 15px; }
.pm2-feature { background: #f0f8f0; padding: 10px 14px; border-radius: 6px; font-size: 0.9em; color: #444; }

/* TABLES */
.summary-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.summary-table th { background: #667eea; color: white; padding: 10px 15px; text-align: left; }
.summary-table td { padding: 10px 15px; border-bottom: 1px solid #eee; font-size: 0.9em; }
.summary-table tr:nth-child(even) { background: #f9f9f9; }
.summary-table tr:hover { background: #f0f2f8; }
.summary-table code { background: #2d2d2d; color: #f8f8f2; padding: 2px 8px; border-radius: 4px; font-size: 0.85em; }

@media (max-width: 768px) {
    .topbar { flex-direction: column; height: auto; padding: 10px; gap: 8px; }
    .ports-grid { grid-template-columns: 1fr; }
    .port-card { flex-direction: column; }
    .flow-diagram { justify-content: center; }
}
