/* 619 Importadora — CRM */
:root {
  --bg: #0f0a09; --side: #170d0c; --panel: #1b1110; --panel2: #221514; --line: rgba(201, 162, 74, .16); --line2: rgba(255, 255, 255, .06);
  --text: #f1e8da; --muted: #a2948a; --gold: #c9a24a; --gold2: #e8cf8a; --red: #d6312f; --green: #4ade80; --amber: #fbbf24; --blue: #7aa7ff;
  --serif: 'Playfair Display', Georgia, serif; --sans: 'Inter', system-ui, sans-serif; --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; background: radial-gradient(ellipse at 50% 0%, #3a1414, var(--bg) 60%); }
.login .box { width: min(860px, 100%); text-align: center; animation: up .9s var(--ease); }
.login img.logo { width: 120px; border-radius: 50%; margin: 0 auto 20px; box-shadow: 0 0 80px rgba(214, 49, 47, .4); }
.login h1 { font-size: 38px; margin-bottom: 6px; }
.login p { color: var(--muted); margin-bottom: 34px; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; text-align: left; }
.profile { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .02); display: flex; gap: 12px; align-items: center; transition: .35s var(--ease); }
.profile:hover { border-color: var(--gold); transform: translateY(-3px); background: rgba(201, 162, 74, .06); }
.profile small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
@keyframes up { from { opacity: 0; transform: translateY(30px); } }

/* layout */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; border-bottom: 1px solid var(--line2); margin-bottom: 16px; }
.side .brand img { width: 44px; border-radius: 50%; }
.side .brand b { font-family: var(--serif); font-weight: 400; font-size: 16px; display: block; }
.side .brand small { color: var(--muted); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--muted); margin-bottom: 3px; width: 100%; transition: .3s var(--ease); position: relative; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.nav-item.on { color: var(--gold2); background: linear-gradient(90deg, rgba(201, 162, 74, .14), transparent); }
.nav-item.on::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--gold); }
.nav-item .pill { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 10px; }
.side .me { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line2); display: flex; gap: 10px; align-items: center; }
.side .me small { color: var(--muted); display: block; font-size: 11px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: linear-gradient(135deg, var(--gold), #7a1018); color: #fff; flex: none; }
.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; border-bottom: 1px solid var(--line2); position: sticky; top: 0; background: rgba(15, 10, 9, .85); backdrop-filter: blur(12px); z-index: 20; }
.top h2 { font-size: 26px; }
.top .crumb { color: var(--muted); font-size: 12px; }
.top .right { display: flex; gap: 10px; align-items: center; }
.live { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line2); border-radius: 999px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: blink 2s infinite; }
@keyframes blink { 50% { opacity: .4; } }
.content { padding: 28px 32px 60px; animation: fadeIn .5s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(14px); } }
.menu-btn { display: none; }

