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

:root {
    --primary: #1e1e2d;
    --primary-hover: #000000;
    --primary-light: #eef0f2;
    --success: #50cd89;
    --success-light: #e8fff3;
    --danger: #f1416c;
    --danger-light: #fff5f8;
    --warning: #ffc700;
    --warning-light: #fff8dd;
    --info: #7239ea;
    --info-light: #f8f5ff;
    --dark: #181c32;
    --gray-600: #7e8299;
    --gray-500: #a1a5b7;
    --gray-400: #b5b5c3;
    --border: #eff2f5;
    --border-input: #e4e6ef;
    --bg: #f5f8fa;
    --sidebar: #1e1e2d;
    --sidebar-item: #9899ac;
    --sidebar-hover-bg: #2a2a3c;
    --radius-card: 0.625rem;
    --radius-btn: 0.475rem;
    --shadow-card: 0 0 20px 0 rgba(76, 87, 125, 0.05);
    --shadow-hover: 0 0 30px 0 rgba(76, 87, 125, 0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Poppins', Helvetica, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--dark);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

h1 { font-size: 20px; font-weight: 600; margin: 0; color: var(--dark); }
h2 { font-size: 16px; font-weight: 600; color: var(--dark); }
h3 { font-size: 14px; font-weight: 600; color: var(--dark); }

/* ============ LAYOUT ============ */
.app-page { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 265px;
    background: var(--sidebar);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}
.app-sidebar-logo {
    height: 90px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 25px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.app-sidebar-logo .logo-img { height: 46px; width: auto; }
.app-sidebar-logo .brand-text { color: #fff; font-size: 20px; font-weight: 700; letter-spacing: .5px; }

/* Badges de tipo de variável (Tabela Base / Variáveis) */
.badge-number   { background: var(--gray-200, #EFF2F5); color: #3f4254; }
.badge-currency { background: var(--success-light, #e8fff3); color: #2d8a5f; }
.badge-percent  { background: var(--warning-light, #fff8dd); color: #b58600; }
.badge-factor   { background: var(--primary-light, #e6f3ff); color: var(--primary); }
.badge-text     { background: #f1e9ff; color: #7239ea; }
.badge-inactive { background: #fbe6ea; color: #d9214e; }
.badge-active   { background: var(--success-light, #e8fff3); color: #2d8a5f; }

/* Cards de estatística do dashboard */
.stat-card { display: block; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.stat-card:hover { box-shadow: 0 4px 18px 0 rgba(76,87,125,.12); transform: translateY(-2px); }
.stat-value { font-size: 34px; font-weight: 700; color: #1e1e2d; line-height: 1.1; }
.stat-label { font-size: 14px; color: #7e8299; margin-top: 6px; }
.stat-label .hint { display: inline; }

/* Aplicabilidade por material (checkboxes lado a lado) */
.checkbox-row { display: flex; flex-wrap: wrap; gap: 18px; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13.5px; color: #3f4254; }
.checkbox-inline input { width: auto; }

/* Editor de opções da variável */
.options-table { width: 100%; }
.options-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #a1a5b7; padding: 6px 8px; }
.options-table td { padding: 4px 8px; vertical-align: middle; }
.options-table input[type=text], .options-table input[type=number] { margin: 0; padding: 8px 10px; }
.btn-remove {
    border: 1px solid #E4E6EF; background: #fff; color: #d9214e; width: 30px; height: 30px;
    border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; font-weight: 600;
}
.btn-remove:hover { background: #fbe6ea; }
.type-section { border-top: 1px solid #EFF2F5; margin-top: 18px; padding-top: 18px; }

/* Matriz de preços (Tabela Base) */
.table-scroll { overflow-x: auto; }
.matrix-table { min-width: 900px; font-size: 13px; }
.matrix-table th, .matrix-table td { padding: 7px 10px; white-space: nowrap; }
.matrix-table thead th { position: sticky; top: 0; }
.matrix-table .bracket-cell {
    font-weight: 600; color: #181c32; background: #f9fafc;
    vertical-align: middle; border-right: 2px solid #EFF2F5;
}
.matrix-table tr.bracket-start td { border-top: 2px solid #E4E6EF; }
.matrix-edit td { padding: 4px 6px; }
.matrix-edit input[type=number] { width: 74px; margin: 0; padding: 6px 8px; text-align: right; font-size: 12.5px; }

/* Simulador — detalhamento do cálculo */
.calc-steps { width: 100%; font-size: 13px; margin-bottom: 16px; }
.calc-steps th, .calc-steps td { padding: 8px 10px; }
.result-box { background: #f9fafc; border: 1px solid #EFF2F5; border-radius: .475rem; padding: 16px 18px; }
.result-line { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; color: #3f4254; }
.result-line strong { font-size: 15px; color: #181c32; }
.result-line.total { border-top: 2px solid #E4E6EF; margin-top: 6px; padding-top: 12px; }
.result-line.total span { font-weight: 600; font-size: 15px; }
.result-line.total strong { font-size: 22px; color: #50cd89; }

/* Resumo detalhado do simulador */
.summary-table { width: 100%; font-size: 13.5px; margin-bottom: 16px; }
.summary-table th { text-align: left; font-weight: 500; color: #7e8299; padding: 7px 10px; width: 48%; vertical-align: top; }
.summary-table td { padding: 7px 10px; color: #181c32; font-weight: 600; }
.summary-table td.muted { color: #b5b9c6; font-weight: 400; font-style: italic; }
.summary-table tr:not(.sep) th, .summary-table tr:not(.sep) td { border-top: 1px solid #F1F3F7; }
.summary-table tr.sep th {
    background: #f9fafc; color: #a1a5b7; font-size: 11px; text-transform: uppercase;
    letter-spacing: .5px; font-weight: 600; padding: 8px 10px; border-top: 2px solid #E4E6EF;
}

.app-sidebar-menu { padding: 15px; display: flex; flex-direction: column; gap: 2px; }
.menu-section {
    color: #565674;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 10px 8px;
}
.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-btn);
    color: var(--sidebar-item);
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.15s ease;
}
.menu-link:hover { background: var(--sidebar-hover-bg); color: #fff; }
.menu-link.active { background: var(--sidebar-hover-bg); color: #fff; }
.menu-link.active .menu-icon { color: #fff; }
.menu-icon { flex-shrink: 0; color: #6d6d80; }
.menu-link.menu-sub { padding: 7px 12px 7px 16px; font-size: 12.5px; }
.menu-bullet { width: 6px; height: 6px; border-radius: 50%; background: #565674; flex-shrink: 0; margin: 0 8px 0 4px; }
.menu-link.menu-sub:hover .menu-bullet, .menu-link.menu-sub.active .menu-bullet { background: #fff; }
.menu-link:hover .menu-icon { color: #fff; }

.sidebar-overlay { display: none; }

.app-wrapper {
    flex: 1;
    margin-left: 265px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-header {
    height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}
.header-burger { display: none; cursor: pointer; color: var(--gray-600); }
.app-header-title { font-size: 17px; font-weight: 600; flex: 1; }
.app-header-user { display: flex; align-items: center; gap: 12px; }
.user-info { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { color: var(--gray-500); font-size: 11px; text-transform: capitalize; }
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 15px;
}
.user-logout {
    width: 38px; height: 38px;
    border-radius: 8px;
    background: var(--bg);
    color: var(--gray-600);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.user-logout:hover { background: var(--danger-light); color: var(--danger); }

.app-content { padding: 30px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ============ CARDS ============ */
.card {
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 25px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}
.card h2 { margin: 0 0 18px; }
.card h3 { margin: 0 0 14px; }

/* ============ TOOLBAR (page title strip) ============ */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============ TABLES ============ */
table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}
table th {
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
table td {
    padding: 12px;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
    color: #3f4254;
    vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tbody tr { transition: background 0.12s; }
table tbody tr:hover { background: var(--bg); }
.breakdown-table td.num, .breakdown-table th.num,
table td.num, table th.num { text-align: right; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-btn);
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
    line-height: 1.4;
}
.btn:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--bg); color: var(--gray-600); }
.btn-secondary:hover { background: #e9edf1; color: var(--dark); }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-small { padding: 6px 12px; font-size: 12px; }
.linklike { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { text-decoration: underline; }

/* ============ FORMS ============ */
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #3f4254; }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password],
.form-row input[type=number], .form-row select, .form-row textarea,
input[type=text], input[type=number], select, textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-family: inherit;
    color: var(--dark);
    background: #fff;
    transition: border-color 0.15s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus,
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gray-400);
}
.form-row .hint, .hint { color: var(--gray-500); font-size: 12px; margin-top: 4px; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }

/* ============ MIRROR WIZARD ============ */
.mirror-block { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 22px; margin-bottom: 20px; background: #fff; }
.mirror-block h3 { margin-top: 0; }
.conditional { display: none; }
.conditional.visible { display: block; }
.total-box { font-size: 18px; font-weight: 700; text-align: right; padding: 14px 0; color: var(--dark); }

/* ============ FLASH / ALERTS ============ */
.flash { padding: 14px 18px; border-radius: var(--radius-btn); margin-bottom: 22px; font-size: 13px; font-weight: 500; }
.flash-success { background: var(--success-light); color: #2d8a5f; }
.flash-error { background: var(--danger-light); color: var(--danger); }

/* ============ BADGES ============ */
.badge { display: inline-block; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge-draft { background: var(--warning-light); color: #b58600; }
.badge-finalized { background: var(--primary-light); color: var(--primary); }
.badge-sent { background: var(--success-light); color: #2d8a5f; }

/* ============ LOGIN ============ */
.page { max-width: 1320px; margin: 0 auto; padding: 30px; }
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}
.login-box {
    max-width: 400px;
    width: 100%;
    background: #fff;
    padding: 40px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}
.login-box .login-logo {
    text-align: center;
    margin-bottom: 8px;
}
.login-box .login-logo img { height: 60px; width: auto; }
.login-box h1 { font-size: 18px; margin: 20px 0 24px; text-align: center; font-weight: 600; }
.login-box .btn { width: 100%; justify-content: center; padding: 12px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 991px) {
    .app-sidebar { transform: translateX(-265px); transition: transform 0.25s ease; }
    .app-wrapper { margin-left: 0; }
    .header-burger { display: flex; }
    .sidebar-toggle-cb:checked ~ .app-page .app-sidebar { transform: translateX(0); }
    .sidebar-toggle-cb:checked ~ .app-page .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
    }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .app-content { padding: 20px; }
}
