:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #0ea5e9;
    --background-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --text-color: #0f172a;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --hover-bg: #f1f5f9;
    --active-bg: #f1f5f9;
    --active-text: #0f172a;
    --input-bg: #ffffff;
    --input-border: #e2e8f0;
    --input-focus-border: #6366f1;
    --input-focus-ring: rgba(99, 102, 241, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-light);
    font-size: 0.875rem;
}

.auth-form {
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon i {
    position: absolute;
    left: 14px;
    color: var(--text-light);
    font-size: 0.875rem;
    pointer-events: none;
}

.input-icon input {
    padding: 10px 14px 10px 40px;
    width: 100%;
}

.password-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.forgot-password {
    font-size: 0.75rem;
    color: var(--primary-color);
    text-decoration: none;
}

.forgot-password:hover {
    text-decoration: underline;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-light);
    user-select: none;
}

.checkbox-container input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.auth-footer {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    gap: 24px;
    padding: 16px;
}

/* Sidebar */
#sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--text-color);
    transition: all 0.3s;
    border-radius: 16px;
    padding: 28px 12px;
    height: calc(100vh - 32px);
    position: sticky;
    top: 16px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 0 12px 24px;
    margin-bottom: 24px;
    position: relative;
}

.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
    opacity: 0.5;
}

.sidebar-header h3 {
    color: var(--text-color);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: -0.3px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.2s;
}

.user-info:hover {
    background: var(--hover-bg);
}

.profile-img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
}

.user-name {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--text-color);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-light);
}

.list-unstyled {
    padding: 0;
    list-style: none;
    flex: 1;
}

.list-unstyled li {
    margin-bottom: 2px;
}

.list-unstyled li a {
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 8px;
    font-size: 0.825rem;
    font-weight: 500;
}

.list-unstyled li a:hover {
    background: var(--hover-bg);
    color: var(--text-color);
}

.list-unstyled li.active a {
    background: var(--active-bg);
    color: var(--active-text);
}

.list-unstyled li a i {
    width: 16px;
    text-align: center;
    font-size: 0.95rem;
    opacity: 0.75;
}

.list-unstyled li.active a i {
    opacity: 0.9;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.sidebar-logout {
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--danger-color);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 8px;
    font-size: 0.825rem;
    font-weight: 600;
}

.sidebar-logout:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.sidebar-logout i {
    width: 16px;
    text-align: center;
    font-size: 0.95rem;
}

/* Conteúdo Principal */
#content {
    flex: 1;
    transition: all 0.3s;
    max-width: calc(100% - 274px);
}

/* Navbar */
.navbar {
    background: var(--sidebar-bg);
    padding: 16px 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--card-shadow);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notifications {
    position: relative;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.notifications:hover {
    background: var(--hover-bg);
}

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Form Elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 0.875rem;
    line-height: 1.5;
    transition: all 0.2s;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 4px var(--input-focus-ring);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Labels */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
}

/* Botões */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    text-decoration: none;
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--hover-bg);
}

/* Cards e Componentes */
.card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

/* Estatísticas Cards */
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--card-shadow);
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h4 {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.stat-info .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
}

.stat-helper {
    margin-top: 8px;
    color: var(--text-light);
    font-size: 0.82rem;
    line-height: 1.35;
}

.stat-helper.success {
    color: #047857;
}

.stat-helper.warning {
    color: #b45309;
}

.stat-info .change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #dcfce7;
    color: #15803d;
}

.change.negative {
    background: #fee2e2;
    color: #b91c1c;
}

/* Tabelas */
.table-responsive {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.875rem;
}

td {
    font-size: 0.925rem;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-approved {
    background: #dcfce7;
    color: #15803d;
}

.status-pending {
    background: #fef3c7;
    color: #b45309;
}

.status-inactive {
    background: #fee2e2;
    color: #b91c1c;
}

.section-kicker {
    display: inline-flex;
    align-items: center;
    margin-bottom: 8px;
    color: #0f766e;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.affiliate-manager-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.affiliate-manager-card.compact {
    padding: 22px 24px;
}

.affiliate-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 20px;
}

.affiliate-manager-header h2 {
    font-size: 1.25rem;
    line-height: 1.25;
    margin-bottom: 8px;
}

.affiliate-manager-header p {
    color: var(--text-light);
    max-width: 820px;
    font-size: 0.925rem;
}

.affiliate-manager-total {
    min-width: 210px;
    padding: 16px;
    border: 1px solid #ccfbf1;
    border-radius: 12px;
    background: #f0fdfa;
}

.affiliate-manager-total span,
.level-card-metrics span,
.table-muted {
    color: var(--text-light);
    font-size: 0.8rem;
}

.affiliate-manager-total strong {
    display: block;
    margin-top: 6px;
    color: #0f172a;
    font-size: 1.35rem;
}

.affiliate-manager-total small {
    display: block;
    margin-top: 4px;
    color: var(--text-light);
    font-size: 0.78rem;
}

.manager-flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.manager-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #f8fafc;
}

.manager-step p {
    margin-top: 4px;
    color: var(--text-light);
    font-size: 0.85rem;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0f172a;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    font-size: 0.85rem;
    font-weight: 700;
}

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

.affiliate-level-grid.referrals-levels {
    margin-bottom: 24px;
}

.affiliate-level-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    background: #ffffff;
}

