:root {
    --tiflow-primary: #31AFC2;
    --tiflow-primary-dark: #208b9c;
    --tiflow-ink: #1f2937;
    --tiflow-muted: #6b7280;
    --tiflow-bg: #f5f7fa;
    --tiflow-border: #e5e7eb;
    --tiflow-sidebar: #17212b;
}

html {
    font-size: 14px;
}

body {
    color: var(--tiflow-ink);
    background: var(--tiflow-bg);
}

.text-primary-tiflow {
    color: var(--tiflow-primary) !important;
}

.btn-tiflow {
    background: linear-gradient(135deg, var(--tiflow-primary), var(--tiflow-primary-dark));
    color: #fff;
    border: 0;
    box-shadow: 0 8px 18px rgba(49, 175, 194, .22);
}

.btn-tiflow:hover,
.btn-tiflow:focus {
    color: #fff;
    filter: brightness(.96);
}

.eyebrow {
    display: inline-block;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
}

.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: -.04em;
    background: linear-gradient(135deg, #fff, #d9f5f9);
    color: var(--tiflow-primary-dark);
    box-shadow: 0 14px 30px rgba(0, 0, 0, .12);
}

.brand-mark-small {
    width: 42px;
    height: 42px;
    border-radius: 13px;
}

.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 10%, rgba(49, 175, 194, .14), transparent 30%),
        #f6f8fb;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(360px, 42%) 1fr;
}

.auth-brand-panel {
    padding: clamp(3rem, 7vw, 7rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #fff;
    background:
        linear-gradient(145deg, rgba(23, 33, 43, .96), rgba(21, 80, 91, .95)),
        linear-gradient(135deg, var(--tiflow-primary), var(--tiflow-sidebar));
}

.auth-brand-panel h1 {
    font-size: clamp(2.4rem, 5vw, 4.6rem);
    line-height: .98;
    margin: 1.25rem 0 1.5rem;
    letter-spacing: -.05em;
}

.auth-brand-panel p {
    max-width: 520px;
    color: rgba(255, 255, 255, .78);
    font-size: 1.05rem;
    line-height: 1.7;
}

.auth-brand-footer {
    margin-top: 3rem;
    font-size: .8rem;
    color: rgba(255, 255, 255, .6);
}

.security-note {
    margin-top: 2rem;
    max-width: 520px;
    padding: 1rem 1.15rem;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 14px;
    background: rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .72);
}

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.auth-card {
    width: min(100%, 460px);
    padding: 2.4rem;
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(229, 231, 235, .8);
    box-shadow: 0 24px 70px rgba(31, 41, 55, .08);
}

.auth-card-wide {
    width: min(100%, 680px);
}

.auth-card h2 {
    font-weight: 750;
    letter-spacing: -.03em;
}

.form-control,
.form-select {
    border-radius: 10px;
    border-color: #dce1e7;
    min-height: 44px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tiflow-primary);
    box-shadow: 0 0 0 .2rem rgba(49, 175, 194, .14);
}

.password-rules {
    padding: .85rem 1rem;
    border-radius: 10px;
    background: #f4fafb;
    color: #547078;
    font-size: .85rem;
}

.admin-body {
    min-height: 100vh;
    overflow-x: hidden;
}

.admin-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    padding: 1.4rem 1.2rem;
    background: var(--tiflow-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .35rem .4rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand small {
    color: rgba(255, 255, 255, .55);
}

.sidebar-nav {
    padding-top: 1.35rem;
}

.sidebar-section {
    display: block;
    padding: 0 .7rem .5rem;
    color: rgba(255, 255, 255, .38);
    font-size: .66rem;
    letter-spacing: .12em;
    font-weight: 800;
}

.sidebar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: .16rem 0;
    padding: .72rem .8rem;
    border-radius: 9px;
    color: rgba(255, 255, 255, .72);
    text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: #fff;
    background: rgba(49, 175, 194, .17);
}

.sidebar-link.active {
    box-shadow: inset 3px 0 0 var(--tiflow-primary);
}

.sidebar-link.disabled {
    opacity: .55;
    cursor: default;
}

.sidebar-link small {
    color: rgba(255, 255, 255, .35);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem .6rem .3rem;
}

.sidebar-footer span,
.sidebar-footer small {
    display: block;
}

.sidebar-footer small {
    color: rgba(255, 255, 255, .38);
}

.admin-content {
    grid-column: 2;
    min-width: 0;
}

