:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2e2e2e;
    --bg-surface: #2a2a2a;
    --bg-hover: #353535;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-dim: #c13550;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --text-muted: #707070;
    --border: #3a3a3a;
    --border-light: #4a4a4a;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --radius: 6px;
    --radius-lg: 10px;
    --transition: 0.2s ease;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100%;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5em;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 0.75em; }

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

a:hover { color: var(--accent-hover); }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Buttons */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    padding: 0.5em 1em;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
}

button:hover, .btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

button:active, .btn:active {
    transform: scale(0.97);
}

button:disabled, .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

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

.btn-sm {
    padding: 0.3em 0.7em;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.4em;
    line-height: 1;
}

/* Inputs */
input[type="text"],
input[type="number"],
input[type="search"],
textarea {
    padding: 0.45em 0.7em;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition);
}

input:focus, textarea:focus {
    border-color: var(--accent);
}

/* Select */
select {
    padding: 0.4em 2em 0.4em 0.7em;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
    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='%23aab' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5em center;
}
select:focus {
    border-color: var(--accent);
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Checkbox */
input[type="checkbox"] {
    width: 1.1em;
    height: 1.1em;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Details / Summary */
details {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    margin-bottom: 0.4em;
}

details[open] {
    border-color: var(--border-light);
}

summary {
    padding: 0.6em 0.8em;
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5em;
    transition: background var(--transition);
    border-radius: var(--radius);
}

summary:hover {
    background: var(--bg-hover);
}

summary::before {
    content: '\25B6';
    font-size: 0.65em;
    transition: transform var(--transition);
    color: var(--text-muted);
}

details[open] > summary::before {
    transform: rotate(90deg);
}

summary::-webkit-details-marker {
    display: none;
}

details > :not(summary) {
    padding: 0 0.8em 0.6em;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 0.5em 0.75em;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 1;
}

tr:hover td {
    background: var(--bg-hover);
}

/* Dialog */
dialog {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1.5em;
    min-width: 360px;
    max-width: 90vw;
    max-height: 85vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    margin: auto;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

dialog h2 {
    margin-top: 0;
    margin-bottom: 1em;
    color: var(--accent);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-accent {
    background: var(--accent-dim);
    color: #fff;
    border-color: var(--accent);
}

.badge-success {
    background: #1a5d36;
    color: var(--success);
    border-color: var(--success);
}

.badge-warning {
    background: #5d3e0e;
    color: var(--warning);
    border-color: var(--warning);
}

/* Status bar */
.status-bar {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.3em 0;
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1em;
}

.tab-bar button {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.6em 1.2em;
    font-weight: 500;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.tab-bar button:hover {
    color: var(--text-primary);
    background: transparent;
    border-bottom-color: var(--border-light);
}

.tab-bar button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Utility */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.overflow-auto { overflow: auto; }
.w-full { width: 100%; }

/* Loading spinner */
#app {
    height: 100%;
}

.loading-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6rem;
    height: 6rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    color: var(--text-secondary);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* Blazor error UI */
#blazor-error-ui {
    background: var(--danger);
    color: #fff;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: var(--radius);
}

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

h1:focus {
    outline: none;
}
