:root {
    --bg: #f3f5ef;
    --panel: rgba(255, 255, 255, 0.84);
    --ink: #18221e;
    --muted: #61746b;
    --line: rgba(24, 34, 30, 0.12);
    --accent: #1d6b52;
    --accent-strong: #15513e;
    --danger: #9d3030;
    --shadow: 0 24px 60px rgba(20, 38, 31, 0.12);
}

html, body {
    min-height: 100%;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(29, 107, 82, 0.14), transparent 30%),
        linear-gradient(180deg, #f8faf6 0%, var(--bg) 100%);
}

body {
    margin: 0;
}

a, .btn-link {
    color: var(--accent);
}

.btn {
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover:not(:disabled),
.btn:focus-visible:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(20, 38, 31, 0.12);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(20, 38, 31, 0.1);
}

.btn:disabled,
.btn.disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    color: #fff;
    background-color: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem rgba(255, 255, 255, 0.8), 0 0 0 0.25rem rgba(29, 107, 82, 0.25);
}

.content {
    padding: 0 2rem 2rem;
}

h1:focus {
    outline: none;
}

.hero-card,
.editor-card,
.app-card,
.list-card,
.empty-state {
    background: var(--panel);
    backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero-card {
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.hero-card.compact {
    padding: 1.5rem 1.75rem;
}

.eyebrow {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.hero-copy,
.note-text {
    margin: 0;
    color: var(--muted);
}

.note-text {
    margin-top: 0.75rem;
}

.auth-shell {
    min-height: calc(100vh - 10rem);
    display: grid;
    place-items: center;
}

.auth-shell .hero-card {
    width: min(100%, 28rem);
}

.stack {
    display: grid;
    gap: 1rem;
}

.card-grid,
.admin-grid {
    display: grid;
    gap: 1.25rem;
}

.card-grid {
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}

.admin-grid {
    grid-template-columns: minmax(18rem, 26rem) 1fr;
    align-items: start;
}

.admin-grid.wide {
    grid-template-columns: repeat(2, minmax(18rem, 1fr));
}

.editor-card,
.app-card,
.list-card,
.empty-state {
    padding: 1.5rem;
}

.span-2 {
    grid-column: span 2;
}

.card-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

.card-header h2,
.card-header h3 {
    margin: 0 0 0.25rem;
}

.card-header p {
    margin: 0;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-pill.running {
    background: rgba(29, 107, 82, 0.12);
    color: var(--accent-strong);
}

.status-pill.stopped {
    background: rgba(157, 48, 48, 0.12);
    color: var(--danger);
}

.status-pill.pending {
    background: rgba(180, 120, 20, 0.14);
    color: #7d5600;
}

.detail-list {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 0.5rem 0.75rem;
    margin: 0 0 1rem;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 600;
}

.detail-list dd {
    margin: 0;
    word-break: break-word;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.maintenance-actions {
    position: relative;
    z-index: 3;
}

.maintenance-actions .btn {
    position: relative;
    z-index: 4;
    pointer-events: auto;
    cursor: pointer !important;
    touch-action: manipulation;
}

.maintenance-actions .btn:hover:not(:disabled),
.maintenance-actions .btn:focus-visible:not(:disabled) {
    color: #fff;
    background-color: var(--accent-strong);
    border-color: var(--accent-strong);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(20, 38, 31, 0.14);
}

.maintenance-actions .btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(20, 38, 31, 0.1);
}

.selection-list {
    display: grid;
    gap: 0.6rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.9rem;
    background: rgba(255, 255, 255, 0.45);
}

.selection-item {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.table-shell {
    overflow-x: auto;
}

.shared-drop-surface {
    position: relative;
    display: block;
    border: 2px dashed rgba(29, 107, 82, 0.35);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.45);
    padding: 0.75rem 0.75rem 0;
    margin-top: 0.5rem;
    overflow: hidden;
}

.shared-drop-surface.readonly {
    border-style: solid;
    background: rgba(255, 255, 255, 0.3);
}

.shared-drop-surface.disabled {
    opacity: 0.7;
    cursor: progress;
}

.shared-drop-surface:not(.readonly):hover {
    border-color: rgba(29, 107, 82, 0.65);
    background: rgba(255, 255, 255, 0.62);
}

.table th {
    color: var(--muted);
    font-weight: 700;
}

.table td {
    word-break: break-word;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.project-section {
    margin-bottom: 2rem;
}

.section-heading {
    margin-bottom: 1rem;
}

.config-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
    margin-top: 1rem;
}

.code-editor {
    min-height: 18rem;
    font-family: Consolas, "Courier New", monospace;
    white-space: pre;
}

.meta-line {
    color: var(--muted);
    margin-bottom: 1rem;
}

.empty-editor-state {
    border: 1px dashed var(--line);
    border-radius: 16px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.35);
    color: var(--muted);
}

.log-shell {
    margin-top: 1rem;
}

.compact-header {
    margin-bottom: 0.75rem;
    align-items: center;
}

.compact-header h4 {
    margin: 0;
}

.log-shell h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.console-log {
    margin: 0;
    overflow: auto;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #18221e;
    color: #e7f0eb;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.console-log.compact {
    height: 7.5rem;
}

.console-log.expanded {
    height: 20rem;
}

.code-editor.compact {
    min-height: 14rem;
    max-height: 14rem;
    overflow: auto;
}

.drop-zone {
    position: relative;
    display: grid;
    gap: 0.35rem;
    border: 2px dashed rgba(29, 107, 82, 0.35);
    border-radius: 18px;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.45);
    margin-bottom: 1rem;
    cursor: pointer;
    overflow: hidden;
}

.drop-zone.disabled {
    opacity: 0.65;
    cursor: progress;
}

.drop-zone:hover {
    border-color: rgba(29, 107, 82, 0.65);
    background: rgba(255, 255, 255, 0.62);
}

.drop-title {
    font-weight: 700;
}

.drop-copy {
    color: var(--muted);
}

.drop-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.shared-folder-table {
    position: relative;
    z-index: 1;
    margin-bottom: 0;
}

.shared-folder-table a,
.shared-folder-table button,
.shared-folder-table input {
    position: relative;
    z-index: 2;
}

.folder-toolbar {
    margin-bottom: 1rem;
}

.folder-name-input {
    max-width: 18rem;
}

.shared-entry-actions {
    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.folder-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent-strong);
    font-weight: 700;
    text-align: left;
}

.folder-link:hover:not(:disabled),
.folder-link:focus-visible {
    text-decoration: underline;
}

.folder-link:disabled {
    opacity: 0.6;
}

.parent-row td {
    border-bottom-style: dashed;
}

.parent-link {
    color: var(--muted);
}

.folder-link-icon {
    display: inline-flex;
    width: 1.05rem;
    height: 1.05rem;
    color: #b57b00;
    flex: 0 0 auto;
}

.folder-link-icon svg,
.icon-action svg {
    width: 100%;
    height: 100%;
}

.file-name {
    color: var(--ink);
}

.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    text-decoration: none;
}

.icon-primary {
    color: var(--accent-strong);
}

.icon-primary:hover,
.icon-primary:focus-visible {
    background: rgba(29, 107, 82, 0.12);
    border-color: rgba(29, 107, 82, 0.28);
}

.icon-danger {
    color: var(--danger);
}

.icon-danger:hover,
.icon-danger:focus-visible {
    background: rgba(157, 48, 48, 0.12);
    border-color: rgba(157, 48, 48, 0.28);
}

.icon-action:disabled {
    opacity: 0.55;
}

.shared-drop-hint {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.2rem;
    padding: 0.9rem 0.3rem 1rem;
    color: var(--muted);
}

.shared-empty-state {
    margin-bottom: 0.75rem;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

@media (max-width: 900px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-grid.wide {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .content {
        padding: 0 1rem 1.5rem;
    }
}
