@import url('https://fonts.googleapis.com/css2?family=Mulish:wght@400;500;600;700;800&family=Inter:wght@400;500;600&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #050811;
    --card: rgba(15, 23, 42, 0.92);
    --border: rgba(255, 255, 255, 0.08);
    --text: #e5e7eb;
    --muted: #9ca3af;
    --brand: #ffde00;
    --brand-dark: #0a0f1c;
    --purple: #7c3a96;
    --danger: #f87171;
    --success: #4ade80;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', 'Mulish', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(124, 58, 150, 0.18), transparent 35%),
        radial-gradient(circle at bottom left, rgba(255, 222, 0, 0.08), transparent 30%),
        var(--bg);
}

.admin-brand h1,
.admin-shell h1,
.admin-shell h2,
.card h2 {
    font-family: 'Outfit', 'Mulish', sans-serif;
}

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

.admin-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

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

.admin-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}

.admin-topbar-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-topbar {
    padding: 10px 14px;
    font-size: 0.84rem;
    white-space: nowrap;
}

.btn-topbar i {
    font-size: 0.82rem;
    opacity: 0.9;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-brand img,
.admin-brand-logo {
    height: 64px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

@media (min-width: 768px) {
    .admin-brand img,
    .admin-brand-logo {
        height: 80px;
    }
}

.admin-brand h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.admin-brand p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    backdrop-filter: blur(8px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.card h2 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.card .subtitle {
    color: var(--muted);
    margin-bottom: 20px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #d1d5db;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: white;
    font: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(255, 222, 0, 0.45);
    box-shadow: 0 0 0 3px rgba(255, 222, 0, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: var(--brand);
    color: var(--brand-dark);
}

.btn-primary:hover { filter: brightness(1.05); }

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 222, 0, 0.12);
    border-color: rgba(255, 222, 0, 0.45);
    color: var(--brand);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 222, 0, 0.15);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.82rem;
    border-radius: 10px;
}

.btn-danger {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.55);
    color: #fecaca;
    transform: translateY(-1px);
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.checkbox-field {
    margin-top: 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d1d5db;
    font-size: 0.92rem;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
    accent-color: var(--brand);
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.alert-success {
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.25);
    color: var(--success);
}

.alert-error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.25);
    color: var(--danger);
}

.login-wrap {
    min-height: calc(100vh - 64px);
    display: grid;
    place-items: center;
    padding: 24px 16px 32px;
}

.login-page {
    min-height: 100vh;
}

.login-site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    background: rgba(5, 8, 17, 0.88);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
}

.login-site-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}

.login-site-brand img {
    height: 40px;
    width: auto;
}

.login-site-brand span {
    font-family: 'Outfit', 'Mulish', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.login-site-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-site-link {
    color: #d1d5db;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    transition: color 0.15s ease, background 0.15s ease;
}

.login-site-link:hover {
    color: var(--brand);
    background: rgba(255, 222, 0, 0.08);
    text-decoration: none;
}

/* Site navbar profile dropdown */
.nav-profile {
    position: relative;
}

.nav-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    cursor: pointer;
    font: inherit;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.nav-profile-btn:hover,
.nav-profile.is-open .nav-profile-btn {
    border-color: rgba(255, 222, 0, 0.35);
    background: rgba(255, 222, 0, 0.08);
}

.nav-profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--brand-dark);
    font-size: 0.78rem;
    font-weight: 800;
    flex-shrink: 0;
}

.nav-profile-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    min-width: 0;
    text-align: left;
}

.nav-profile-name {
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.1;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-profile-role {
    font-size: 0.68rem;
    color: var(--muted);
    line-height: 1.1;
}

.nav-profile-chevron {
    width: 16px;
    height: 16px;
    color: var(--muted);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.nav-profile.is-open .nav-profile-chevron {
    transform: rotate(180deg);
}

.nav-profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 15, 28, 0.98);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    z-index: 60;
}

.nav-profile.is-open .nav-profile-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-profile-meta {
    padding: 10px 12px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 6px;
}

