﻿/* ============================================
   CRM Enterprise - Main Stylesheet
   Inspired by transface.com.br design system
   ============================================ */

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

:root {
    --primary: #C60003;
    --primary-dark: #A50002;
    --primary-darker: #8C0001;
    --primary-light: rgba(198, 0, 3, 0.06);
    --primary-glow: rgba(198, 0, 3, 0.15);
    --secondary: #64748b;
    --success: #C60003;
    --danger: #C60003;
    --warning: #F6C400;
    --info: #F6C400;
    --dark: #1a2332;
    --dark-soft: #243042;
    --light: #f5f7fa;
    --white: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #334155;
    --text-muted: #94a3b8;
    --sidebar-width: 278px;
    --sidebar-bg: #1a2332;
    --sidebar-hover: rgba(198, 0, 3, 0.08);
    --sidebar-active: rgba(198, 0, 3, 0.12);
    --header-height: 64px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 10px 10px -5px rgba(0,0,0,.03);
    --transition: all .2s cubic-bezier(.4,0,.2,1);
    --transition-slow: all .3s cubic-bezier(.4,0,.2,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--light);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.enterprise-shell {
    background:
    radial-gradient(circle at top left, rgba(198, 0, 3, 0.08), transparent 28%),
    radial-gradient(circle at bottom right, rgba(198, 0, 3, 0.05), transparent 24%),
    linear-gradient(180deg, #fbfcff 0%, #f3f5fa 100%);
}

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

/* ---- Layout ---- */
.app-layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #d61f24 0%, #c60003 42%, #970002 100%);
    color: rgba(255,255,255,.76);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: var(--transition-slow);
    display: flex;
    flex-direction: column;
    box-shadow: 18px 0 45px rgba(98, 13, 17, 0.18);
}
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(255,255,255,.18), transparent 34%),
        linear-gradient(180deg, rgba(255,255,255,.06), transparent 26%),
        radial-gradient(circle at bottom right, rgba(255,255,255,.08), transparent 32%);
    pointer-events: none;
}
.sidebar > * {
    position: relative;
    z-index: 1;
}
.sidebar-header {
    padding: 24px 22px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.14);
    flex-shrink: 0;
}
.brand-link {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    text-decoration: none;
}
.sidebar-header .logo {
    height: 36px;
    width: auto;
    flex-shrink: 0;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.12));
}
.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 2px;
}
.brand-copy strong {
    color: var(--white);
    font-family: 'Ubuntu', 'Inter', sans-serif;
    font-size: 1rem;
    letter-spacing: .2px;
}
.brand-eyebrow {
    color: rgba(255,255,255,.58);
    font-size: .68rem;
    letter-spacing: 1.9px;
    text-transform: uppercase;
    font-weight: 700;
}

