:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-2: #1e222b;
    --border: #2a2f3a;
    --text: #d7dbe3;
    --muted: #8b93a3;
    --accent: #3b82f6;
    --accent-hover: #2f6fe0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --ok: #22c55e;
    --bad: #ef4444;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
    background: var(--panel-2);
    padding: 1px 6px;
    border-radius: 4px;
}

/* ---------- shell / layout ---------- */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
}
.brand:hover { text-decoration: none; color: #fff; }
.brand-sub { color: var(--muted); font-size: 12px; }

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.page {
    max-width: 920px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 18px 48px;
    overflow: auto;
}

h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 15px; margin: 0 0 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

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

/* ---------- cards / forms ---------- */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--muted); }
.field em { color: #6b7280; font-style: normal; }
.field.host { grid-column: span 1; }
.field.port { max-width: 140px; }

input {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    padding: 9px 11px;
    font-size: 14px;
    width: 100%;
}
input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .25);
}

.actions { margin-top: 16px; display: flex; gap: 10px; }

.validation-message, .validation-errors {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
}
.validation-errors { list-style: none; padding: 0; }

/* ---------- buttons ---------- */
.btn {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: #262b36; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(239, 68, 68, .12); }

/* ---------- hosts table ---------- */
.hosts { width: 100%; border-collapse: collapse; }
.hosts th, .hosts td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.hosts th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.hosts .right { text-align: right; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- terminal page ---------- */
.term-page {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 10px;
}

.term-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}
.term-target { font-family: Consolas, "Cascadia Mono", monospace; color: var(--text); }
.spacer { flex: 1 1 auto; }

.term-status {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
}
.term-status.ok { color: var(--ok); border-color: rgba(34, 197, 94, .5); }
.term-status.bad { color: var(--bad); border-color: rgba(239, 68, 68, .5); }
.term-status.idle { color: var(--muted); }

.term-host {
    flex: 1 1 auto;
    min-height: 0;
    background: #1e1e1e;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    overflow: hidden;
}
/* let xterm fill the host element */
.term-host .xterm { height: 100%; }

.term-hint {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

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

/* ---------- Blazor unhandled-error toast ---------- */
/* Blazor toggles inline `display:block` on #blazor-error-ui when an error
   occurs, so this stays the positioning layer and the inner .error-toast
   owns the layout, surface, and entrance animation. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 28px;
    z-index: 2000;
    padding: 0 16px;
    pointer-events: none; /* let clicks fall through the empty gutter */
    font-size: 14px;
}

#blazor-error-ui > .error-toast {
    pointer-events: auto;
    position: relative;
    margin: 0 auto;
    max-width: 470px;
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 15px 46px 15px 15px;
    color: var(--text);
    background:
        radial-gradient(130% 150% at 0% 0%, rgba(239, 68, 68, .12), transparent 58%),
        linear-gradient(180deg, #1e222b, #15181e);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow:
        0 24px 50px -18px rgba(0, 0, 0, .75),
        0 0 0 1px rgba(239, 68, 68, .07),
        inset 0 1px 0 rgba(255, 255, 255, .04);
    animation: errorToastIn .4s cubic-bezier(.22, 1, .36, 1);
}

/* danger accent stripe */
#blazor-error-ui > .error-toast::before {
    content: "";
    position: absolute;
    left: 0;
    top: 13px;
    bottom: 13px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, #f87171, var(--danger));
    box-shadow: 0 0 14px rgba(239, 68, 68, .55);
}

#blazor-error-ui .error-toast__icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #fca5a5;
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .34);
}
#blazor-error-ui .error-toast__icon svg { width: 20px; height: 20px; }

#blazor-error-ui .error-toast__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 1px;
}
#blazor-error-ui .error-toast__title {
    margin: 0;
    font-weight: 600;
    color: #fff;
}
#blazor-error-ui .error-toast__desc {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.45;
}

#blazor-error-ui .error-toast__actions {
    flex: 0 0 auto;
    align-self: center;
}

/* Reload — primary call to action */
#blazor-error-ui a.reload {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 1px solid var(--accent);
    text-decoration: none;
    white-space: nowrap;
    transition: background .14s, box-shadow .14s, transform .08s;
}
#blazor-error-ui a.reload:hover {
    background: var(--accent-hover);
    text-decoration: none;
    box-shadow: 0 8px 20px -6px rgba(59, 130, 246, .55);
}
#blazor-error-ui a.reload:active { transform: translateY(1px); }
#blazor-error-ui a.reload svg { width: 14px; height: 14px; }

/* Dismiss — ghost icon button, top-right */
#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    color: var(--muted);
    cursor: pointer;
    font-size: 0; /* neutralize any stray glyph; icon is drawn via SVG */
    transition: background .14s, color .14s;
}
#blazor-error-ui .dismiss:hover { background: rgba(255, 255, 255, .07); color: #fff; }
#blazor-error-ui .dismiss:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .45);
}
#blazor-error-ui .dismiss svg { width: 13px; height: 13px; pointer-events: none; }

@keyframes errorToastIn {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 520px) {
    #blazor-error-ui { bottom: 16px; padding: 0 12px; }
    #blazor-error-ui > .error-toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    #blazor-error-ui > .error-toast { animation: none; }
}

/* ---------- auth header controls ---------- */
.user-email {
    color: var(--muted);
    font-size: 13px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.logout-form { margin: 0; display: inline; }

/* ---------- login / register ---------- */
.auth-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 18px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 26px 24px;
}
.auth-card h1 { font-size: 21px; margin: 0 0 6px; }
.auth-card .muted { margin: 0 0 18px; font-size: 13px; }
.auth-card .field { margin-bottom: 14px; }

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 18px;
    color: var(--muted);
    font-size: 13px;
}
.checkbox input { width: auto; }

.btn.block { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

.auth-error {
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .4);
    color: #fca5a5;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.auth-alt {
    margin: 16px 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
