/* ---------------------------------------------------------------------------
   Design concept: "control room for isolated islands."
   Each instance is a sealed, invisible-to-others space — so the visual
   language leans into isolated cards floating on a dark grid, with a single
   signal color (a clear cyan-green, like an active status light) marking
   what's live. Monospace is reserved for anything identity-bearing (join
   codes, UUIDs) to read as literal, copyable data rather than decoration.
--------------------------------------------------------------------------- */

:root {
    --bg: #0d1117;
    --bg-elevated: #151b23;
    --border: #26303c;
    --text: #e6edf3;
    --text-dim: #8b98a5;
    --signal: #3ddc97;       /* active / live */
    --signal-dim: #1f6e4d;
    --warn: #e8a13b;
    --danger: #e5534b;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
}

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

.shell {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 80px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.topbar .brand {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.topbar .brand span {
    color: var(--signal);
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
}

.auth-card {
    max-width: 380px;
    margin: 10vh auto 0;
}

.auth-card h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.auth-card p.sub {
    color: var(--text-dim);
    margin: 0 0 24px;
    font-size: 13.5px;
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-family: var(--font-ui);
    font-size: 14.5px;
    margin-bottom: 16px;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--signal);
}

button, .btn {
    background: var(--signal);
    color: #06231a;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

button.secondary, .btn.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

button:hover { filter: brightness(1.08); }

.error {
    background: rgba(229, 83, 75, 0.1);
    border: 1px solid var(--danger);
    color: #ffb4af;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 16px;
}

.instance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.instance-card {
    position: relative;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.instance-card::before {
    content: '';
    position: absolute;
    top: 18px;
    left: -1px;
    width: 3px;
    height: 22px;
    background: var(--signal);
    border-radius: 0 3px 3px 0;
}

.instance-card h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

.instance-card .meta {
    color: var(--text-dim);
    font-size: 12.5px;
    margin-bottom: 10px;
}

.instance-card .code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    display: inline-block;
    letter-spacing: 0.04em;
}

.pill {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pill.active { background: rgba(61, 220, 151, 0.15); color: var(--signal); }
.pill.archived { background: rgba(139, 152, 165, 0.15); color: var(--text-dim); }
.pill.disabled { background: rgba(229, 83, 75, 0.15); color: var(--danger); }

.section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 0 0 14px;
}

.qr-box {
    background: #fff;
    padding: 12px;
    border-radius: 8px;
    display: inline-block;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

/* ---------------------------------------------------------------------------
   Sidebar app shell (left nav instead of top bar)
--------------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.app-sidebar-head {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.app-sidebar-head span { color: var(--signal); }
.app-nav { padding: 10px 0; flex: 1; }
.app-nav-title {
    padding: 14px 18px 6px;
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.app-nav a {
    display: block;
    padding: 9px 18px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    border-left: 2px solid transparent;
}
.app-nav a:hover { background: var(--bg); }
.app-nav a.active { background: var(--bg); border-left-color: var(--signal); color: var(--signal); }
.app-sidebar-foot {
    padding: 14px 18px 18px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-dim);
}
.app-sidebar-foot a { display: block; margin-top: 4px; }
.app-main { flex: 1; min-width: 0; }
.app-content { padding: 28px 32px 60px; max-width: 1100px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a {
    padding: 9px 14px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13.5px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--signal); }

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.list-row:last-child { border-bottom: none; }
.list-row .meta { color: var(--text-dim); font-size: 12.5px; }

.chat-log { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.chat-msg { max-width: 80%; }
.chat-msg .who { font-size: 12px; color: var(--text-dim); margin-bottom: 2px; }
.chat-msg .bubble { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.chat-msg.mine { align-self: flex-end; }
.chat-msg.mine .bubble { background: var(--signal-dim); border-color: var(--signal); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th, table.data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data-table th { color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

@media (max-width: 780px) {
    .app-sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .15s; }
    .app-sidebar.open { transform: translateX(0); }
    .app-content { padding: 18px 16px 60px; }
}
