:root {
    --bg:            #f1f5f9;
    --surface:       #ffffff;
    --border:        #e2e8f0;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --accent:        #3b82f6;
    --accent-hover:  #2563eb;
    --success:       #16a34a;
    --success-hover: #15803d;
    --warning:       #d97706;
    --danger:        #dc2626;
    --header-bg:     #0f172a;
    --sidebar-width: 260px;
    --header-height: 56px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ── Login ── */

body.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    padding: 40px 36px;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.login-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
    background: var(--surface);
}

.form-group input:focus {
    border-color: var(--accent);
}

.alert {
    padding: 10px 13px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.btn-primary {
    display: inline-block;
    padding: 10px 40px;
    background: var(--header-bg);
    color: white;
    border: none;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary-wrap {
    text-align: center;
    margin-top: 8px;
}

.btn-primary:hover {
    background: #1e293b;
}

/* ── App shell ── */

body.app-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    height: var(--header-height);
    background: var(--header-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
}

.header-icon {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.header-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
}

.header-tabs {
    display: flex;
    gap: 4px;
    margin: 0 auto;
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover {
    color: white;
    background: rgba(255,255,255,0.08);
}

.tab-btn.active {
    color: white;
    background: rgba(255,255,255,0.14);
}

.logout-btn {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    padding: 5px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.logout-btn:hover {
    color: white;
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.08);
}

/* ── Layout ── */

.layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ── Sidebar ── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px 16px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.file-count {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.file-list {
    list-style: none;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}

.file-list-state {
    padding: 12px 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background 0.1s;
    word-break: break-all;
}

.file-item svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

.file-item:hover {
    background: var(--bg);
}

.file-item.active {
    background: #eff6ff;
    color: var(--accent);
}

.file-item.active svg {
    color: var(--accent);
}

/* ── Editor ── */

.editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.editor-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #cbd5e1;
}

.editor-empty svg {
    width: 48px;
    height: 48px;
}

.editor-empty p {
    font-size: 14px;
    color: #94a3b8;
}

.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.editor-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
}

.editor-filename {
    font-size: 13px;
    font-family: 'SFMono-Regular', 'Consolas', 'Menlo', monospace;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.edit-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--warning);
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-edit {
    background: var(--accent);
    color: white;
}

.btn-edit:hover {
    background: var(--accent-hover);
}

.btn-save {
    background: var(--success);
    color: white;
}

.btn-save:hover {
    background: var(--success-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

#fileContent {
    flex: 1;
    width: 100%;
    padding: 16px 18px;
    border: none;
    font-family: 'SFMono-Regular', 'Consolas', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.7;
    resize: none;
    color: var(--text);
    background: var(--surface);
    outline: none;
}

#fileContent[readonly] {
    background: #fafafa;
    color: #334155;
}

/* ── Toast ── */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 11px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 100;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ── Services / Containers panels ── */

.panel {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.data-table td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.row-actions {
    display: flex;
    gap: 6px;
}

.status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-running, .health-up     { background: #f0fdf4; color: var(--success); }
.status-stopped, .health-down   { background: #f1f5f9; color: var(--text-muted); }
.status-failed                  { background: #fef2f2; color: var(--danger); }
.status-starting, .status-stopping { background: #fffbeb; color: var(--warning); }
.status-unknown, .health-unknown   { background: #f1f5f9; color: var(--text-muted); }
