:root {
    --roxo: #372b83;
    --dourado: #e8bb4d;
    --rosa: #c5546e;
    --bg: #f5f3fb;
    --texto: #25233a;
    --muted: #6b667d;
    --borda: #e4e0ef;
    --branco: #ffffff;
    --erro: #b42318;
    --sucesso: #067647;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--texto);
}

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

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

.sidebar {
    width: 270px;
    background: var(--roxo);
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.18);
}

.brand-icon,
.login-logo {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: var(--dourado);
    color: var(--roxo);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.brand-box strong {
    display: block;
    font-size: 20px;
    line-height: 1;
}

.brand-box span {
    display: block;
    color: rgba(255,255,255,0.75);
    margin-top: 4px;
}

.menu {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu a {
    color: #fff;
    padding: 13px 14px;
    border-radius: 14px;
    font-weight: 700;
    background: rgba(255,255,255,0.06);
}

.menu a.active,
.menu a:hover {
    background: var(--dourado);
    color: var(--roxo);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.18);
}

.sidebar-footer small,
.sidebar-footer strong,
.sidebar-footer a {
    display: block;
    color: #fff;
}

.sidebar-footer small {
    color: rgba(255,255,255,0.7);
}

.sidebar-footer a {
    margin-top: 10px;
    color: var(--dourado);
    font-weight: 700;
}

.content {
    width: 100%;
    padding: 32px;
    margin-left: 270px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 24px;
}

.page-head h1 {
    margin: 0;
    font-size: 30px;
    color: var(--roxo);
}

.page-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 800;
    cursor: pointer;
    background: #ece8f8;
    color: var(--roxo);
    min-height: 44px;
}

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

.btn-light {
    background: #fff;
    border: 1px solid var(--borda);
}

.btn.full {
    width: 100%;
}

.panel,
.metric-card,
.login-card {
    background: var(--branco);
    border: 1px solid var(--borda);
    border-radius: 22px;
    box-shadow: 0 16px 45px rgba(55, 43, 131, 0.08);
}

.panel {
    padding: 22px;
    margin-bottom: 22px;
}

.panel h2 {
    margin-top: 0;
    color: var(--roxo);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.metric-card {
    padding: 24px;
}

.metric-card span {
    color: var(--muted);
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin: 8px 0 12px;
    font-size: 42px;
    color: var(--roxo);
}

.metric-card a {
    font-weight: 800;
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--borda);
    border-radius: 12px;
    padding: 11px 12px;
    font-size: 15px;
    background: #fff;
    color: var(--texto);
}

.toolbar input {
    max-width: 360px;
}

.toolbar select {
    max-width: 220px;
}

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

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--borda);
    vertical-align: middle;
}

th {
    color: var(--roxo);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #faf9ff;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 30px;
}

.actions {
    display: flex;
    gap: 12px;
}

.actions a {
    font-weight: 800;
}

.actions .danger {
    color: var(--erro);
}

.tag {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: #f1edf9;
    color: var(--roxo);
    font-weight: 800;
    font-size: 13px;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
    font-weight: 800;
}

.alert-success {
    color: var(--sucesso);
    background: #ecfdf3;
    border: 1px solid #abefc6;
}

.alert-error {
    color: var(--erro);
    background: #fef3f2;
    border: 1px solid #fecdca;
}

.form-panel {
    max-width: 920px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
    color: var(--roxo);
}

.form-group label span {
    color: var(--rosa);
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.span-2 {
    grid-column: span 2;
}

.checkbox-card {
    padding: 14px 16px;
    background: #faf9ff;
    border: 1px solid var(--borda);
    border-radius: 16px;
}

.checkbox-line {
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
}

.checkbox-line input {
    width: 18px;
    min-height: 18px;
}

.readonly-box > div {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 11px 12px;
    border-radius: 12px;
    background: #faf9ff;
    border: 1px dashed var(--borda);
    font-size: 18px;
    font-weight: 900;
    color: var(--roxo);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #efeafd, #f8f6fb 45%, #ffffff);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 32px;
}

.login-logo {
    margin-bottom: 18px;
}

.login-card h1 {
    margin: 0;
    color: var(--roxo);
}

.login-card p {
    margin: 8px 0 24px;
    color: var(--muted);
}

.login-card label {
    display: block;
    margin: 14px 0 8px;
    font-weight: 800;
    color: var(--roxo);
}

.login-card button {
    margin-top: 18px;
}

.login-help {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--borda);
    color: var(--muted);
    font-size: 14px;
}

.table-wrap {
    overflow-x: auto;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .content {
        margin-left: 0;
        padding: 20px;
    }

    .page-head,
    .toolbar,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cards-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .toolbar input,
    .toolbar select {
        max-width: none;
    }
}

/* Matéria-prima composta */
.componentes-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.select-componente-mp {
    background: #fff;
}

.input-readonly {
    background: #faf9ff;
    color: var(--roxo);
    font-weight: 800;
}

.tag-composed {
    background: #fff5d6;
    color: #7a5100;
}

@media (max-width: 900px) {
    .componentes-container {
        grid-template-columns: 1fr;
    }
}
