:root {
    --ui-bg: #f3f4f8;
    --ui-text: #1d2129;
    --ui-muted: #6b7280;
    --ui-line: #e4e6eb;
    --ui-soft: #f5f6f8;
    --ui-accent: #7c3aed;
    --ui-accent-2: #6d28d9;
    --ui-accent-soft: #f1eafe;
    --ui-danger: #dc2626;
    --ui-good: #15803d;
    --ui-dark: #17181c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; color: var(--ui-text); background: var(--ui-bg); font-size: 14px; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
    border: 1px solid var(--ui-line); background: #fff; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px;
    text-decoration: none; transition: background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { background: var(--ui-soft); }
.btn.primary { background: var(--ui-accent); color: #fff; border-color: var(--ui-accent); }
.btn.primary:hover { background: var(--ui-accent-2); }
.btn.big { height: 46px; padding: 0 22px; font-size: 14px; border-radius: 12px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--ui-danger); }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--ui-muted); }
.icon-btn:hover { background: var(--ui-soft); color: var(--ui-text); }
.input { width: 100%; height: 44px; border: 1px solid var(--ui-line); border-radius: 10px; padding: 0 14px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-soft); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.error { color: var(--ui-danger); font-size: 13px; min-height: 18px; margin-top: 4px; }

/* LOGIN */
.login-page { display: flex; min-height: 100vh; background: linear-gradient(135deg, #1f1147, #4c1d95 55%, #7c3aed); align-items: center; justify-content: center; padding: 24px; }
.login-card { background: #fff; border-radius: 20px; padding: 36px 32px 30px; width: 100%; max-width: 400px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.login-card .brand-mark { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #4c1d95, #7c3aed); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; margin-bottom: 18px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p.sub { color: var(--ui-muted); margin-bottom: 24px; }
.login-card .btn { width: 100%; height: 46px; margin-top: 6px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-wrap .icon-btn { position: absolute; right: 5px; top: 5px; }

/* TOPO */
.top {
    background: linear-gradient(90deg, #1f1147, #4c1d95 55%, #7c3aed); color: #fff; height: 60px;
    display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 10;
}
.top .brand-mark { width: 34px; height: 34px; border-radius: 9px; background: #fff; color: #4c1d95; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.top .brand-text { font-weight: 700; font-size: 15px; }
.top .spacer { flex: 1; }
.top .user { font-size: 13px; opacity: .8; }
.top .btn { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; height: 34px; }
.top .btn:hover { background: rgba(255,255,255,.24); }

/* AMBIENTE DE TRABALHO */
.dash { max-width: 1180px; margin: 0 auto; padding: 32px 24px 60px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.dash-head h1 { font-size: 26px; letter-spacing: -.01em; }
.dash-head p { color: var(--ui-muted); margin-top: 4px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 220px; position: relative; }
.toolbar .search svg { position: absolute; left: 13px; top: 13px; color: var(--ui-muted); }
.toolbar .search .input { padding-left: 40px; }
.toolbar select.input { width: auto; min-width: 180px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card {
    background: #fff; border-radius: 16px; overflow: hidden; border: 1px solid var(--ui-line); display: flex; flex-direction: column;
    transition: box-shadow .2s, transform .2s, border-color .2s; cursor: pointer; position: relative;
}
.card:hover { box-shadow: 0 14px 40px rgba(30, 20, 60, .12); transform: translateY(-3px); border-color: #d9ccfb; }
.card-cover { height: 118px; position: relative; display: flex; align-items: flex-end; padding: 14px 16px; color: #fff; }
.card-cover .initials { font-size: 30px; font-weight: 800; letter-spacing: .02em; text-shadow: 0 2px 12px rgba(0,0,0,.25); }
.card-cover .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; }
.card-body { padding: 14px 16px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.card-body h3 { font-size: 15px; font-weight: 700; line-height: 1.3; }
.card-body .client { color: var(--ui-muted); font-size: 12.5px; }
.card-body .when { color: var(--ui-muted); font-size: 12px; margin-top: auto; padding-top: 8px; }
.card-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px 12px 16px; border-top: 1px solid var(--ui-line); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 100px; }
.chip.pub { background: #dcfce7; color: var(--ui-good); text-decoration: none; }
.chip.pub:hover { background: #bbf7d0; }
.chip.draft { background: var(--ui-soft); color: var(--ui-muted); }
.chip svg { width: 12px; height: 12px; }
.card-foot .spacer { flex: 1; }
.menu { position: absolute; right: 10px; bottom: 50px; background: #fff; border: 1px solid var(--ui-line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.14); padding: 6px; min-width: 170px; z-index: 5; display: none; }
.menu.open { display: block; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; font-size: 13px; }
.menu button:hover { background: var(--ui-soft); }
.menu button.danger { color: var(--ui-danger); }
.menu svg { width: 15px; height: 15px; }

.new-card {
    border: 2px dashed #c4b5fd; background: var(--ui-accent-soft); border-radius: 16px; min-height: 248px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px; color: var(--ui-accent); font-weight: 700; cursor: pointer; transition: background .15s;
}
.new-card:hover { background: #e9ddfd; }
.new-card .plus { width: 52px; height: 52px; border-radius: 50%; background: var(--ui-accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.new-card .plus svg { width: 26px; height: 26px; }
.empty { text-align: center; padding: 60px 20px; color: var(--ui-muted); }

.ext-title { margin: 44px 0 6px; font-size: 16px; }
.ext-sub { color: var(--ui-muted); margin-bottom: 14px; font-size: 13px; }
.ext-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ext { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--ui-line); border-radius: 12px; padding: 12px 14px; text-decoration: none; transition: border-color .15s; }
.ext:hover { border-color: var(--ui-accent); }
.ext b { display: block; font-size: 13px; }
.ext span { font-size: 11.5px; color: var(--ui-muted); }
.ext .dot { width: 32px; height: 32px; border-radius: 8px; background: var(--ui-soft); display: flex; align-items: center; justify-content: center; color: var(--ui-muted); flex-shrink: 0; }

/* MODAL */
.modal-back { position: fixed; inset: 0; background: rgba(15, 12, 30, .55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 820px; max-height: 90vh; overflow-y: auto; padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal h2 { font-size: 20px; }
.modal .sub { color: var(--ui-muted); margin-top: 4px; }
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 6px 0 20px; }
.tpl {
    border: 2px solid var(--ui-line); border-radius: 14px; padding: 0; cursor: pointer; background: #fff; text-align: left; overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}
.tpl:hover { border-color: #c4b5fd; }
.tpl.on { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-soft); }
.tpl-prev { height: 84px; position: relative; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.tpl-prev .l1 { height: 7px; border-radius: 3px; width: 70%; }
.tpl-prev .l2 { height: 5px; border-radius: 3px; width: 45%; opacity: .7; }
.tpl-prev .tag { position: absolute; top: 10px; right: 10px; font-size: 10px; font-weight: 700; background: #fff; color: var(--ui-accent); padding: 2px 8px; border-radius: 100px; }
.tpl-info { padding: 10px 12px 12px; }
.tpl-info b { display: block; font-size: 13px; margin-bottom: 3px; }
.tpl-info span { font-size: 11.5px; color: var(--ui-muted); line-height: 1.45; display: block; }
.tpl-info i { font-style: normal; font-size: 10.5px; color: var(--ui-accent); font-weight: 600; display: block; margin-top: 6px; }
.modal-foot { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ui-dark); color: #fff; padding: 11px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 86vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--ui-danger); }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px; color: var(--ui-muted); }
.spin { width: 18px; height: 18px; border: 2px solid var(--ui-line); border-top-color: var(--ui-accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
    .tpl-grid { grid-template-columns: 1fr 1fr; }
    .top .user { display: none; }
}
@media (max-width: 480px) { .tpl-grid { grid-template-columns: 1fr; } }

/* ---------- Criar com IA ---------- */
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn.ai-btn { background: linear-gradient(135deg, #f1eafe, #fde7f3); color: var(--ui-accent-2); border-color: #ddd0fb; }
.btn.ai-btn:hover { background: linear-gradient(135deg, #e9ddfd, #fbd8ec); }
.ai-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-form textarea.input { height: auto; padding: 10px 14px; resize: vertical; line-height: 1.45; }
.ai-form .help { font-size: 12px; color: var(--ui-muted); margin-top: 6px; }
.ai-form .req { font-weight: 500; color: #b91c1c; }
.ai-shots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ai-shot { aspect-ratio: 3/4; border-radius: 10px; border: 1px solid var(--ui-line); background: #f9fafb center/cover no-repeat; position: relative; }
.ai-shot button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ai-shot button svg { width: 12px; height: 12px; }
.ai-shot.add { border: 2px dashed #c4b5fd; background: var(--ui-accent-soft); color: var(--ui-accent); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 600; font-size: 11px; }
.ai-shot.add svg { width: 20px; height: 20px; }
.ai-toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 4px 0 16px; cursor: pointer; }
.ai-toggle input { width: 18px; height: 18px; accent-color: var(--ui-accent); }
.ai-toggle span { color: var(--ui-muted); }
.ai-progress { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 12px; background: var(--ui-accent-soft); margin-bottom: 14px; }
.ai-progress b { display: block; font-size: 14px; }
.ai-progress span { font-size: 12px; color: var(--ui-muted); }
.ai-done { padding: 16px; border-radius: 12px; background: #ecfdf5; border: 1px solid #a7f3d0; margin-bottom: 14px; }
.ai-done h3 { font-size: 15px; margin-bottom: 6px; color: #065f46; }
.ai-done ul { margin: 6px 0 0 18px; font-size: 13px; color: #374151; }
@media (max-width: 640px) { .ai-form .row { grid-template-columns: 1fr; } .ai-shots { grid-template-columns: repeat(3, 1fr); } }

/* Recuperar propostas do armazenamento antigo */
.migrate { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 28px 0 8px; padding: 16px 18px; border: 1px dashed #c4b5fd; border-radius: 14px; background: var(--ui-accent-soft); }
.migrate b { display: block; font-size: 14px; }
.migrate span { display: block; font-size: 12.5px; color: var(--ui-muted); margin-top: 3px; max-width: 620px; }
