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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}

h1 {
    text-align: center;
    font-size: 28px;
    color: #f0f6fc;
    letter-spacing: 0.5px;
}

.subtitle {
    text-align: center;
    color: #8b949e;
    margin-bottom: 32px;
    font-size: 14px;
}

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.cat-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
    border-top: 3px solid;
}

.cat-header {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.cat-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.cat-body {
    padding: 14px;
}

.cat-body label {
    display: block;
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 6px;
}

.cat-input {
    width: 100%;
    padding: 8px 12px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 16px;
    font-family: monospace;
    outline: none;
    transition: border-color 0.15s;
}

.cat-input:focus {
    border-color: #58a6ff;
}

.cat-input::-webkit-inner-spin-button,
.cat-input::-webkit-outer-spin-button {
    opacity: 1;
}

/* Buttons */
.option-row {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #8b949e;
    user-select: none;
}

.toggle input { display: none; }

.toggle-slider {
    width: 36px;
    height: 20px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 10px;
    position: relative;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: "";
    width: 14px;
    height: 14px;
    background: #8b949e;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: #238636;
    border-color: #2ea043;
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(16px);
    background: #fff;
}

.toggle-label {
    color: #c9d1d9;
}

.actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 32px;
}

button {
    padding: 10px 28px;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

#calculate {
    background: #238636;
    color: #fff;
    border-color: rgba(240, 246, 252, 0.1);
}

#calculate:hover {
    background: #2ea043;
}

.secondary {
    background: #21262d;
    color: #c9d1d9;
}

.secondary:hover {
    background: #30363d;
}

/* Results */
.results { margin-top: 16px; }
.hidden { display: none; }

/* Summary */
.summary {
    background: linear-gradient(135deg, #161b22, #1c2333);
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 24px;
    text-align: center;
}

.summary-stat {
    display: inline-block;
    margin: 0 24px;
    vertical-align: top;
}

.summary-stat .value {
    font-size: 42px;
    font-weight: 700;
    color: #58a6ff;
}

.summary-stat .label {
    font-size: 12px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* Per Category */
.per-category {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.alloc-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    border-left: 4px solid;
}

.alloc-card .ac-header {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 10px;
}

.alloc-card .ac-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
    color: #8b949e;
}

.alloc-card .ac-row strong {
    color: #c9d1d9;
}

.alloc-card .ac-total {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #21262d;
    font-weight: 600;
    font-size: 14px;
    color: #f0f6fc;
}

/* Rack Visualization */
.racks-view { margin-top: 8px; }

.racks-title {
    font-size: 14px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.racks-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.rack {
    background: #161b22;
    border: 2px solid #30363d;
    border-radius: 8px;
    width: 180px;
    overflow: hidden;
}

.rack-header {
    padding: 10px;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    background: #21262d;
    border-bottom: 1px solid #30363d;
    color: #f0f6fc;
}

.rack-body {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rack-switch {
    background: #1c2a3a;
    border: 1px solid #2d4a6a;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 10px;
    color: #7ea4c8;
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.rack-switch.first { height: 28px; display: flex; align-items: center; justify-content: center; }
.rack-switch.second { height: 28px; display: flex; align-items: center; justify-content: center; }

.server-block {
    border: 1px solid;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: center;
}

.server-block.small-block { min-height: 32px; }
.server-block.big-block { min-height: 74px; }

.rack-footer {
    padding: 8px;
    text-align: center;
    font-size: 11px;
    color: #8b949e;
    border-top: 1px solid #21262d;
}

/* Responsive */
@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
    .per-category { grid-template-columns: 1fr; }
    .racks-grid { flex-direction: column; align-items: center; }
    .summary-stat { margin: 0 12px; }
    .summary-stat .value { font-size: 28px; }
}
