:root {
    --color-network: #0066CC;
    --color-broadcast: #FF8C00;
    --color-usable: #008000;
    --color-title: #2C3E50;
    --color-important: #CC0000;
    --color-info: #666666;
    --color-primary: #3498db;
    --color-secondary: #95a5a6;
    --color-danger: #e74c3c;
    --color-warning: #f39c12;
    --color-success: #27ae60;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: var(--color-title);
}

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

/* Banner */
.sale-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #e0e0e0;
    text-align: center;
    padding: 10px 15px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sale-banner a { color: #f39c12; text-decoration: none; font-weight: bold; }
.sale-banner a:hover { text-decoration: underline; }

/* Header */
.app-header {
    background: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    position: relative;
}
.app-header h1 { color: var(--color-title); font-size: 1.8em; margin-bottom: 5px; }
.subtitle { color: var(--color-info); font-size: 0.9em; }

/* History button */
.history-btn {
    position: absolute;
    right: 20px;
    top: 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: bold;
    transition: all 0.3s;
}
.history-btn:hover { background: #2980b9; }
.history-btn .badge {
    background: var(--color-danger);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75em;
    margin-left: 4px;
    display: none;
}

/* History Modal */
.history-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.history-overlay.show { display: flex; }
.history-modal {
    background: white;
    border-radius: 15px;
    padding: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.history-modal h3 { color: var(--color-title); margin-bottom: 15px; }
.history-item {
    padding: 12px;
    border: 1px solid #ecf0f1;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85em;
    font-family: 'Consolas', monospace;
}
.history-item:hover { background: #f0f4f8; }
.history-item .time { color: var(--color-info); font-size: 0.8em; }
.history-empty { text-align: center; color: var(--color-info); padding: 30px; }
.history-actions { display: flex; gap: 10px; margin-top: 15px; justify-content: flex-end; }

/* Toggle Bar */
.toggle-bar {
    display: flex;
    background: white;
    border-radius: 15px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    justify-content: center;
    gap: 12px;
    align-items: center;
}
.toggle-label { font-size: 0.85em; color: var(--color-info); font-weight: 600; }
.toggle-btn {
    padding: 8px 20px;
    border: 2px solid #ddd;
    background: white;
    color: var(--color-info);
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}
.toggle-btn.active { background: var(--color-network); border-color: var(--color-network); color: white; }
.toggle-divider { width: 1px; height: 24px; background: #ddd; }

/* Tab Navigation */
.tab-nav {
    display: flex;
    background: white;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
}
.tab-button {
    padding: 10px 10px;
    border: none;
    background: transparent;
    color: var(--color-info);
    font-size: 0.82em;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
}
.tab-button.active { background: var(--color-primary); color: white; font-weight: bold; }
.tab-button.new-feature { position: relative; }
.tab-button.new-feature::after {
    content: 'NEW';
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--color-danger);
    color: white;
    font-size: 0.55em;
    padding: 1px 4px;
    border-radius: 4px;
    line-height: 1;
}

/* Cards */
.card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.card h2 {
    color: var(--color-title);
    font-size: 1.3em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

/* Forms */
.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    color: var(--color-title);
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.95em;
}
.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1em;
    font-family: 'Consolas', monospace;
    transition: border-color 0.3s;
}
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 0.9em;
    font-family: 'Consolas', monospace;
    transition: border-color 0.3s;
    resize: vertical;
    line-height: 1.5;
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: var(--color-primary); }

/* Quick Buttons */
.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    align-items: center;
}
.quick-buttons .label { color: var(--color-info); font-size: 0.9em; }
.btn-quick {
    padding: 8px 12px;
    border: 2px solid var(--color-primary);
    background: white;
    color: var(--color-primary);
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}
.btn-quick:active { background: var(--color-primary); color: white; transform: scale(0.95); }

/* Slider */
.slider-container {
    margin: 20px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
}
.slider-container label { display: block; color: var(--color-title); font-weight: 600; margin-bottom: 10px; }
.slider-value { color: var(--color-network); font-size: 1.2em; font-weight: bold; font-family: 'Consolas', monospace; }
.slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 25px; height: 25px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.slider-labels { display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.8em; color: var(--color-info); }
.slider-info { text-align: center; color: var(--color-usable); font-weight: bold; margin-top: 10px; font-size: 0.95em; }
.checkbox-group { margin-top: 10px; }
.checkbox-group label { display: flex; align-items: center; cursor: pointer; color: var(--color-title); font-size: 0.9em; }
.checkbox-group input[type="checkbox"] { margin-right: 8px; width: 18px; height: 18px; cursor: pointer; }

/* Buttons */
.button-group { display: flex; gap: 10px; margin: 20px 0; }
.btn-primary, .btn-secondary, .btn-danger, .btn-sm {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:active { background: #2980b9; transform: scale(0.98); }
.btn-secondary { background: var(--color-secondary); color: white; }
.btn-secondary:active { background: #7f8c8d; transform: scale(0.98); }
.btn-danger { background: var(--color-danger); color: white; flex: 0; padding: 14px 24px; }
.btn-danger:active { background: #c0392b; transform: scale(0.98); }
.btn-sm { padding: 8px 14px; font-size: 0.8em; flex: 0; }

/* Result Box */
.result-box {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 10px;
    font-family: 'Consolas', monospace;
    font-size: 0.85em;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 100px;
    max-height: 500px;
    overflow-y: auto;
}
.result-box:empty::after { content: attr(data-placeholder); color: #666; font-style: italic; }

/* Result Table */
.result-table { width: 100%; border-collapse: collapse; margin: 15px 0; font-size: 0.9em; }
.result-table th {
    background: #2C3E50;
    color: white;
    padding: 10px;
    text-align: left;
    font-weight: 600;
}
.result-table td { padding: 8px 10px; border-bottom: 1px solid #ecf0f1; }
.result-table tr:hover { background: #f8f9fa; }
.result-table .highlight { background: #e8f5e9; }

/* Color classes */
.text-network { color: #5dade2; font-weight: bold; }
.text-broadcast { color: #f39c12; font-weight: bold; }
.text-usable { color: #2ecc71; }
.text-title { color: #ecf0f1; font-weight: bold; font-size: 1.1em; }
.text-important { color: #e74c3c; font-weight: bold; }
.text-info { color: #95a5a6; }
.text-warning { background: #f39c12; color: #1e1e1e; padding: 2px 5px; border-radius: 3px; }
.text-binary { background: #34495e; padding: 2px 5px; border-radius: 3px; }

/* Tab Pane */
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* VLSM Table */
.vlsm-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.vlsm-input-row input {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
}
.vlsm-input-row input:focus { outline: none; border-color: var(--color-primary); }
.vlsm-input-row .name-input { flex: 1; min-width: 100px; }
.vlsm-input-row .hosts-input { width: 120px; }
.btn-remove {
    background: var(--color-danger);
    color: white;
    border: none;
    border-radius: 8px;
    width: 32px; height: 32px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    flex-shrink: 0;
}
.btn-add-row {
    background: var(--color-success);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    margin-top: 8px;
}

/* Cheat Sheet */
.cheatsheet-subtabs { display: flex; gap: 4px; margin-bottom: 15px; }
.cheatsheet-subtabs button {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
}
.cheatsheet-subtabs button.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}
.cheatsheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82em;
    font-family: 'Consolas', monospace;
}
.cheatsheet-table th {
    background: #2C3E50;
    color: white;
    padding: 8px 6px;
    text-align: left;
    position: sticky;
    top: 0;
}
.cheatsheet-table td { padding: 6px; border-bottom: 1px solid #ecf0f1; }
.cheatsheet-table tr:hover { background: #f0f4f8; }
.cheatsheet-table .mask-cell { color: var(--color-network); font-weight: bold; }
.cheatsheet-table .hosts-cell { color: var(--color-usable); }
.cheatsheet-scroll { max-height: 400px; overflow-y: auto; border-radius: 8px; border: 1px solid #ecf0f1; }

/* IPv6 Tools */
.tool-section {
    border: 1px solid #ecf0f1;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}
.tool-section h3 { color: var(--color-title); margin-bottom: 12px; font-size: 1.05em; }

/* Footer */
.app-footer {
    text-align: center;
    color: white;
    margin-top: 20px;
    padding: 15px;
    font-size: 0.85em;
}
.app-footer p { margin: 5px 0; }

/* SEO Section */
.seo-content {
    background: white;
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 0.9em;
    line-height: 1.8;
    color: #555;
}
.seo-content h2 { color: #2C3E50; font-size: 1.2em; margin-bottom: 10px; }
.seo-content h3 { color: #2C3E50; font-size: 1.05em; margin-top: 15px; }
.seo-content ul { padding-left: 20px; margin: 10px 0; }

/* Input group */
.input-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.input-group label { font-weight: 600; font-size: 0.9em; white-space: nowrap; }
.input-group input { flex: 1; min-width: 150px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #2C3E50;
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: bold;
    z-index: 2000;
    animation: toastIn 0.3s, toastOut 0.3s 1.7s forwards;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* Responsive */
@media (max-width: 600px) {
    body { padding: 5px; }
    .app-header h1 { font-size: 1.5em; }
    .tab-button { font-size: 0.7em; padding: 8px 6px; }
    .card { padding: 15px; }
    .card h2 { font-size: 1.1em; }
    .btn-quick { font-size: 0.75em; padding: 6px 10px; }
    .result-box { font-size: 0.75em; }
    .toggle-btn { padding: 6px 14px; font-size: 0.8em; }
    .result-table { font-size: 0.75em; }
    .cheatsheet-table { font-size: 0.7em; }
    .vlsm-input-row { flex-direction: column; }
    .vlsm-input-row .name-input,
    .vlsm-input-row .hosts-input { width: 100%; }
    .history-btn { position: static; margin-top: 10px; }
}
