:root {
    --brand-primary: #1e88e5;
    --brand-primary-dark: #1565c0;
    --brand-surface: #ffffff;
    --brand-muted: #4b5563;
    --brand-success: #16a34a;
    --brand-danger: #dc2626;
    --border-radius-lg: 18px;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f4f5f7;
    color: #111827;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--brand-primary);
}

a:hover {
    color: var(--brand-primary-dark);
}

.navbar {
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.92) !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav-link {
    font-weight: 500;
    color: rgba(17, 24, 39, 0.78) !important;
    transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #0f172a !important;
}

.app-shell {
    flex: 1;
    padding-top: 5rem;
}

.container-xxl {
    max-width: 1200px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.page-header .title-block h1 {
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.page-header .title-block p {
    margin: 0;
    color: rgba(75, 85, 99, 0.85);
}

.card {
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    color: #111827;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.card-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.metric-card .metric-value {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
}

.metric-card .metric-label {
    color: var(--brand-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
}

.metric-trend {
    font-size: 0.9rem;
    color: var(--brand-success);
}

.table {
    color: #111827;
    margin-bottom: 0;
    font-size: 0.95rem;
}

.table tbody td,
.table tbody th {
    color: #111827;
}

.table > :not(caption) > * > * {
    background-color: #fff;
    border: none;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(148, 163, 184, 0.1);
}

.table-hover tbody tr:hover {
    background-color: rgba(30, 136, 229, 0.15);
}

.table thead th {
    color: rgba(75, 85, 99, 0.85);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    background: rgba(148, 163, 184, 0.2);
}

.status-badge.status-active {
    background: rgba(22, 163, 74, 0.15);
    color: #166534;
}

.status-badge.status-inactive {
    background: rgba(220, 38, 38, 0.15);
    color: #b91c1c;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
    border: none;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.55rem 1.4rem;
    box-shadow: 0 15px 30px rgba(30, 136, 229, 0.35);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--brand-primary-dark), #0e4a86);
    box-shadow: 0 18px 40px rgba(30, 136, 229, 0.45);
}

.btn-outline-secondary {
    border-radius: 12px;
    color: #111827;
    border-color: rgba(148, 163, 184, 0.5);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    color: #0f172a;
    border-color: rgba(148, 163, 184, 0.8);
    background: rgba(148, 163, 184, 0.2);
}

.form-control,
.form-select {
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #0f172a;
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(30, 136, 229, 0.65);
    box-shadow: 0 0 0 0.2rem rgba(30, 136, 229, 0.15);
    background: #fff;
    color: #0f172a;
}

.form-label {
    font-weight: 500;
    color: rgba(17, 24, 39, 0.78);
    letter-spacing: 0.01em;
}

.text-danger {
    color: #f87171 !important;
}

.alert {
    border-radius: 16px;
    border: none;
}

.alert-success {
    background: rgba(22, 163, 74, 0.15);
    color: #166534;
}

.alert-danger {
    background: rgba(220, 38, 38, 0.15);
    color: #b91c1c;
}

.table-actions {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.table-actions .btn {
    padding: 0.35rem 0.75rem;
    border-radius: 10px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.footer-note {
    font-size: 0.85rem;
    color: rgba(75, 85, 99, 0.7);
    text-align: center;
    padding: 2rem 0 3rem;
}

@media (max-width: 992px) {
    .navbar {
        background: rgba(255, 255, 255, 0.98) !important;
    }

    .app-shell {
        padding-top: 6rem;
    }
}

.auth-body {
    min-height: 100vh;
    background: #f4f5f7;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.25rem;
    color: #111827;
}

.auth-wrapper {
    width: min(100%, 420px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.auth-brand-link {
    text-decoration: none;
    color: inherit;
    display: inline-flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.auth-brand-icon {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 136, 229, 0.12);
    color: var(--brand-primary);
    font-size: 2rem;
}

.auth-brand-text {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.95rem;
}

.auth-card {
    width: 100%;
    border-radius: 24px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.auth-card .card-body {
    padding: clamp(1.75rem, 3vw, 2.75rem);
}

/* Single-level auth card variation for clean, centered auth layouts */
.auth-card--single-level {
    max-width: 720px;
    width: 100%;
    margin: 1rem auto;
}

.auth-card-inner {
    padding-top: 0.5rem;
}

.auth-title {
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: rgba(75, 85, 99, 0.85);
    margin-bottom: 1.75rem;
}

.auth-footer {
    font-size: 0.85rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
    margin: 1.5rem 0;
    color: rgba(75, 85, 99, 0.6);
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(148, 163, 184, 0.4);
}

.auth-link {
    color: var(--brand-primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-link:hover {
    color: var(--brand-primary-dark);
    text-decoration: underline;
}

.auth-alt-provider {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-alt-provider button {
    width: 100%;
}
.auth-alt-provider .provider-logo {
    width: 20px;
    height: 20px;
    vertical-align: -3px;
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.auth-form .form-floating {
    margin-bottom: 0;
}

.manage-nav {
    width: 100%;
    max-width: 260px;
    padding: 1.5rem 1.25rem;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

n/* Ensure buttons in the manage content area don't inherit unexpected transforms/writing-mode */
.manage-nav + .flex-grow-1 .btn,
.manage-nav + .flex-grow-1 button {
    transform: none !important;
    writing-mode: horizontal-tb !important;
}

/* Slightly increase spacing for manage page content */
@media (min-width: 992px) {
    .manage-nav + .flex-grow-1 {
        padding-left: 0.5rem;
    }
}

/* Ensure profile/manage content has a reasonable minimum width so form controls don't collapse */
.manage-nav + .flex-grow-1 .profile-content {
    min-width: 320px;
    padding-left: 0.75rem;
}

/* Force form controls to take full width and avoid shrinking */
.manage-nav + .flex-grow-1 .profile-content .form-control {
    width: 100% !important;
    min-width: 200px;
}

/* Strongly reset any unexpected rotation/writing-mode for the profile action button */
#update-profile-button,
.manage-nav + .flex-grow-1 .profile-content #update-profile-button {
    transform: none !important;
    -webkit-transform: none !important;
    writing-mode: horizontal-tb !important;
    -webkit-writing-mode: horizontal-tb !important;
    display: inline-block !important;
    white-space: nowrap !important;
    align-self: flex-end !important;
    margin-top: 1rem;
    min-width: 140px;
}

/* Provide a fallback alignment for small screens */
@media (max-width: 767.98px) {
    #update-profile-button {
        width: 100% !important;
        min-width: 0;
    }
}

/* Strong reset for Manage page controls to prevent vertical orientation */
.manage-nav, .manage-nav *, .profile-content, .profile-content * {
    writing-mode: horizontal-tb !important;
    -webkit-writing-mode: horizontal-tb !important;
    transform: none !important;
    -webkit-transform: none !important;
    rotate: 0deg !important;
}

#update-profile-button, .profile-save {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    -webkit-transform: none !important;
    rotate: 0deg !important;
    writing-mode: horizontal-tb !important;
    -webkit-writing-mode: horizontal-tb !important;
    display: inline-block !important;
    white-space: nowrap !important;
    min-width: 140px !important;
    margin-top: 1rem !important;
    box-shadow: 0 12px 30px rgba(30, 136, 229, 0.25) !important;
    border-radius: 12px !important;
}

/* Ensure inputs don't collapse */
.profile-content .form-control {
    width: 100% !important;
    min-width: 220px !important;
    max-width: 520px !important;
}

/* Temporary visual aid: subtle outline to help debug layout (remove if ok) */
.profile-content #update-profile-button { outline: 2px solid rgba(30,136,229,0.12) !important; }

.manage-nav-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(75, 85, 99, 0.7);
    margin-bottom: 1.25rem;
}

.manage-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.manage-link {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    font-weight: 500;
    color: rgba(17, 24, 39, 0.78);
    text-decoration: none;
    transition: all 0.2s ease;
}

.manage-link i {
    font-size: 1rem;
}

.manage-link:hover {
    background: rgba(30, 136, 229, 0.1);
    color: var(--brand-primary);
}

.manage-link.active {
    background: rgba(30, 136, 229, 0.18);
    color: var(--brand-primary-dark);
    box-shadow: inset 0 0 0 1px rgba(30, 136, 229, 0.35);
}
