:root {
    --bg: #0a0a0f;
    --bg-elevated: #0f1420;
    --border: #1e2530;
    --text: #e6ecf5;
    --text-muted: #94a3b8;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --accent-tint: rgba(14, 165, 233, 0.1);
    --error: #ef4444;
    --radius: 10px;
    --content-width: 1800px;

    --alert-error-bg: rgba(239, 68, 68, 0.1);
    --alert-error-border: rgba(239, 68, 68, 0.35);
    --alert-error-text: #fca5a5;
    --alert-info-bg: rgba(14, 165, 233, 0.1);
    --alert-info-border: rgba(14, 165, 233, 0.35);
    --alert-info-text: #7dd3fc;
    --badge-success-bg: rgba(34, 197, 94, 0.1);
    --badge-success-border: rgba(34, 197, 94, 0.35);
    --badge-success-text: #86efac;
    --badge-warning-bg: rgba(245, 158, 11, 0.1);
    --badge-warning-border: rgba(245, 158, 11, 0.35);
    --badge-warning-text: #fcd34d;
    --badge-info-bg: rgba(168, 85, 247, 0.1);
    --badge-info-border: rgba(168, 85, 247, 0.35);
    --badge-info-text: #d8b4fe;
    --badge-teal-bg: rgba(20, 184, 166, 0.1);
    --badge-teal-border: rgba(20, 184, 166, 0.35);
    --badge-teal-text: #5eead4;
    --badge-pink-bg: rgba(236, 72, 153, 0.1);
    --badge-pink-border: rgba(236, 72, 153, 0.35);
    --badge-pink-text: #f9a8d4;
    --badge-indigo-bg: rgba(99, 102, 241, 0.1);
    --badge-indigo-border: rgba(99, 102, 241, 0.35);
    --badge-indigo-text: #a5b4fc;
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --shadow: rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
    --bg: #f4f6fa;
    --bg-elevated: #ffffff;
    --border: #dbe2ea;
    --text: #101725;
    --text-muted: #5b6779;
    --accent: #0284c7;
    --accent-hover: #036ba1;
    --accent-tint: rgba(2, 132, 199, 0.1);
    --error: #dc2626;

    --alert-error-bg: rgba(220, 38, 38, 0.08);
    --alert-error-border: rgba(220, 38, 38, 0.3);
    --alert-error-text: #b91c1c;
    --alert-info-bg: rgba(2, 132, 199, 0.08);
    --alert-info-border: rgba(2, 132, 199, 0.3);
    --alert-info-text: #036ba1;
    --badge-success-bg: rgba(22, 163, 74, 0.08);
    --badge-success-border: rgba(22, 163, 74, 0.3);
    --badge-success-text: #15803d;
    --badge-warning-bg: rgba(217, 119, 6, 0.08);
    --badge-warning-border: rgba(217, 119, 6, 0.3);
    --badge-warning-text: #b45309;
    --badge-info-bg: rgba(147, 51, 234, 0.08);
    --badge-info-border: rgba(147, 51, 234, 0.3);
    --badge-info-text: #7e22ce;
    --badge-teal-bg: rgba(13, 148, 136, 0.08);
    --badge-teal-border: rgba(13, 148, 136, 0.3);
    --badge-teal-text: #0f766e;
    --badge-pink-bg: rgba(219, 39, 119, 0.08);
    --badge-pink-border: rgba(219, 39, 119, 0.3);
    --badge-pink-text: #be185d;
    --badge-indigo-bg: rgba(79, 70, 229, 0.08);
    --badge-indigo-border: rgba(79, 70, 229, 0.3);
    --badge-indigo-text: #4338ca;
    --overlay-bg: rgba(15, 23, 42, 0.35);
    --shadow: rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body, .topbar, .footer, .panel, .modal, .modal-overlay,
.toast, .field input, .advanced-options, .status-line, code,
.data-table th, .data-table td {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Manrope", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

.topbar {
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.topbar-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    font-weight: 600;
    font-size: 17px;
    letter-spacing: 0.2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-label {
    color: var(--text-muted);
    font-size: 13px;
}

.btn.theme-toggle-btn {
    padding: 7px;
}

/* topbar ghost buttons get a visible border; a table row's Disconnect button stays borderless, so this is scoped to the topbar only */
.topbar-actions .btn-ghost {
    border-color: var(--border);
}

.topbar-actions .btn-ghost:hover {
    border-color: var(--accent);
}

.theme-toggle-btn svg {
    width: 18px;
    height: 18px;
}

.theme-toggle-btn .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle-btn .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle-btn .icon-moon { display: block; }

.container {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.footer {
    border-top: 1px solid var(--border);
}

.footer-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 18px 24px;
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.footer-build {
    opacity: 0.7;
}

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 24px 0 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.muted { color: var(--text-muted); }
code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 13px; }

/* default browser blue-and-underline was unreadable on the dark theme - buttons styled as <a> (.btn) override this anyway */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.panel-narrow { max-width: 420px; margin: 60px auto; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.field span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }

.field input, .field select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
}

/* the native dropdown arrow looks different per OS, so this swaps in one solid triangle matching --text-muted; baked in per-theme as a data URI since background-image can't read CSS vars */
select, .field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.25rem;
}

    :root[data-theme="light"] select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235b6779' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    }

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

/* custom checkbox, since the OS-native box looked out of place next to everything else's styling */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    flex-shrink: 0;
    margin: 0;
    vertical-align: middle;
    border: 1.5px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    cursor: pointer;
    position: relative;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

input[type="checkbox"]:hover {
    border-color: var(--accent);
}

input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

input[type="checkbox"]:disabled {
    border-color: var(--border);
    opacity: 0.6;
    cursor: not-allowed;
}

/* the .field input/span rules are for text boxes with a caption above, not for a checkbox/radio row that happens to live in one */
.field .checkbox-field { margin-bottom: 8px; }
.field .checkbox-field span { display: inline; margin-bottom: 0; }
.field .checkbox-field input { padding: 0; }

/* custom radio, same idea as the checkbox above */
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    flex-shrink: 0;
    margin: 0;
    vertical-align: middle;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s ease;
}

