/* ============================================================
   Sistema de Controle de Fornecedores - TI
   Design tokens
   ============================================================ */
:root {
    --bg: #0f172a;
    --bg-2: #1e293b;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
    --shadow: 0 4px 14px rgba(15,23,42,.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

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

/* ============================================================
   Layout principal
   ============================================================ */
.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    border-bottom: 1px solid #334155;
    margin-bottom: 20px;
}

.brand-logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: var(--radius-sm);
    display: grid; place-items: center;
    font-weight: 700;
    color: white;
}

.brand-text strong {
    display: block;
    font-size: 15px;
    color: white;
}
.brand-text span {
    font-size: 12px;
    color: #94a3b8;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    font-size: 14px;
    transition: all .15s;
}
.sidebar nav a:hover { background: #1e293b; color: white; text-decoration: none; }
.sidebar nav a.active {
    background: var(--primary);
    color: white;
}
.sidebar nav .ico { font-size: 16px; }

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #1e293b;
    border-radius: var(--radius-sm);
    margin-top: 16px;
}
.user-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: grid; place-items: center;
    color: white;
    font-weight: 600;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong {
    display: block;
    color: white;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.perfil-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: .5px;
    margin-top: 2px;
}
.perfil-admin       { background: #fbbf24; color: #78350f; }
.perfil-gestor      { background: #60a5fa; color: #1e3a8a; }
.perfil-visualizador{ background: #94a3b8; color: #1e293b; }

.logout-btn {
    color: #94a3b8;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
}
.logout-btn:hover { background: var(--danger); color: white; text-decoration: none; }

/* ============================================================
   Conteúdo
   ============================================================ */
.content {
    overflow-y: auto;
    max-height: 100vh;
}
.topbar {
    background: var(--surface);
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 22px; font-weight: 600; }
.subtitulo { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.page-body { padding: 24px 32px; }

/* ============================================================
   Cards / KPIs
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}
.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
}
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-accent { border-left: 4px solid var(--primary); }
.kpi-success { border-left: 4px solid var(--success); }
.kpi-warning { border-left: 4px solid var(--warning); }
.kpi-danger  { border-left: 4px solid var(--danger); }

/* ============================================================
   Card genérico
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card .card-actions { display: flex; gap: 8px; }

.card-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 1000px) {
    .card-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   Botões
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    background: var(--surface-3);
    color: var(--text);
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: white; border-color: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ============================================================
   Formulários
   ============================================================ */
.form-row {
    display: grid;
    gap: 14px;
    margin-bottom: 12px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 900px) {
    .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
}

label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=file], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: white;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ============================================================
   Tabelas
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    background: var(--surface-3);
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-essencial     { background: var(--success-light); color: #065f46; }
.badge-nao-essencial { background: var(--danger-light);  color: #991b1b; }
.badge-nao-avaliado  { background: var(--surface-3);     color: var(--text-muted); }
.badge-info          { background: var(--primary-light); color: #1e40af; }

/* Prioridade */
.prio { display:inline-block; padding: 2px 7px; border-radius: 4px; font-weight: 600; font-size: 12px; }
.prio-5 { background: #fee2e2; color: #991b1b; }
.prio-4 { background: #fed7aa; color: #9a3412; }
.prio-3 { background: #fef3c7; color: #854d0e; }
.prio-2 { background: #e0e7ff; color: #3730a3; }
.prio-1, .prio-0 { background: #e0f2fe; color: #075985; }

/* Notas */
.nota-circle {
    display: inline-grid;
    place-items: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
    color: white;
}
.nota-10, .nota-9, .nota-8 { background: var(--success); }
.nota-7, .nota-6           { background: #84cc16; }
.nota-5, .nota-4           { background: var(--warning); }
.nota-3, .nota-2, .nota-1, .nota-0 { background: var(--danger); }
.nota-na                   { background: var(--text-muted); }

/* ============================================================
   Mensagens
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border: 1px solid;
    font-size: 13px;
}
.alert-success { background: var(--success-light); border-color: #6ee7b7; color: #065f46; }
.alert-error   { background: var(--danger-light);  border-color: #fca5a5; color: #991b1b; }
.alert-info    { background: var(--primary-light); border-color: #93c5fd; color: #1e40af; }
.alert-warning { background: var(--warning-light); border-color: #fcd34d; color: #78350f; }

/* ============================================================
   Login
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-card {
    background: white;
    padding: 36px 32px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: 100%;
    max-width: 380px;
}
.login-card .brand {
    border: none;
    padding: 0;
    margin: 0 0 24px 0;
    justify-content: center;
}
.login-card .brand-text strong { color: var(--text); }
.login-card .brand-text span { color: var(--text-muted); }
.login-card h2 {
    font-size: 18px;
    margin-bottom: 4px;
    text-align: center;
}
.login-card .hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}
.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 11px;
}

/* ============================================================
   Filtros
   ============================================================ */
.filtros {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    align-items: end;
}
.filtros .actions { display: flex; gap: 6px; align-items: end; }

/* ============================================================
   Charts
   ============================================================ */
.chart-container {
    position: relative;
    height: 320px;
}
.chart-tall { height: 420px; }

/* ============================================================
   Drop zone (upload)
   ============================================================ */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    background: var(--surface-2);
    transition: all .2s;
    cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.dropzone-icon { font-size: 48px; margin-bottom: 10px; }
.dropzone p { color: var(--text-muted); margin-bottom: 6px; }

/* Helpers */
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap { gap: 12px; }
.wrap-cnpj { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; color: var(--text-muted); }
.cc-tag { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; margin-right: 4px; font-family: ui-monospace, monospace; }
.cc-ac { background: #dbeafe; color: #1e40af; }
.cc-av { background: #fce7f3; color: #9d174d; }
.cc-gr { background: #d1fae5; color: #065f46; }
