:root {
    --hf-primary: #0F2A47;       /* Marinho — cor primária da marca */
    --hf-primary-light: #1c426c; /* Marinho claro derivado */
    --hf-accent: #14B8A6;        /* Turquesa — secundária */
    --hf-accent-dark: #0d9488;   /* Turquesa escuro */
    --hf-success: #34D399;       /* Verde menta */
    --hf-bg: #F1F5F9;            /* Nuvem */
    --hf-surface: #ffffff;
    --hf-border: #d8e1ee;
    --hf-text: #0F2A47;          /* Marinho como texto principal */
    --hf-text-muted: #475569;    /* Ardósia */
    --hf-shadow: 0 1px 2px rgba(15, 42, 71, .04), 0 4px 14px rgba(15, 42, 71, .08);
    --hf-radius: 10px;
    --hf-sidebar-w: 256px;
    --hf-topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body { background: var(--hf-bg); }
body.hf-body { color: var(--hf-text); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }

.hf-shell { display: flex; min-height: 100vh; }

.hf-sidebar {
    width: var(--hf-sidebar-w);
    background: var(--hf-primary);
    color: #e6eefc;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform .25s ease;
}
.hf-sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.hf-sidebar-brand i { font-size: 1.6rem; color: #14B8A6; }
.hf-brand-title { font-weight: 700; letter-spacing: .2px; }
.hf-brand-sub { font-size: .75rem; color: rgba(255,255,255,.7); }
.hf-brand-logo { max-width: 180px; height: auto; display: block; }

.hf-nav { padding: .5rem 0; }
.hf-nav-section {
    padding: 1rem 1.25rem .25rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: rgba(255,255,255,.55);
}
.hf-nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1.25rem;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s ease, border-color .15s ease;
}
.hf-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.hf-nav-link.active { background: rgba(255,255,255,.08); border-left-color: #14B8A6; color: #fff; font-weight: 600; }
.hf-nav-link i { width: 18px; text-align: center; opacity: .9; }

.hf-nav-toggle { display: flex; align-items: center; cursor: pointer; }
.hf-nav-toggle .hf-nav-caret {
    width: auto;
    font-size: .75rem;
    margin-right: .25rem;
    opacity: .7;
    transition: transform .2s ease;
}
.hf-nav-toggle[aria-expanded="true"] .hf-nav-caret { transform: rotate(180deg); }

.hf-nav-sublink {
    display: flex; align-items: center; gap: .65rem;
    padding: .5rem 1.25rem .5rem 2.75rem;
    color: rgba(255, 255, 255, .72);
    text-decoration: none;
    font-size: .85rem;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.hf-nav-sublink:hover { background: rgba(255, 255, 255, .04); color: #fff; }
.hf-nav-sublink.active {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    font-weight: 600;
    border-left-color: #14B8A6;
}
.hf-nav-sublink i { width: 16px; text-align: center; opacity: .8; font-size: .85rem; }

.hf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.hf-topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--hf-topbar-h);
    background: var(--hf-surface);
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--hf-border);
    position: sticky; top: 0; z-index: 10;
}
.hf-topbar-left, .hf-topbar-right { display: flex; align-items: center; gap: .75rem; }
.hf-page-title { font-weight: 600; color: var(--hf-text); font-size: 1rem; }
.hf-sidebar-toggle { color: var(--hf-text); padding: .25rem .5rem; }

.hf-content { padding: 1.25rem; flex: 1; }
.hf-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--hf-border); background: var(--hf-surface); }

.hf-card {
    background: var(--hf-surface);
    border: 1px solid var(--hf-border);
    border-radius: var(--hf-radius);
    box-shadow: var(--hf-shadow);
    overflow: hidden;
}
.hf-card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--hf-border);
    background: linear-gradient(180deg, #fbfcfe 0%, #ffffff 100%);
}
.hf-card-header h6 { color: var(--hf-text); font-weight: 600; }
.hf-card-body { padding: 1.1rem; }

.hf-section-title {
    margin-top: .5rem;
    color: var(--hf-primary);
    font-weight: 600;
    border-bottom: 1px dashed var(--hf-border);
    padding-bottom: .35rem;
}

.hf-stat {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem;
    background: var(--hf-surface);
    border: 1px solid var(--hf-border);
    border-radius: var(--hf-radius);
    box-shadow: var(--hf-shadow);
    height: 100%;
}
.hf-stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.4rem;
}
.hf-stat-label { font-size: .8rem; color: var(--hf-text-muted); text-transform: uppercase; letter-spacing: .5px; }
.hf-stat-value { font-size: 1.6rem; font-weight: 700; color: var(--hf-text); line-height: 1; margin-top: .15rem; }
.hf-stat-foot  { margin-top: .35rem; }