.nav-profile-meta strong {
    display: block;
    font-size: 0.92rem;
    color: #fff;
    margin-bottom: 2px;
}

.nav-profile-meta span {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    word-break: break-all;
}

.nav-profile-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-profile-menu a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-profile-menu a:hover {
    background: rgba(255, 222, 0, 0.1);
    color: var(--brand);
    text-decoration: none;
}

.nav-profile-menu a[hidden] {
    display: none !important;
}

.nav-profile-logout {
    color: #fca5a5 !important;
}

.nav-profile-logout:hover {
    background: rgba(248, 113, 113, 0.12) !important;
    color: #fecaca !important;
}

.nav-profile-mobile {
    width: 100%;
}

.nav-profile-mobile .nav-profile-btn {
    width: 100%;
    justify-content: flex-start;
    border-radius: 14px;
    padding: 10px 12px;
}

.nav-profile-mobile .nav-profile-name {
    max-width: none;
}

.nav-profile-mobile .nav-profile-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 8px;
    display: none;
}

.nav-profile-mobile.is-open .nav-profile-menu {
    display: block;
}

@media (max-width: 767px) {
    .login-site-brand span {
        display: none;
    }

    .nav-profile-label {
        display: none;
    }

    .nav-profile-btn {
        padding: 4px;
        border-radius: 50%;
    }
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 20px 22px 18px;
}

.login-card .field {
    margin-bottom: 10px;
}

.login-card .field:last-of-type {
    margin-bottom: 12px;
}

.login-card .field label {
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.login-card .field input {
    padding: 10px 12px;
    border-radius: 10px;
    color: #fff !important;
    caret-color: #fff;
    -webkit-text-fill-color: #fff;
}

.login-card .field input::placeholder {
    color: rgba(156, 163, 175, 0.75);
    -webkit-text-fill-color: rgba(156, 163, 175, 0.75);
    opacity: 1;
}

.login-card .field input:-webkit-autofill,
.login-card .field input:-webkit-autofill:hover,
.login-card .field input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #0f172a inset !important;
    box-shadow: 0 0 0 1000px #0f172a inset !important;
    -webkit-text-fill-color: #fff !important;
    caret-color: #fff;
    border: 1px solid rgba(255, 222, 0, 0.35);
    transition: background-color 99999s ease-out 0s;
}

.password-field-wrap {
    display: flex;
    align-items: stretch;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: #0f172a;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.password-field-wrap:focus-within {
    border-color: rgba(255, 222, 0, 0.45);
    box-shadow: 0 0 0 3px rgba(255, 222, 0, 0.12);
}

.password-field-wrap input {
    flex: 1;
    min-width: 0;
    border: none !important;
    border-radius: 0 !important;
    background: #0f172a !important;
    box-shadow: none !important;
    padding: 10px 12px;
    color: #fff !important;
    caret-color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.password-field-wrap input[type="password"] {
    font-family: inherit;
    letter-spacing: 0.12em;
}

.password-field-wrap input[type="text"] {
    letter-spacing: 0.02em;
}

.password-field-wrap input:focus {
    outline: none;
    box-shadow: none !important;
}

.password-field-wrap input:-webkit-autofill,
.password-field-wrap input:-webkit-autofill:hover,
.password-field-wrap input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #0f172a inset !important;
    box-shadow: 0 0 0 1000px #0f172a inset !important;
    -webkit-text-fill-color: #fff !important;
    caret-color: #fff !important;
    transition: background-color 99999s ease-out 0s;
}

.password-field-wrap:has(input:-webkit-autofill) {
    border-color: rgba(255, 222, 0, 0.35);
}

.password-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 0 12px;
    margin: 0;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: #cbd5e1;
    cursor: pointer;
    font: inherit;
    transition: color 0.15s ease, background 0.15s ease;
}

.password-toggle:hover {
    color: var(--brand);
    background: rgba(255, 222, 0, 0.1);
}

.password-toggle.is-visible {
    color: var(--brand);
    background: rgba(255, 222, 0, 0.14);
}

.password-toggle:focus {
    outline: none;
}

