:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --dark: #111827;
    --brown: #7a6856;
    --danger: #b91c1c;
    --ok: #047857;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-bottom: 72px;
}

.top {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--dark);
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top strong { display: block; font-size: 18px; }
.top span { display: block; font-size: 12px; opacity: .75; }

.top a {
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.25);
    padding: 8px 10px;
    border-radius: 10px;
}

.wrap, .result-page {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 16px;
    display: grid;
    gap: 16px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,.04);
}

h1, h2 { margin: 0 0 12px; }
.muted, small { color: var(--muted); }

.form { display: grid; gap: 14px; }

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

input, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px;
    font: inherit;
}

textarea { resize: vertical; }

.btn {
    width: 100%;
    border: 0;
    background: var(--dark);
    color: white;
    padding: 15px;
    border-radius: 14px;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn.secondary {
    display: inline-block;
    width: auto;
    margin-top: 12px;
}

.hidden { display: none; }

.rule {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f9fafb;
    display: grid;
    gap: 4px;
}

.warning {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    padding: 12px;
    border-radius: 14px;
}

.files { display: grid; gap: 8px; }

.file-pill {
    background: #f3f4f6;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 10px;
    font-size: 13px;
}

.hero {
    background: #111827;
    color: white;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.chips span {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    padding: 8px 10px;
    font-size: 13px;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    position: sticky;
    top: 68px;
    z-index: 5;
}

.tab-btn {
    border: 1px solid var(--line);
    background: white;
    padding: 12px 8px;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
}

.tab-btn.active {
    background: var(--dark);
    color: white;
}

.tab-panel { display: none; gap: 16px; }
.tab-panel.active { display: grid; }

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

th { background: #f9fafb; }

.two {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.error p, .error-text { color: var(--danger); font-weight: 700; }
.ok { color: var(--ok); font-weight: 700; }

.login {
    width: min(420px, 100%);
    margin: 0 auto;
    padding: 40px 16px;
}

.bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: white;
    border-top: 1px solid var(--line);
}

.bottom a {
    padding: 15px;
    text-align: center;
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
}

code {
    background: #f3f4f6;
    padding: 2px 5px;
    border-radius: 6px;
}

.budget-sheet {
    border: 2px solid var(--brown);
    border-radius: 16px;
    background: white;
}

.budget-head {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    align-items: center;
    gap: 18px;
    margin-bottom: 22px;
}

.logo-text {
    font-size: 42px;
    font-weight: 900;
    letter-spacing: -2px;
}

.logo-sub {
    background: var(--brown);
    color: white;
    display: inline-block;
    padding: 3px 12px;
    font-weight: 900;
    letter-spacing: 2px;
}

.budget-head h1 {
    font-size: 36px;
    letter-spacing: 2px;
    text-align: center;
}

.line {
    height: 3px;
    background: var(--brown);
    width: 80%;
    margin: 0 auto;
}

.budget-client, .budget-extra {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 16px 0;
}

.budget-total {
    display: grid;
    gap: 10px;
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    margin: 16px 0;
    font-size: 18px;
}

.budget-total strong {
    float: right;
}

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

@media (min-width: 820px) {
    body { padding-bottom: 0; }
    .wrap {
        grid-template-columns: 1.1fr .9fr;
        align-items: start;
    }
    .two { grid-template-columns: 1fr 1fr; }
    .bottom { display: none; }
    .budget-client { grid-template-columns: 1.4fr 1fr .8fr; }
    .budget-extra { grid-template-columns: repeat(4, 1fr); }
}

@media print {
    body { background: white; padding: 0; }
    .top, .bottom, .tabs, .hero, .tab-panel:not(#tab-desenho), .budget-actions { display: none !important; }
    .result-page { padding: 0; width: 100%; }
    #tab-orcamento { display: block !important; }
    .budget-sheet { border: 2px solid var(--brown); box-shadow: none; border-radius: 0; min-height: 100vh; }
    input, textarea { border: 0; border-bottom: 1px solid #ccc; border-radius: 0; }
}

/* Planejamento interno e produção */
.tabs {
    grid-template-columns: repeat(5, 1fr);
}

.approval-box,
.sheet-config {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 16px 0;
}

select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px;
    font: inherit;
    background: white;
}

.ok-box {
    background: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
    color: #065f46;
}

.btn.small {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 12px;
    width: auto;
}

.btn.danger {
    background: #991b1b;
}

#planejamentoTabela input,
#planejamentoTabela textarea,
#producaoTabela input {
    min-width: 120px;
}

.cut-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f9fafb;
    padding: 10px;
    margin-top: 12px;
}

#planoCorteCanvas {
    width: 100%;
    min-width: 760px;
    max-width: 100%;
    background: white;
    border-radius: 10px;
}

.labels-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 12px;
}

.label-card {
    border: 1px dashed #111827;
    border-radius: 12px;
    padding: 12px;
    background: white;
    display: grid;
    gap: 4px;
    font-size: 13px;
}

.label-card strong {
    font-size: 16px;
}

.producao-area {
    display: none;
}

@media (min-width: 820px) {
    .approval-box,
    .sheet-config {
        grid-template-columns: repeat(3, 1fr);
    }
    .labels-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media print {
    .tab-panel { display: none !important; }
    #tab-planejamento.active,
    #tab-producao.active {
        display: block !important;
    }
    .btn, .tabs, .top, .bottom, .producao-lock { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}


.render-action {
    display: inline-block;
    background: #111827;
    color: #fff;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 800;
    margin-top: 10px;
}

@media print {
    .render-action { display: none !important; }
}


.svg-desenho-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.svg-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    overflow: auto;
}

.svg-card svg {
    width: 100%;
    min-height: 260px;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.prompt-box {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    font-family: Arial, Helvetica, sans-serif;
    resize: vertical;
    margin-bottom: 12px;
}

.render-actions {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.render-result {
    min-height: 320px;
    border: 1px dashed #9ca3af;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: #f9fafb;
    overflow: hidden;
    padding: 10px;
}

.render-result img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}

@media (min-width: 900px) {
    .svg-desenho-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .render-actions {
        grid-template-columns: repeat(3, 1fr);
    }
}