input[type="radio"]:hover,
input[type="radio"]:checked {
    border-color: var(--accent);
}

input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--accent);
}

input[type="radio"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.checkbox-list {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
}

.checkbox-list label:hover {
    background: var(--bg-elevated);
}

.advanced-options {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
}

.advanced-options summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    user-select: none;
}

.advanced-options[open] summary { margin-bottom: 12px; color: var(--text); }
.advanced-options .field:last-of-type { margin-bottom: 10px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    line-height: 16px;
}

.btn-primary { background: var(--accent); color: #041420; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); }

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

.btn-block { width: 100%; }

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
    text-wrap: pretty;
}

.alert-error { background: var(--alert-error-bg); border: 1px solid var(--alert-error-border); color: var(--alert-error-text); }
.alert-info { background: var(--alert-info-bg); border: 1px solid var(--alert-info-border); color: var(--alert-info-text); }

#twoFactorRecoveryCodesText {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 10px 0;
    color: var(--text);
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success { background: var(--badge-success-bg); border-color: var(--badge-success-border); color: var(--badge-success-text); }
.badge-danger { background: var(--alert-error-bg); border-color: var(--alert-error-border); color: var(--alert-error-text); }
.badge-warning { background: var(--badge-warning-bg); border-color: var(--badge-warning-border); color: var(--badge-warning-text); }
.badge-neutral { background: var(--bg); border-color: var(--border); color: var(--text-muted); }
.badge-accent { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.badge-info { background: var(--badge-info-bg); border-color: var(--badge-info-border); color: var(--badge-info-text); }
.badge-teal { background: var(--badge-teal-bg); border-color: var(--badge-teal-border); color: var(--badge-teal-text); }
.badge-pink { background: var(--badge-pink-bg); border-color: var(--badge-pink-border); color: var(--badge-pink-text); }
.badge-indigo { background: var(--badge-indigo-bg); border-color: var(--badge-indigo-border); color: var(--badge-indigo-text); }

.status-line { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13px; background: var(--bg); border: 1px solid var(--border); }

.status-error { color: var(--alert-error-text); }
.status-line.status-error { background: var(--alert-error-bg); border-color: var(--alert-error-border); }

.action-row { display: flex; gap: 10px; margin-bottom: 16px; }

.share-url-row { display: flex; gap: 10px; margin-top: 10px; }
.share-url-row input { flex: 1; font-family: monospace; }

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.sidebar-column {
    position: sticky;
    top: 20px;
}

.sidebar {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 6px;
}

.sidebar-actions .btn-block { margin-top: 0; justify-content: flex-start; }

.nav-icon { flex-shrink: 0; }

.section-icon { flex-shrink: 0; color: var(--accent); }

.panel-header h2 { display: flex; align-items: center; gap: 8px; }

.sidebar-actions .btn.active { background: var(--accent-tint); border-color: var(--accent); color: var(--text); }

.sidebar-actions .btn:hover { background: var(--bg); }

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 24px 0 10px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.sidebar-group-toggle:hover { color: var(--text); }

.sidebar-group-chevron {
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.sidebar-group-toggle[aria-expanded="false"] .sidebar-group-chevron { transform: rotate(-90deg); }

.workspace { min-width: 0; }

.workspace-empty { padding: 32px 24px; }

.workspace-empty > .muted:first-child { text-align: center; margin-bottom: 24px; }

.workspace-empty h3 { margin-bottom: 8px; }

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar-column { position: static; }
}

.data-table-wrap {
    overflow-x: auto;
    margin-top: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.upload-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
}

.progress-wrap { margin-bottom: 16px; }

.progress-track {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.1s linear;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-primary:disabled, .btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 440px;
    width: 90%;
}

.modal h2 { margin-bottom: 12px; }
.modal p { margin: 0 0 12px; font-size: 14px; }
.modal .field { margin-top: 16px; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin: 0;
}

.info-list dt {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.info-list dd {
    margin: 0;
    font-size: 13px;
    word-break: break-word;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.list-row:last-child { border-bottom: none; }

.restore-proceed-btn {
    margin-top: 12px;
}

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    z-index: 200;
    max-width: 340px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    box-shadow: 0 8px 24px var(--shadow);
    cursor: pointer;
    animation: toast-in 0.15s ease-out;
}

.toast:hover { border-color: var(--accent); }
.toast.toast-error { border-left-color: var(--error); }

.toast-title { font-weight: 600; margin-bottom: 4px; }
.toast-body { color: var(--text-muted); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* the topbar hamburger's dropdown: two items today, but built to take more without redesigning */
.context-menu {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 60;
    padding: 4px;
    min-width: 160px;
}

.context-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.context-menu-item:hover { background: var(--border); }

.context-menu-item.context-menu-item-danger { color: var(--error); }