.password-toggle:focus-visible {
    outline: 2px solid rgba(255, 222, 0, 0.45);
    outline-offset: -2px;
}

.password-toggle-icons {
    position: relative;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.password-toggle-icon {
    position: absolute;
    font-size: 1rem;
    line-height: 1;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.password-toggle-show {
    opacity: 1;
    transform: scale(1);
}

.password-toggle-hide {
    opacity: 0;
    transform: scale(0.85);
}

.password-toggle.is-visible .password-toggle-show {
    opacity: 0;
    transform: scale(0.85);
}

.password-toggle.is-visible .password-toggle-hide {
    opacity: 1;
    transform: scale(1);
}

.password-toggle-text {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
}

@media (max-width: 420px) {
    .password-toggle {
        padding: 0 10px;
    }

    .password-toggle-text {
        display: none;
    }
}

.login-card .btn-primary {
    padding: 11px 16px;
}

.login-submit-btn {
    width: 100%;
    margin-top: 4px;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.login-card .alert {
    margin-bottom: 12px;
    padding: 10px 12px;
    font-size: 0.88rem;
}

.login-footer {
    text-align: center;
    margin: 12px 0 0;
}

.login-title {
    margin: 0 0 14px;
    text-align: center;
    font-family: 'Outfit', 'Mulish', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.login-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0;
    background: transparent;
    border: none;
}

.login-tab {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font: inherit;
    padding: 9px 10px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.login-tab:hover:not(.is-active) {
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.05);
}

.login-tab:focus {
    outline: none;
}

.login-tab:focus-visible {
    outline: 2px solid rgba(255, 222, 0, 0.55);
    outline-offset: 2px;
}

.login-tab.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-dark);
    box-shadow: 0 6px 16px rgba(255, 222, 0, 0.18);
}

.login-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.login-tab-icon svg {
    width: 15px;
    height: 15px;
}

.login-tab.is-active .login-tab-icon {
    background: rgba(10, 15, 28, 0.12);
}

.login-tab-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.login-tab-label {
    font-family: 'Outfit', 'Mulish', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.15;
}

.login-tab-hint {
    font-size: 0.68rem;
    font-weight: 500;
    opacity: 0.72;
    line-height: 1.15;
}

.login-tab.is-active .login-tab-hint {
    opacity: 0.85;
}

.login-tab-desc-wrap {
    margin-bottom: 12px;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.login-tab-desc {
    text-align: center;
    color: #cbd5e1;
    font-size: 0.8rem;
    margin: 0;
    line-height: 1.35;
}

/* Logged-in module switcher (CRM ↔ Assurance) */
.module-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-width: 0;
    width: min(100%, 320px);
}

.module-switcher-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.module-switcher-tab:hover:not(.is-active) {
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.05);
    text-decoration: none;
}

.module-switcher-tab.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-dark);
    box-shadow: 0 6px 18px rgba(255, 222, 0, 0.2);
    transform: translateY(-1px);
}

.module-switcher-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.module-switcher-icon svg {
    width: 16px;
    height: 16px;
}

.module-switcher-tab.is-active .module-switcher-icon {
    background: rgba(10, 15, 28, 0.12);
}

.module-switcher-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.module-switcher-label {
    font-family: 'Outfit', 'Mulish', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.15;
}

.module-switcher-hint {
    font-size: 0.68rem;
    font-weight: 500;
    opacity: 0.72;
    line-height: 1.15;
}

.module-switcher-tab.is-active .module-switcher-hint {
    opacity: 0.85;
}

.admin-topbar .module-switcher {
    width: 300px;
    flex: 0 0 auto;
}

@media (max-width: 960px) {
    .admin-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-topbar-actions {
        width: 100%;
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .admin-topbar .module-switcher {
        width: 100%;
        max-width: none;
    }

    .admin-topbar-tools {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
}

.login-card .logo {
    display: block;
    margin: 0 auto 12px;
    height: 52px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

@media (min-width: 768px) {
    .login-card .logo {
        height: 56px;
    }
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.history-table th,
.history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.history-table th {
    color: var(--muted);
    font-weight: 600;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--brand);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.link-btn:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
}