.level-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.level-card-top h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.level-card-top p {
    color: var(--text-light);
    font-size: 0.82rem;
}

.level-chip,
.level-table-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

.level-chip {
    min-width: 64px;
    padding: 6px 10px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.8rem;
}

.level-table-chip {
    min-width: 34px;
    padding: 4px 8px;
    background: #ecfeff;
    color: #0e7490;
    font-size: 0.78rem;
}

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

.level-card-metrics div {
    min-width: 0;
}

.level-card-metrics strong {
    display: block;
    margin-top: 2px;
    color: var(--text-color);
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.commissions-header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
}

.commissions-header .card-title {
    margin: 0;
}

.commission-filters {
    width: 100%;
    display: grid;
    grid-template-columns:
        minmax(120px, 0.9fr)
        minmax(140px, 1fr)
        minmax(145px, 0.9fr)
        minmax(145px, 0.9fr)
        minmax(220px, 1.4fr)
        minmax(105px, 0.7fr)
        auto;
    gap: 8px;
    align-items: center;
}

.commission-filters .btn,
.commission-filters select.btn,
.commission-filters input.btn {
    width: 100%;
    min-width: 0;
    height: 36px;
    line-height: 36px;
    padding: 0 12px;
}

.commission-filters .filter-submit {
    width: auto;
    min-width: 92px;
    justify-content: center;
    white-space: nowrap;
}

.commission-filters .input-with-icon {
    width: 100%;
    display: block;
}

.commission-filters .input-with-icon input {
    width: 100%;
}

/* Gráficos */
.chart-container {
    width: 100%;
    height: 350px;
}

/* Responsividade */
@media (max-width: 1024px) {
    .wrapper {
        padding: 12px;
        gap: 16px;
    }

    #sidebar {
        width: 240px;
    }

    #content {
        max-width: calc(100% - 268px);
    }
}

@media (max-width: 768px) {
    .wrapper {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        height: auto;
        position: static;
    }

    #content {
        max-width: 100%;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .navbar {
        padding: 12px 16px;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .auth-card {
        padding: 24px;
    }

    .affiliate-manager-header,
    .manager-flow,
    .affiliate-level-grid {
        grid-template-columns: 1fr;
    }

    .affiliate-manager-header {
        flex-direction: column;
    }

    .affiliate-manager-total {
        width: 100%;
    }

    .commission-filters {
        grid-template-columns: 1fr;
    }

    .commission-filters .filter-submit {
        width: 100%;
    }
}
/* ===== Busca com ícone (dashboard “Últimas Comissões”) ===== */
.input-with-icon{
  position: relative;
  display: inline-block;        /* fica em linha com os outros filtros */
  vertical-align: middle;
}

.input-with-icon input{
  width: 220px;                 /* ajuste se quiser maior/menor */
  height: 36px;
  line-height: 36px;
  padding: 0 12px 0 36px;       /* espaço para a lupa à esquerda */
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
  background: #fff;
}

.input-with-icon .search-icon{
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: 0;
  padding: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  cursor: text;                 /* clicar foca no input */
}

.input-with-icon .search-icon i{
  pointer-events: none;
  opacity: .7;
}
@media (min-width: 769px) and (max-width: 1320px) {
  .commission-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Chrome/WebKit tende a deixar date mais alto */
input[type="date"].btn::-webkit-datetime-edit {
  padding: 0 2px;
}
/* Modal simples */
.modal-backdrop{
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 16px;
}
.modal-card{
  width: 100%; max-width: 520px; background: #fff; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12); overflow: hidden;
  animation: modalIn .18s ease-out;
}
.modal-header, .modal-footer{ padding: 16px 20px; background: #f8fafc; }
.modal-body{ padding: 16px 20px; }
.modal-header h4{ margin: 0; font-size: 1.05rem; }
.modal-close{
  background: transparent; border: 0; font-size: 22px; cursor: pointer; line-height: 1;
  color: #64748b;
}
@keyframes modalIn{from{transform: translateY(8px); opacity:0} to{transform:none; opacity:1}}

.stat-helper {
    margin-top: 8px;
    color: var(--text-light, #64748b);
    font-size: 0.82rem;
    line-height: 1.35;
}

.stat-helper.success {
    color: #047857;
}

.stat-helper.warning {
    color: #b45309;
}

.stat-actions {
    margin-top: 14px;
}

.btn-release-compact {
    padding: 8px 12px;
    align-self: flex-start;
    white-space: nowrap;
}
.affiliate-release-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
}

.affiliate-release-modal.is-open {
    display: flex;
}

.affiliate-release-dialog {
    position: relative;
    width: min(520px, 100%);
    background: #ffffff;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.affiliate-release-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
}

.affiliate-release-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    border-radius: 12px;
    background: #ecfdf5;
    color: #059669;
    font-size: 1.25rem;
}

.affiliate-release-dialog h2 {
    margin: 0 36px 10px 0;
    font-size: 1.35rem;
    line-height: 1.25;
}

.affiliate-release-dialog p {
    color: var(--text-light, #64748b);
    font-size: 0.95rem;
    line-height: 1.55;
}

.affiliate-release-summary {
    margin: 18px 0;
    padding: 12px 14px;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    background: #f0fdf4;
    color: #047857;
    font-weight: 700;
}

.affiliate-release-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.affiliate-release-actions.single-action .btn {
    flex: 1;
    justify-content: center;
}

.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}