.sidebar-nav {
    padding: 16px 14px;
    flex: 1;
    overflow-y: auto;
}
.sidebar-nav .nav-section {
    padding: 16px 12px 8px;
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: 2.2px;
    color: rgba(255,255,255,.46);
    font-weight: 700;
    margin-top: 4px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: rgba(255,255,255,.74);
    font-size: .9rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 12px;
    margin: 2px 0;
    position: relative;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,.1);
    color: #ffffff;
    transform: translateX(2px);
    border-left-color: rgba(255,255,255,.55);
}
.sidebar-nav a.active {
    background: #ffffff;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(90, 9, 13, 0.18);
}
.sidebar-nav a .icon {
    width: 22px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.sidebar-nav a.active .icon {
    color: var(--primary);
}

/* Sidebar footer / branding */
.sidebar-footer {
    padding: 18px 20px;
    border-top: 1px solid rgba(255,255,255,.14);
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
}
.sidebar-profile {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: var(--primary);
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(0,0,0,.16);
}
.sidebar-profile-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.sidebar-profile-copy strong {
    color: #ffffff;
    font-size: .86rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
.sidebar-profile-copy span {
    color: rgba(255,255,255,.72);
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-quick-action {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.08);
}
.sidebar-quick-action:hover {
    color: #ffffff;
    background: rgba(255,255,255,.14);
    text-decoration: none;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex; flex-direction: column;
    background: var(--light);
    /* Compensa o .top-header fixo (saiu do flow) — mantém o conteúdo
       começando abaixo da barra em qualquer tela. */
    padding-top: var(--header-height);
}

/* Header — FIXO em todas as telas: nunca sai da viewport ao rolar.
   No desktop começa após a sidebar (left: var(--sidebar-width));
   no mobile cobre toda a largura (responsive.css faz left:0). */
.top-header {
    min-height: var(--header-height);
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    position: fixed; top: 0; left: var(--sidebar-width); right: 0;
    z-index: 50;
    box-shadow: 0 12px 26px rgba(148, 163, 184, 0.08);
    backdrop-filter: blur(12px);
}
.top-header .left { display: flex; align-items: center; gap: 12px; }
.top-header .right { display: flex; align-items: center; gap: 8px; }
.header-context {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-right: 4px;
}
.header-kicker {
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    font-weight: 700;
    color: var(--text-muted);
}
.header-title {
    font-size: 1rem;
    color: var(--dark);
    font-family: 'Ubuntu', 'Inter', sans-serif;
    letter-spacing: -.2px;
}
.header-btn {
    background: none; border: none; cursor: pointer;
    color: var(--secondary); font-size: 1.1rem;
    padding: 10px 12px; border-radius: 12px;
    transition: var(--transition);
    display: inline-flex; align-items: center; gap: 4px;
}
.header-btn:hover { background: rgba(198, 0, 3, 0.08); color: var(--primary); }

.locale-toggle {
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: rgba(255, 255, 255, 0.96);
    color: var(--dark);
    gap: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    text-decoration: none;
    white-space: nowrap;
}
.locale-toggle:hover {
    text-decoration: none;
    background: rgba(198, 0, 3, 0.08);
    color: var(--primary);
}
.locale-toggle svg {
    flex-shrink: 0;
}
.header-btn.locale-toggle {
    padding: 8px 10px 8px 8px;
}
.locale-toggle-current {
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    box-shadow: 0 8px 16px rgba(198, 0, 3, 0.18);
}
.locale-toggle-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--dark);
}
.locale-toggle-next {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.login-locale-row {
    margin-top: 18px;
    display: flex;
    justify-content: center;
}
.locale-toggle-standalone {
    min-height: 44px;
    padding: 10px 14px;
    gap: 10px;
}

.context-selector {
    display: flex; gap: 8px; align-items: center;
    margin-left: 8px;
}
.context-selector select {
    padding: 8px 12px; border: 1px solid rgba(203, 213, 225, 0.9); border-radius: 12px;
    font-size: .85rem; background: rgba(255,255,255,.92);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.user-menu {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; position: relative;
    padding: 4px 8px;
    border-radius: 14px;
    transition: var(--transition);
}
.user-menu:hover { background: rgba(198, 0, 3, 0.06); }
.user-menu .avatar {
    width: 36px; height: 36px; border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .82rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}
.user-menu .avatar.has-photo { background: #e5e7eb; }
.user-menu .avatar img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.user-menu .meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.user-menu .name { font-size: .88rem; color: var(--text); font-weight: 600; }
.user-menu .role {
    font-size: .68rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 700;
}

/* Page content */
.page-content { padding: 28px; flex: 1; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--dark); letter-spacing: -0.3px; font-family: 'Ubuntu', 'Inter', sans-serif; }
.breadcrumb {
    display: flex; gap: 8px; font-size: .85rem; color: var(--text-muted);
    margin-bottom: 16px;
}
.breadcrumb a { color: var(--primary); }

/* Cards */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 1rem;
    display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }
.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

/* Grid */
.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.col { padding: 0 10px; flex: 1; min-width: 0; }
.col-2 { width: 16.66%; padding: 0 10px; }
.col-3 { width: 25%; padding: 0 10px; }
.col-4 { width: 33.33%; padding: 0 10px; }
.col-6 { width: 50%; padding: 0 10px; }
.col-8 { width: 66.66%; padding: 0 10px; }
.col-12 { width: 100%; padding: 0 10px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.kpi-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    opacity: 0;
    transition: var(--transition);
}
.kpi-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.kpi-card:hover::before { opacity: 1; }
.kpi-card .kpi-icon { font-size: 2rem; margin-bottom: 8px; }
.kpi-card .kpi-value { font-size: 1.8rem; font-weight: 700; color: var(--dark); }
.kpi-card .kpi-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.kpi-card .kpi-change { font-size: .8rem; margin-top: 6px; }
.kpi-card .kpi-change.up { color: var(--success); }
.kpi-card .kpi-change.down { color: var(--danger); }
.kpi-card.kpi-blue::before,
.kpi-card.kpi-green::before,
.kpi-card.kpi-orange::before,
.kpi-card.kpi-purple::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}
.kpi-card.kpi-blue::before { background: linear-gradient(90deg, #c60003, #e8333a); }
.kpi-card.kpi-green::before { background: linear-gradient(90deg, #8c0001, #c60003); }
.kpi-card.kpi-orange::before { background: linear-gradient(90deg, #f6c400, #ffd940); }
.kpi-card.kpi-purple::before { background: linear-gradient(90deg, #243042, #c60003); }
.kpi-card .kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.kpi-card.kpi-blue .kpi-icon,
.kpi-card.kpi-green .kpi-icon,
.kpi-card.kpi-purple .kpi-icon { background: rgba(198, 0, 3, 0.08); }
.kpi-card.kpi-orange .kpi-icon { background: rgba(246, 196, 0, 0.14); }
.kpi-card .kpi-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi-card .kpi-sub {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}
table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
}
table tr:hover td { background: #f1f5f9; }
table .actions { white-space: nowrap; display: flex; gap: 6px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px;
    border: none; border-radius: var(--radius);
    font-size: .88rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    box-shadow: 0 2px 4px rgba(198, 0, 3, 0.2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker));
    text-decoration: none; color: var(--white);
    box-shadow: 0 4px 8px rgba(198, 0, 3, 0.3);
    transform: translateY(-1px);
}
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-outline {
    background: transparent; border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--light); border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 6px 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 16px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; margin-bottom: 4px;
    font-weight: 500; font-size: .9rem; color: var(--dark);
}
.form-control {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: .9rem; transition: var(--transition);
    background: var(--white);
}
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
select.form-control { appearance: auto; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-error { color: var(--danger); font-size: .8rem; margin-top: 4px; }
.form-required::after { content: ' *'; color: var(--danger); }
.lookup-onboarding {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid #a5f3fc;
    background: linear-gradient(180deg, rgba(236, 254, 255, 0.96), rgba(224, 242, 254, 0.92));
    color: #155e75;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.lookup-onboarding svg {
    flex-shrink: 0;
    margin-top: 2px;
}
.lookup-onboarding strong {
    display: block;
    margin-bottom: 2px;
}
.lookup-onboarding span {
    display: block;
}
body.lookup-page-blocked {
    overflow: hidden;
}
.lookup-page-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1200;
}
.lookup-page-overlay.is-visible {
    display: flex;
}
.lookup-page-overlay__card {
    width: min(92vw, 360px);
    padding: 26px 24px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.18);
    text-align: center;
}
.lookup-page-overlay__gear {
    width: 74px;
    height: 74px;
    margin: 0 auto 14px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: linear-gradient(180deg, rgba(198, 0, 3, 0.08), rgba(198, 0, 3, 0.14));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.lookup-page-overlay__gear svg {
    animation: lookup-gear-spin 1.2s linear infinite;
}
.lookup-page-overlay__title {
    display: block;
    font-size: 1rem;
    color: var(--dark);
    margin-bottom: 6px;
}
.lookup-page-overlay__message {
    display: block;
    font-size: .88rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.lookup-field-group {
    position: relative;
}
.lookup-control {
    position: relative;
}
.lookup-field-group .form-control {
    padding-right: 42px;
}
.lookup-indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
}
.lookup-indicator::before {
    content: '';
    line-height: 1;
}
.lookup-indicator.is-visible {
    display: flex;
}
.lookup-indicator.is-loading {
    background: transparent;
    border: 2px solid rgba(198, 0, 3, 0.18);
    border-top-color: var(--primary);
    box-shadow: none;
    animation: lookup-spin .75s linear infinite;
}
.lookup-indicator.is-success {
    background: #16a34a;
    border: 1px solid #15803d;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}
.lookup-indicator.is-success::before {
    content: '\2713';
}
.lookup-indicator.is-error {
    background: #dc2626;
    border: 1px solid #b91c1c;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}
.lookup-indicator.is-error::before {
    content: '!';
}
.lookup-feedback {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lookup-helper,
.lookup-status {
    font-size: .78rem;
    line-height: 1.4;
    display: none;
}
.lookup-helper {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}
.lookup-helper.is-disabled {
    color: #b45309;
}
.lookup-helper::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    flex-shrink: 0;
}
.lookup-status.is-visible {
    display: flex;
    align-items: center;
    gap: 6px;
}
.lookup-status.is-loading { color: var(--primary); }
.lookup-status.is-success { color: #15803d; }
.lookup-status.is-error { color: #b91c1c; }
.form-control.lookup-loading {
    border-color: rgba(198, 0, 3, 0.55);
    box-shadow: 0 0 0 3px rgba(198, 0, 3, 0.12);
}
.form-control.lookup-success {
    border-color: rgba(22, 163, 74, 0.55);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}
.form-control.lookup-error {
    border-color: rgba(220, 38, 38, 0.45);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.10);
}
@keyframes lookup-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes lookup-gear-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Badges/Tags */
.badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 12px; font-size: .75rem;
    font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #cffafe; color: var(--info); }
.badge-secondary { background: #f1f5f9; color: var(--secondary); }

/* Pagination */
.pagination { display: flex; gap: 4px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span {
    padding: 6px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: .85rem;
    color: var(--text);
}
.pagination a:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .active { background: var(--primary); color: var(--white); border-color: var(--primary); box-shadow: 0 2px 4px rgba(198, 0, 3, 0.25); }

/* Alerts / Flash */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .9rem;
    display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error, .alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #cffafe; color: #155e75; border: 1px solid #a5f3fc; }

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 200;
    align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 600px; max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 1.1rem;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
}
.modal-close {
    background: none; border: none; font-size: 1.3rem;
    cursor: pointer; color: var(--text-muted);
}
.form-frame-overlay {
    z-index: 1300;
}
.form-frame-modal {
    width: min(96vw, 1320px);
    height: min(90vh, 960px);
    max-width: none;
    max-height: none;
    overflow: hidden;
    border-radius: 24px;
}
.form-frame-modal__header {
    align-items: flex-start;
    gap: 16px;
}
.form-frame-modal__eyebrow {
    display: inline-flex;
    align-items: center;
    margin-bottom: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--primary);
    background: rgba(198, 0, 3, 0.08);
}
.form-frame-modal__hint {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: .84rem;
    line-height: 1.45;
}
.form-frame-modal__body {
    padding: 0;
    height: calc(100% - 94px);
    background: #f8fafc;
}
.form-frame-modal__iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #fff;
}
.enterprise-frame-mode {
    min-height: 100vh;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}
.enterprise-frame-page {
    min-height: 100vh;
}
.enterprise-frame-content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px;
}

@media (max-width: 768px) {
    .form-frame-modal {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .form-frame-modal__body {
        height: calc(100% - 96px);
    }
    .enterprise-frame-content {
        padding: 16px;
    }
}

/* Kanban */
.kanban-board {
    display: flex; gap: 16px; overflow-x: auto;
    padding-bottom: 16px; min-height: 500px;
}
.kanban-column {
    min-width: 280px; max-width: 320px;
    background: #f1f5f9; border-radius: var(--radius);
    flex-shrink: 0;
}
.kanban-column-header {
    padding: 12px 16px; font-weight: 600;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex; align-items: center; justify-content: space-between;
    font-size: .9rem;
}
.kanban-column-header .count {
    background: rgba(0,0,0,.1); padding: 2px 8px;
    border-radius: 10px; font-size: .75rem;
}
.kanban-cards { padding: 8px; min-height: 100px; }
.kanban-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px;
    margin-bottom: 8px; cursor: grab; transition: var(--transition);
    box-shadow: var(--shadow);
}
.kanban-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); }
.kanban-card .card-title { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.kanban-card .card-meta { font-size: .8rem; color: var(--text-muted); }
.kanban-card .card-value { font-weight: 700; color: var(--success); margin-top: 6px; }

/* Progress bar */
.progress {
    height: 8px; background: #e2e8f0; border-radius: 4px;
    overflow: hidden;
}
.progress-bar {
    height: 100%; border-radius: 4px;
    transition: width .5s ease;
}
.progress-bar-success { background: var(--success); }
.progress-bar-primary { background: var(--primary); }
.progress-bar-warning { background: var(--warning); }
.progress-bar-danger { background: var(--danger); }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
    padding: 10px 20px; border: none; background: none;
    font-size: .9rem; cursor: pointer; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: var(--transition);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none!important; }
.w-100 { width: 100%; }
.cursor-pointer { cursor: pointer; }

/* Responsive */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sidebar-toggle { display: none; }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(15, 23, 42, .45); z-index: 99;
}
.sidebar-backdrop.visible { display: block; }
@media (max-width: 1024px) {
    .enterprise-frame-content { padding: 20px; }
    .kanban-column { min-width: 260px; }
}
@media (max-width: 768px) {
    .sidebar {
        width: min(88vw, 320px);
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    /* Header fixo: no mobile cobre toda a largura (sidebar é overlay) */
    .top-header { left: 0; padding: 0 10px; }   /* encosta os ícones no canto */
    .sidebar-toggle { display: block; }
    .header-context { display: none; }
    .context-selector { display: none; }
    .user-menu .meta { display: none; }
    .user-menu { padding: 4px; }                 /* avatar IF colado no canto */
    .user-menu .avatar { width: 34px; height: 34px; }
    .top-header .locale-toggle-label,
    .top-header .locale-toggle-next { display: none; }
    .header-btn.locale-toggle { padding: 8px; }
    .sidebar-nav { padding-bottom: 28px; }
    .sidebar-footer { padding: 16px; }
    .row { flex-direction: column; }
    .col-3, .col-4, .col-6, .col-8 { width: 100%; }
    .kanban-board { flex-direction: column; }
    .kanban-column { min-width: 100%; max-width: 100%; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    /* Tabelas roláveis horizontalmente em telas pequenas */
    .card .table, table.table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table th, .table td { white-space: nowrap; }
    .page-header { flex-wrap: wrap; gap: 12px; }
    .page-actions { flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .page-header h2 { font-size: 1.15rem; }
    .modal-content { width: 100vw; max-width: 100vw; border-radius: 0; }
    .btn { padding: 10px 14px; }
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a2332 0%, #243042 40%, var(--primary-darker) 100%);
    position: relative;
}
.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(198, 0, 3, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(198, 0, 3, 0.1) 0%, transparent 50%);
}
.login-card {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl); padding: 40px;
    width: 100%; max-width: 420px;
    position: relative; z-index: 1;
}
.login-card .login-logo {
    display: block;
    margin: 0 auto 20px;
    height: 42px;
    width: auto;
}
.login-card h1 { text-align: center; margin-bottom: 8px; color: var(--dark); font-size: 1.5rem; letter-spacing: -0.3px; }
.login-card p { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: .9rem; }
.login-card .form-control { padding: 12px 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }

/* Chart containers */
.chart-container { position: relative; height: 300px; width: 100%; }
.chart-container canvas { width: 100%!important; height: 100%!important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