a.hf-stat-link {
    color: inherit;
    text-decoration: none;
    transition: transform .12s, box-shadow .12s, border-color .12s;
}
a.hf-stat-link:hover {
    transform: translateY(-2px);
    border-color: var(--hf-accent);
    box-shadow: 0 6px 20px rgba(15,23,42,.10);
    color: inherit;
}
a.hf-stat-link.is-active {
    border-color: var(--hf-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}

.hf-shortcut {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
    padding: 1.5rem 1rem;
    background: var(--hf-surface);
    border: 1px solid var(--hf-border);
    border-radius: var(--hf-radius);
    color: var(--hf-text);
    text-decoration: none;
    transition: transform .12s ease, border-color .12s ease, color .12s ease;
    height: 100%;
}
.hf-shortcut i { font-size: 1.7rem; color: var(--hf-accent); }
.hf-shortcut span { font-weight: 600; font-size: .95rem; }
.hf-shortcut:hover { transform: translateY(-2px); border-color: var(--hf-accent); color: var(--hf-accent); }

.btn-xs { padding: .12rem .4rem; font-size: .78rem; line-height: 1.2; border-radius: .35rem; }
.btn + .btn-xs, .btn-xs + .btn-xs { margin-left: .15rem; }

.table > :not(caption) > * > * { padding: .55rem .75rem; vertical-align: middle; }

.hf-table-wrap { max-height: calc(100vh - 280px); overflow: auto; }
.hf-table-wrap table { margin-bottom: 0; }

.table thead th {
    background: linear-gradient(180deg, #0F2A47 0%, #1c426c 100%) !important;
    color: #f4f7fc !important;
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    text-align: center !important;
    border-bottom: 2px solid #14B8A6 !important;
    border-color: rgba(255, 255, 255, .08) !important;
    position: sticky;
    top: 0;
    z-index: 5;
    white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: 6px; }
.table thead th:last-child  { border-top-right-radius: 6px; }

.table-striped > tbody > tr:nth-of-type(odd) > * { background: #f8fafd; }
.table-hover > tbody > tr:hover > * { background: #eef4fc !important; }

.btn-xs { padding: .12rem .4rem; font-size: .78rem; line-height: 1.2; border-radius: .35rem; }
.btn + .btn-xs, .btn-xs + .btn-xs { margin-left: .15rem; }

.hf-actions { display: inline-flex; gap: .25rem; }
.hf-action {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--hf-border);
    border-radius: 8px;
    background: #fff;
    color: var(--hf-text);
    text-decoration: none;
    transition: transform .12s, background .12s, color .12s, border-color .12s, box-shadow .12s;
    cursor: pointer;
    padding: 0;
    font-size: .95rem;
}
.hf-action[data-tone="view"]    { color: #14B8A6; }
.hf-action[data-tone="edit"]    { color: #1d4ed8; }
.hf-action[data-tone="delete"]  { color: #dc2626; }
.hf-action[data-tone="success"] { color: #16a34a; }
.hf-action[data-tone="info"]    { color: #0891b2; }
.hf-action[data-tone="warning"] { color: #b45309; }

.hf-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(15,23,42,.08);
    border-color: transparent;
}
.hf-action[data-tone="view"]:hover    { background: var(--hf-accent); color: #fff; }
.hf-action[data-tone="edit"]:hover    { background: #14B8A6;          color: #fff; }
.hf-action[data-tone="delete"]:hover  { background: #dc2626;          color: #fff; }
.hf-action[data-tone="success"]:hover { background: #16a34a;          color: #fff; }
.hf-action[data-tone="info"]:hover    { background: #0891b2;          color: #fff; }
.hf-action[data-tone="warning"]:hover { background: #f59e0b;          color: #1f2937; }
.hf-action button, .hf-action[type="submit"] { background: transparent; border: 0; padding: 0; }
.hf-action.is-form { padding: 0; border: 0; background: transparent; box-shadow: none; }

.hf-job-widget {
    margin: .75rem 1rem;
    padding: .75rem;
    border-radius: 8px;
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .35);
    color: #fff5e0;
    font-size: .8rem;
}
.hf-job-widget[hidden] { display: none !important; }
.hf-job-title { display: flex; align-items: center; font-weight: 600; margin-bottom: .35rem; }
.hf-job-detail { color: rgba(255,255,255,.7); margin-top: .35rem; font-size: .72rem; }
.hf-job-widget .progress { background: rgba(0,0,0,.18); }

.hf-sync-pill {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .3rem .75rem;
    border-radius: 999px;
    background: #f1f4f9;
    color: var(--hf-text);
    font-size: .82rem;
    font-weight: 500;
    border: 1px solid var(--hf-border);
    transition: background .15s ease, border-color .15s ease;
}
.hf-sync-pill:hover { background: #e7ecf3; color: var(--hf-text); }

.hf-sync-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 0 rgba(0,0,0,0);
    flex-shrink: 0;
}

.hf-sync-pill[data-state="ok"]      .hf-sync-dot { background: #16a34a; }
.hf-sync-pill[data-state="running"] .hf-sync-dot { background: #14B8A6; animation: hfPulse 1.2s ease-in-out infinite; }
.hf-sync-pill[data-state="pending"] .hf-sync-dot { background: #f59e0b; animation: hfPulse 1.2s ease-in-out infinite; }
.hf-sync-pill[data-state="error"]   .hf-sync-dot { background: #dc2626; }
.hf-sync-pill[data-state="idle"]    .hf-sync-dot { background: #94a3b8; }

.hf-sync-pill[data-state="ok"]      { background: #ecfdf5; border-color: #bbf7d0; color: #065f46; }
.hf-sync-pill[data-state="running"] { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.hf-sync-pill[data-state="pending"] { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.hf-sync-pill[data-state="error"]   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

@keyframes hfPulse {
    0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
.hf-sync-pill[data-state="pending"] .hf-sync-dot {
    animation-name: hfPulseAmber;
}
@keyframes hfPulseAmber {
    0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.hf-sync-badge {
    background: rgba(0,0,0,.08);
    padding: .05rem .45rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}

.select2-container--bootstrap-5 .select2-selection {
    min-height: calc(2.375rem + 2px);
}
.select2-container--bootstrap-5 .select2-selection--single {
    padding: .375rem .75rem;
}

.hf-detalhes-hero {
    border-left: 4px solid var(--hf-accent);
    overflow: hidden;
}
.hf-detalhes-hero-body {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.5rem;
    align-items: flex-start;
    justify-content: space-between;
}
.hf-detalhes-headline {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex: 1 1 auto;
    min-width: 0;
}
.hf-detalhes-numero {
    border-right: 1px solid var(--hf-border);
    padding-right: 1.5rem;
    text-align: right;
    flex-shrink: 0;
}
.hf-detalhes-numero .display-6 {
    color: var(--hf-primary);
    line-height: 1;
}
.hf-detalhes-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .hf-detalhes-numero {
        border-right: 0;
        text-align: left;
        padding-right: 0;
        border-bottom: 1px solid var(--hf-border);
        padding-bottom: .75rem;
        width: 100%;
    }
    .hf-detalhes-headline { flex-direction: column; }
}

.hf-collapse-icon { transition: transform .15s ease; }
[aria-expanded="true"] .hf-collapse-icon { transform: rotate(90deg); }

.hf-pre {
    background: #0f172a; color: #e2e8f0;
    padding: .85rem 1rem; margin: 0;
    font-size: .78rem;
    max-height: 460px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Login */
.hf-login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #0F2A47 0%, #1c426c 50%, #14B8A6 100%);
    display: grid; place-items: center;
    padding: 2rem 1rem;
}
.hf-login-wrap { width: 100%; max-width: 420px; }
.hf-login-card { background: #fff; border-radius: 14px; padding: 2rem; box-shadow: 0 14px 40px rgba(15, 42, 71, .35); border-top: 4px solid var(--hf-accent); }
.hf-login-brand {
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eef2f7;
}
.hf-login-brand i { font-size: 2rem; color: #14B8A6; }
.hf-login-brand .hf-brand-title { font-size: 1.25rem; color: var(--hf-primary); }
.hf-login-brand .hf-brand-sub { color: var(--hf-text-muted); }
.hf-login-logo { max-width: 260px; height: auto; display: block; }

@media (max-width: 991.98px) {
    .hf-sidebar {
        position: fixed; left: 0; top: 0; z-index: 1040;
        transform: translateX(-100%);
        box-shadow: 0 0 30px rgba(0,0,0,.25);
    }
    .hf-sidebar.show { transform: translateX(0); }
    .hf-main { width: 100%; }
}
