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

:root {
    --bg: #0f0f0f;
    --surface: #181818;
    --surface-raised: #212121;
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: #3b82f6;
    --text: #e4e4e7;
    --text-muted: #71717a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --orange: #f97316;
    --radius: 8px;
    --radius-sm: 6px;
    --font-mono: "SF Mono", "Cascadia Code", "Fira Code", "JetBrains Mono", Consolas, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.logo {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo svg {
    opacity: 0.7;
}

#connection-status {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    transition: color 0.3s;
}

#connection-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

#connection-status.connected { color: var(--green); }
#connection-status.disconnected { color: var(--red); }

#container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
}

.service-box {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    max-height: 500px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: border-color 0.2s;
}

.service-box:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.service-header {
    padding: 10px 14px;
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.service-name {
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: lowercase;
}

.status-badge.Running {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
}

.status-badge.Stopped {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.status-badge.Starting {
    background: rgba(234, 179, 8, 0.15);
    color: var(--yellow);
}

.status-badge.Stopping {
    background: rgba(249, 115, 22, 0.15);
    color: var(--orange);
}

.controls {
    display: flex;
    gap: 4px;
}

.service-icon {
    display: inline-flex;
    color: var(--text-muted);
}

.controls button {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.controls button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.15);
}

.controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.log-area {
    flex: 1;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: #a1a1aa;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.log-area::-webkit-scrollbar {
    width: 6px;
}

.log-area::-webkit-scrollbar-track {
    background: transparent;
}

.log-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.log-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.stdin-area {
    padding: 8px 14px;
    background: var(--surface-raised);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.stdin-area input {
    flex: 1;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    transition: border-color 0.15s;
}

.stdin-area input::placeholder {
    color: var(--text-muted);
}

.stdin-area input:focus {
    border-color: var(--border-focus);
}

.stdin-area button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stdin-area button:hover {
    background: var(--accent-hover);
}

@media (max-width: 860px) {
    #container {
        grid-template-columns: 1fr;
    }
}