html, body {
    font-family: var(--tc-font-sans);
    background-color: var(--tc-bg);
    color: var(--tc-text);
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
}

a, .btn-link {
    color: var(--tc-primary);
    text-decoration: none;
}

a:hover, .btn-link:hover {
    color: var(--tc-primary-hover);
    text-decoration: underline;
}

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

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

.btn-outline-primary {
    color: var(--tc-primary);
    border-color: var(--tc-primary);
}

.btn-outline-primary:hover {
    background-color: var(--tc-primary);
    border-color: var(--tc-primary);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.2);
}

.content {
    padding-top: 1.25rem;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--tc-text);
    font-weight: 600;
}

h1:focus {
    outline: none;
}

.text-muted {
    color: var(--tc-muted) !important;
}

.tc-card {
    background-color: var(--tc-card);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    box-shadow: var(--tc-shadow);
    padding: 1.25rem;
}

.tc-card-header {
    margin: -1.25rem -1.25rem 1rem -1.25rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--tc-border);
    font-weight: 600;
}

.tc-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1.5rem 0;
}

.tc-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--tc-text-secondary);
}

.tc-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.tc-badge-success {
    background-color: var(--tc-success-soft);
    color: var(--tc-success);
}

.tc-badge-danger {
    background-color: var(--tc-danger-soft);
    color: var(--tc-danger);
}

.tc-badge-warning {
    background-color: var(--tc-warning-soft);
    color: var(--tc-warning);
}

.tc-badge-info {
    background-color: var(--tc-info-soft);
    color: var(--tc-info);
}

.tc-badge-muted {
    background-color: #f1f5f9;
    color: var(--tc-muted);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--tc-success);
}

.invalid {
    outline: 1px solid var(--tc-danger);
}

.validation-message {
    color: var(--tc-danger);
}

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

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

.darker-border-checkbox.form-check-input {
    border-color: var(--tc-border-strong);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--tc-muted);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ---------- Blazor error UI (global — hidden until Blazor JS reveals it) ---------- */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

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

/* ---------- App shell (topbar + sidebar) ---------- */

.tc-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f6f8fa;
}

.tc-app-topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.tc-app-topbar-left,
.tc-app-topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tc-app-brand,
.tc-app-brand:hover,
.tc-app-brand:focus {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none !important;
    color: #111827 !important;
}

.tc-app-brand-logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #1f2937, #0f172a);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tc-app-brand-text {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #111827;
}

.tc-brand-accent {
    color: #14b8a6;
}

.tc-app-iconbtn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #4b5563;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.tc-app-iconbtn:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.tc-app-profile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    color: #374151;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background-color 120ms ease;
}

.tc-app-profile:hover {
    background-color: #f3f4f6;
}

.tc-app-profile-icon {
    display: inline-flex;
    align-items: center;
}

.tc-app-profile-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
    padding: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease;
    z-index: 20;
}

.tc-app-profile:hover .tc-app-profile-menu,
.tc-app-profile:focus-within .tc-app-profile-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.tc-app-profile-name {
    font-size: 0.78rem;
    color: #6b7280;
    padding: 0.4rem 0.6rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0.25rem;
}

.tc-app-profile-menu a {
    display: block;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    color: #374151 !important;
    text-decoration: none !important;
    font-weight: 500;
    font-size: 0.9rem;
}

.tc-app-profile-menu a:hover {
    background-color: #f3f4f6;
    color: #111827 !important;
    text-decoration: none !important;
}

.tc-app-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.tc-app-sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    padding: 1.25rem 0.85rem;
    flex-shrink: 0;
    transition: width 180ms ease, padding 180ms ease;
    overflow: hidden;
}

.tc-app-sidebar.tc-collapsed {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-width: 0;
}

.tc-app-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-x: auto;
    min-width: 0;
}

/* ---------- Sidebar nav (must be global — NavLink renders outside scope) ---------- */

.tc-app-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    white-space: nowrap;
}

.tc-app-nav-group {
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 600;
    color: #9ca3af;
    letter-spacing: 0.06em;
    padding: 1rem 0.85rem 0.35rem 0.85rem;
}

.tc-app-nav .tc-app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    color: #374151 !important;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none !important;
    transition: background-color 120ms ease, color 120ms ease;
}

.tc-app-nav .tc-app-nav-link:hover {
    background-color: #f3f4f6;
    color: #111827 !important;
    text-decoration: none !important;
}

.tc-app-nav .tc-app-nav-link.active,
.tc-app-nav .tc-app-nav-link.active:hover {
    background-color: rgba(20, 184, 166, 0.12);
    color: #0f766e !important;
}

.tc-app-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    flex-shrink: 0;
}

.tc-app-nav .tc-app-nav-link.active .tc-app-nav-icon {
    color: #14b8a6;
}

@media (max-width: 720px) {
    .tc-app-sidebar {
        position: fixed;
        left: 0;
        top: 64px;
        bottom: 0;
        z-index: 8;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.04);
    }

    .tc-app-content {
        padding: 1rem;
    }
}