.admin-topbar {
    height: 72px;
    padding: 0 2rem;
    background: #fff;
    border-bottom: 1px solid var(--tiflow-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-context {
    color: var(--tiflow-muted);
    font-size: .85rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-copy {
    text-align: right;
}

.user-copy strong,
.user-copy small {
    display: block;
}

.user-copy small {
    color: var(--tiflow-muted);
    font-size: .72rem;
}

.admin-main {
    padding: 2rem;
}

.page-header-tiflow {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.6rem;
}

.page-header-tiflow h1 {
    margin: .35rem 0;
    font-weight: 750;
    letter-spacing: -.035em;
}

.page-header-tiflow p {
    margin: 0;
    color: var(--tiflow-muted);
}

.metric-card,
.content-card {
    background: #fff;
    border: 1px solid var(--tiflow-border);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(31, 41, 55, .04);
}

.metric-card {
    min-height: 142px;
    padding: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-label {
    display: block;
    color: var(--tiflow-muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.metric-value {
    margin: .45rem 0 .25rem;
    font-size: 1.8rem;
    font-weight: 780;
    letter-spacing: -.04em;
}

.metric-value-small {
    font-size: 1.25rem;
}

.metric-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(49, 175, 194, .1);
    color: var(--tiflow-primary-dark);
    font-weight: 800;
}

.status-dot {
    width: 15px;
    height: 15px;
    border-radius: 999px;
    box-shadow: 0 0 0 7px rgba(107, 114, 128, .08);
}

.status-online {
    background: #22c55e;
    box-shadow: 0 0 0 7px rgba(34, 197, 94, .1);
}

.status-offline {
    background: #ef4444;
    box-shadow: 0 0 0 7px rgba(239, 68, 68, .1);
}

.content-card {
    padding: 1.5rem;
}

.content-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.content-card-header h5 {
    margin-bottom: .35rem;
    font-weight: 750;
}

.content-card-header p {
    color: var(--tiflow-muted);
}

.badge-tiflow {
    color: var(--tiflow-primary-dark);
    background: rgba(49, 175, 194, .12);
    border: 1px solid rgba(49, 175, 194, .16);
}

.module-preview {
    height: 100%;
    padding: 1rem;
    border: 1px dashed #d7dde3;
    border-radius: 12px;
    background: #fafbfc;
}

.module-preview span,
.module-preview small {
    display: block;
}

.module-preview span {
    font-weight: 700;
}

.module-preview small {
    margin-top: .25rem;
    color: var(--tiflow-muted);
}

@media (max-width: 991.98px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-brand-panel {
        min-height: 330px;
    }

    .admin-shell {
        display: block;
    }

    .admin-sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .admin-content {
        grid-column: auto;
    }

    .sidebar-footer {
        display: none;
    }

    .page-header-tiflow {
        align-items: start;
        flex-direction: column;
    }
}

/* Fase 3.2 - Dashboard real */
.dashboard-sync {
    color: var(--tiflow-muted);
    font-size: .78rem;
    text-align: right;
}

.dashboard-alert {
    border-radius: 12px;
    border: 0;
    box-shadow: 0 8px 20px rgba(239, 68, 68, .08);
}

.metric-card-compact {
    min-height: 105px;
}

.table-tiflow thead th {
    border-bottom: 1px solid var(--tiflow-border);
    color: var(--tiflow-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 800;
    white-space: nowrap;
}

.table-tiflow tbody td {
    padding-top: .95rem;
    padding-bottom: .95rem;
    border-color: #eef1f4;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: .32rem .58rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
}

.status-badge-success {
    color: #15803d;
    background: rgba(34, 197, 94, .11);
}

.status-badge-warning {
    color: #a16207;
    background: rgba(234, 179, 8, .14);
}

.status-badge-danger {
    color: #b91c1c;
    background: rgba(239, 68, 68, .11);
}

.status-badge-info {
    color: #0369a1;
    background: rgba(14, 165, 233, .11);
}

.status-badge-muted {
    color: #64748b;
    background: rgba(100, 116, 139, .11);
}

.audit-timeline {
    display: grid;
    gap: .1rem;
}

.audit-item {
    position: relative;
    display: grid;
    grid-template-columns: 20px 1fr;
    gap: .8rem;
    padding: .75rem 0;
}

.audit-item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 28px;
    bottom: -8px;
    width: 1px;
    background: var(--tiflow-border);
}

.audit-dot {
    width: 13px;
    height: 13px;
    margin-top: .2rem;
    border-radius: 999px;
    z-index: 1;
}

.audit-success {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .09);
}

.audit-error {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .09);
}

.audit-copy p {
    margin: .28rem 0 .18rem;
    color: var(--tiflow-muted);
}

.audit-copy small {
    color: #94a3b8;
}

.dashboard-note {
    padding: 1rem 1.1rem;
    border-radius: 12px;
    border: 1px solid rgba(49, 175, 194, .18);
    background: rgba(49, 175, 194, .06);
    color: #547078;
    font-size: .84rem;
}

/* Fase 3.2 - Estado seguro quando a Licensing API estiver indisponível */
.metric-card-unavailable {
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

.metric-value-unavailable {
    color: #94a3b8;
    letter-spacing: 0;
}

.badge-api-offline {
    color: #b91c1c;
    background: rgba(239, 68, 68, .10);
    border: 1px solid rgba(239, 68, 68, .16);
}

.dashboard-unavailable-copy {
    color: #94a3b8;
    font-weight: 600;
}

/* Fase 3.3.1 - Listagem de licenças */
.license-filter-card {
    position: relative;
    overflow: visible;
}

.license-filter-card .form-label {
    color: var(--tiflow-muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.license-company {
    min-width: 210px;
}

.license-company strong,
.license-company small {
    display: block;
}

.license-company small {
    margin-top: .2rem;
    color: var(--tiflow-muted);
    font-family: var(--bs-font-monospace);
    font-size: .72rem;
}

.tenant-pill,
.plan-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: .24rem .55rem;
    border-radius: 8px;
    font-size: .74rem;
    font-weight: 750;
}

.tenant-pill {
    color: #475569;
    background: #f1f5f9;
}

.plan-badge {
    color: var(--tiflow-primary-dark);
    background: rgba(49, 175, 194, .10);
}

div.dataTables_wrapper div.dataTables_length label,
div.dataTables_wrapper div.dataTables_filter label,
div.dataTables_wrapper div.dataTables_info {
    color: var(--tiflow-muted);
    font-size: .82rem;
}

div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
    border: 1px solid #dce1e7;
    border-radius: 9px;
    background: #fff;
}

div.dataTables_wrapper div.dataTables_filter input:focus,
div.dataTables_wrapper div.dataTables_length select:focus {
    border-color: var(--tiflow-primary);
    box-shadow: 0 0 0 .2rem rgba(49, 175, 194, .12);
    outline: 0;
}

div.dataTables_wrapper div.dataTables_paginate ul.pagination {
    margin-top: .5rem;
}

div.dataTables_wrapper .page-link {
    color: #475569;
    border-color: #e5e7eb;
}

div.dataTables_wrapper .page-item.active .page-link {
    color: #fff;
    background: var(--tiflow-primary);
    border-color: var(--tiflow-primary);
}

div.dataTables_wrapper .page-link:focus {
    box-shadow: 0 0 0 .2rem rgba(49, 175, 194, .12);
}

#licensesTable_processing {
    border: 1px solid rgba(49, 175, 194, .18);
    border-radius: 10px;
    background: rgba(255, 255, 255, .96);
    color: var(--tiflow-primary-dark);
    box-shadow: 0 10px 30px rgba(31, 41, 55, .08);
}

@media (max-width: 767.98px) {
    .content-card {
        padding: 1.1rem;
    }

    .license-filter-card .btn {
        min-height: 42px;
    }
}

/* Fase 3.3.2 - Detalhe da licença */
.license-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.license-detail-field {
    min-width: 0;
    padding: 1rem;
    border: 1px solid #e9eef2;
    border-radius: 12px;
    background: #fbfcfd;
}

.license-detail-field > span {
    display: block;
    margin-bottom: .35rem;
    color: #7a8793;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.license-detail-field > strong {
    display: block;
    color: #27323a;
    font-size: .98rem;
    overflow-wrap: anywhere;
}

.license-detail-field > small {
    display: block;
    margin-top: .25rem;
    color: #8a96a0;
}

.license-id-text,
.license-guid-small {
    font-size: .78rem !important;
    overflow-wrap: anywhere;
}

.license-features-json {
    min-height: 150px;
    max-height: 320px;
    margin: 0;
    padding: 1rem;
    overflow: auto;
    border: 1px solid #e9eef2;
    border-radius: 12px;
    background: #f7f9fa;
    color: #42505a;
    font-size: .78rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.license-details-unavailable {
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-tiflow {
    max-width: 520px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
}

.empty-state-tiflow p {
    margin-bottom: 0;
    color: #7a8793;
}

.empty-state-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(220, 53, 69, .10);
    color: #c93847;
    font-size: 1.4rem;
    font-weight: 800;
}

.license-audit-list {
    display: flex;
    flex-direction: column;
}

.license-audit-row {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: .75rem;
    padding: 1rem 0;
    border-bottom: 1px solid #eef1f3;
}

.license-audit-row:last-child {
    border-bottom: 0;
}

.license-audit-status {
    padding-top: .35rem;
    display: flex;
    justify-content: center;
}

.license-audit-body p {
    margin: .45rem 0;
    color: #5f6b74;
}

.license-audit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    color: #8a96a0;
    font-size: .78rem;
}

@media (max-width: 1199.98px) {
    .license-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .license-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Fase 3 final - operação do Licensing Admin */
.tabs-primary {
    border-bottom: 1px solid #e6edf1;
}

.tabs-primary .nav-link {
    border: 0;
    border-bottom: 3px solid transparent;
    color: #697780;
    font-weight: 700;
}

.tabs-primary .nav-link:hover {
    color: #31AFC2;
}

.tabs-primary .nav-link.active {
    border-bottom-color: #31AFC2;
    color: #31AFC2;
    background: transparent;
}

.sidebar-link {
    text-decoration: none;
}

.sidebar-link:hover {
    text-decoration: none;
}

.content-card code,
.table-tiflow code {
    color: #52606a;
}

.swal2-popup .form-label {
    font-size: .82rem;
    font-weight: 700;
    color: #4f5c65;
}