/* elementos */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; border: 1px solid var(--line); transition: .25s var(--ease); white-space: nowrap; }
.btn:hover { border-color: var(--gold); color: var(--gold2); }
.btn.primary { background: linear-gradient(135deg, var(--gold2), var(--gold)); color: #1a0d08; border: 0; }
.btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); color: #1a0d08; }
.btn.danger { border-color: rgba(214, 49, 47, .5); color: #ff8a80; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.card { background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; padding: 22px; }
.card h3 { font-size: 20px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; animation: up .7s var(--ease) both; }
.kpi:nth-child(2) { animation-delay: .06s; } .kpi:nth-child(3) { animation-delay: .12s; } .kpi:nth-child(4) { animation-delay: .18s; } .kpi:nth-child(5) { animation-delay: .24s; }
.kpi small { color: var(--muted); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.kpi b { display: block; font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 8px 0 4px; color: var(--gold2); }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: radial-gradient(circle, rgba(214, 49, 47, .25), transparent 70%); }
.two { grid-template-columns: 1.6fr 1fr; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line2); }
td { padding: 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tr { transition: background .2s; } tbody tr:hover { background: rgba(255, 255, 255, .02); }
.table-wrap { overflow-x: auto; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .06); white-space: nowrap; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.t-green { color: var(--green); background: rgba(74, 222, 128, .1); } .t-amber { color: var(--amber); background: rgba(251, 191, 36, .1); }
.t-red { color: #ff8a80; background: rgba(214, 49, 47, .14); } .t-blue { color: var(--blue); background: rgba(122, 167, 255, .1); } .t-gold { color: var(--gold2); background: rgba(201, 162, 74, .12); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.input, select.input, textarea.input { width: 100%; background: rgba(255, 255, 255, .03); border: 1px solid var(--line2); color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; outline: none; transition: .2s; }
.input:focus { border-color: var(--gold); background: rgba(201, 162, 74, .04); }
select.input option { background: var(--panel); }
.search { max-width: 320px; }
.bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .06); overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; border-radius: 6px; transition: width .8s var(--ease); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* catálogo */
.wines { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.key-st { font-size: 11px; letter-spacing: 0; text-transform: none; margin-left: 6px; }
.key-st b { font-weight: 500; }
.key-hook { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; }
.key-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.key-row .mono { word-break: break-all; flex: 1; min-width: 0; color: var(--gold2); }
.wineries-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.wy-card { display: flex; flex-direction: column; min-width: 0; }
.wy-card p { flex: 1; }
.wy-foot { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line2); }
.wy-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wy-acts .btn { justify-content: center; width: 100%; padding: 9px 10px; }
.wy-acts .btn svg { width: 14px; height: 14px; flex: none; }
.wcard { padding: 0; overflow: hidden; transition: .35s var(--ease); animation: up .6s var(--ease) both; }
.wcard:hover { border-color: var(--line); transform: translateY(-4px); box-shadow: 0 20px 40px -20px #000; }
.wcard .img { height: 220px; display: grid; place-items: center; background: radial-gradient(circle at 50% 60%, rgba(122, 16, 24, .45), transparent 65%); position: relative; }
.wcard .img { overflow: hidden; padding: 0; }
.wcard .img .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.wcard:hover .img .ph { transform: scale(1.06); }
.wcard .img .tags { z-index: 2; }
.flagtag { position: absolute; bottom: 10px; left: 10px; z-index: 2; font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; color: #1a0d08; background: linear-gradient(135deg, #f6e2a8, var(--gold)); }
.thumb { width: 38px; height: 50px; object-fit: cover; border-radius: 8px; flex: none; }
.pv-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preview3d .hint { z-index: 2; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); padding: 20px 0 10px; bottom: 0; }
.photo-up { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.range { gap: 8px !important; } .range b { color: var(--gold2); font-weight: 500; float: right; }
input[type=range] { accent-color: var(--gold); width: 100%; }
.wcard .img .tags { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; }
.wcard .b { padding: 16px; }
.wcard h4 { font-family: var(--serif); font-weight: 400; font-size: 18px; margin-bottom: 2px; }
.wcard .row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; }
.wcard .price { font-family: var(--serif); font-size: 20px; color: var(--gold2); }
.switch { position: relative; width: 36px; height: 20px; border-radius: 20px; background: rgba(255, 255, 255, .12); transition: .3s; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .3s var(--ease); }
.switch.on { background: var(--gold); } .switch.on::after { left: 18px; }
.sw { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

/* editor / modal */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); z-index: 50; opacity: 0; pointer-events: none; transition: .4s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(1080px, 100%); background: var(--panel); border-left: 1px solid var(--line); z-index: 51; transform: translateX(100%); transition: transform .55s var(--ease); display: flex; flex-direction: column; }
.sheet.open { transform: none; }
.sheet.narrow { width: min(560px, 100%); }
.sheet header { padding: 20px 26px; border-bottom: 1px solid var(--line2); display: flex; justify-content: space-between; align-items: center; }
.sheet header h3 { font-size: 24px; }
.sheet .body { flex: 1; overflow: auto; padding: 24px 26px; }
.sheet footer { padding: 16px 26px; border-top: 1px solid var(--line2); display: flex; gap: 10px; justify-content: flex-end; }
.editor { display: grid; grid-template-columns: 1.25fr 1fr; gap: 26px; }
.preview3d { position: sticky; top: 0; height: 560px; border-radius: 18px; background: radial-gradient(circle at 50% 55%, rgba(122, 16, 24, .6), #0d0807 70%); border: 1px solid var(--line2); overflow: hidden; }
.preview3d .hint { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); pointer-events: none; }
.fg { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.fg label { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.s1 { grid-column: span 1; } .s2 { grid-column: span 2; } .s3 { grid-column: span 3; } .s4 { grid-column: span 4; } .s6 { grid-column: span 6; }
.fg h4 { grid-column: span 6; font-family: var(--serif); font-weight: 400; font-size: 17px; color: var(--gold2); margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line2); }
.colors { display: flex; gap: 10px; }
.colors label { flex: 1; }
input[type=color] { width: 100%; height: 40px; border: 1px solid var(--line2); border-radius: 10px; background: none; padding: 3px; cursor: pointer; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.preset { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .1); transition: .2s; }
.preset:hover { transform: scale(1.12); border-color: var(--gold); }

.dialog { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.dialog .card { width: min(520px, 100%); opacity: 0; transform: scale(.95) translateY(20px); transition: .4s var(--ease); max-height: 90vh; overflow: auto; }
.dialog.open { pointer-events: auto; } .dialog.open .card { opacity: 1; transform: none; }

/* organograma */
.org { overflow: auto; padding: 20px 0 40px; }
.tree, .tree ul { display: flex; justify-content: center; padding-top: 26px; position: relative; list-style: none; }
.tree { padding-top: 0; min-width: max-content; margin: 0 auto; }
.tree li { position: relative; padding: 26px 10px 0; display: flex; flex-direction: column; align-items: center; }
.tree li::before, .tree li::after { content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 26px; border-top: 1px solid var(--line); }
.tree li::after { right: auto; left: 50%; border-left: 1px solid var(--line); }
.tree li:only-child::before, .tree li:only-child::after { display: none; } .tree li:only-child { padding-top: 26px; }
.tree > li:only-child { padding-top: 0; }
.tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
.tree li:last-child::before { border-right: 1px solid var(--line); border-radius: 0 10px 0 0; }
.tree li:first-child::after { border-radius: 10px 0 0 0; }
.tree ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 26px; border-left: 1px solid var(--line); }
.tree li:only-child > .node::before { content: ''; position: absolute; top: -26px; left: 50%; height: 26px; border-left: 1px solid var(--line); }
.tree > li:only-child > .node::before { display: none; }
.node { position: relative; background: var(--panel2); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; min-width: 190px; text-align: center; transition: .3s var(--ease); animation: up .6s var(--ease) both; }
.node:hover { border-color: var(--gold); transform: translateY(-3px); box-shadow: 0 16px 30px -16px #000; }
.node .avatar { margin: 0 auto 8px; width: 46px; height: 46px; }
.node b { display: block; font-weight: 500; }
.node small { color: var(--muted); font-size: 11px; }
.node .lvl { position: absolute; top: 10px; right: 10px; font-size: 10px; color: var(--gold); }
.node.off { opacity: .45; }

/* gráfico */
.chart svg { width: 100%; height: 240px; display: block; }
.chart .b { transform-origin: bottom; transform-box: fill-box; animation: grow 1s var(--ease) both; }
@keyframes grow { from { transform: scaleY(0); } }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.list-row:last-child { border: 0; }
.list-row img { height: 52px; }

/* DANFE */
.danfe { background: #fff; color: #111; padding: 24px; border-radius: 10px; font-size: 11px; font-family: Arial, sans-serif; }
.danfe .hd { display: grid; grid-template-columns: 90px 1fr 170px; gap: 12px; border: 1px solid #111; padding: 10px; align-items: center; }
.danfe .hd img { width: 80px; border-radius: 50%; }
.danfe .box { border: 1px solid #111; border-top: 0; padding: 6px 10px; }
.danfe .box b { display: block; font-size: 8px; text-transform: uppercase; color: #555; }
.danfe table td, .danfe table th { border: 1px solid #111; padding: 4px 6px; color: #111; font-size: 10px; }
.danfe .bars { height: 46px; display: flex; gap: 1px; margin: 6px 0; }
.danfe .bars i { background: #111; display: block; }
.danfe .wm { text-align: center; font-weight: 700; color: #b00; border: 2px dashed #b00; padding: 6px; margin: 8px 0; }

.toast { position: fixed; bottom: 24px; right: 24px; z-index: 99; background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--gold); padding: 14px 18px; border-radius: 12px; transform: translateY(150%); transition: .45s var(--ease); max-width: 360px; white-space: pre-line; }
.toast.show { transform: none; } .toast.err { border-left-color: var(--red); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(0, 0, 0, .2); border-top-color: currentColor; border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px; color: var(--muted); }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 70; width: 260px; left: 0; transform: translateX(-100%); transition: .4s var(--ease); }
  .side.open { transform: none; }
  .menu-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line2); border-radius: 10px; }
  .two, .editor { grid-template-columns: 1fr; }
  .preview3d { position: relative; height: 380px; order: -1; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .top .live span { display: none; }
  .fg { grid-template-columns: repeat(2, 1fr); } .fg > * { grid-column: span 2 !important; }
}
@media print { body * { visibility: hidden; } .danfe, .danfe * { visibility: visible; } .danfe { position: absolute; left: 0; top: 0; width: 100%; } }

/* ===================== Distribuidora: novas telas ===================== */
.auth { display: grid; gap: 12px; max-width: 380px; margin: 0 auto; text-align: left; }
.auth .sw { font-size: 12px; }
.danger-kpi b { color: #ff8a80 !important; }
.sellbar { display: grid; grid-template-columns: 150px 1fr 120px; gap: 12px; align-items: center; padding: 8px 0; font-size: 13px; }
.sellbar b { text-align: right; font-weight: 500; color: var(--gold2); }
.sellbar .bar { height: 10px; }
.additem { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.additem select { flex: 1; min-width: 240px; }
.additem input { width: 70px; }
.itab { width: 100%; border-collapse: collapse; }
.itab th { font-size: 10px; }
.itab td { padding: 8px; }
.sm-in { width: 110px; padding: 7px 9px; }
.ordertotal { display: flex; gap: 18px; justify-content: flex-end; align-items: baseline; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line2); color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.ordertotal b { font-family: var(--serif); font-weight: 400; font-size: 24px; color: var(--gold2); }
.timeline { display: grid; gap: 12px; }
.timeline div { position: relative; padding-left: 20px; }
.timeline i { position: absolute; left: 0; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 74, .2); }
.timeline b { display: block; font-weight: 500; font-size: 13px; }
.timeline span { font-size: 11px; color: var(--muted); }
.row-late td:first-child b { color: #ff8a80; }
.row-late { background: rgba(214, 49, 47, .05); }
.linha { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding: 12px; border-radius: 10px; background: rgba(255, 255, 255, .03); border: 1px dashed var(--line); }
.linha .mono { flex: 1; min-width: 260px; word-break: break-all; }
td a.btn { text-decoration: none; }
