/* FLIPR — painel administrativo */
:root {
  --orange: #ff5a0a;
  --orange-600: #e84d00;
  --orange-50: #fff3ec;
  --ink: #15181c;
  --ink-2: #2d3238;
  --muted: #69707a;
  --line: #e5e7eb;
  --bg: #f4f5f7;
  --side: #0f1114;
  --ok: #15803d; --ok-bg: #e8f6ee;
  --warn: #b45309; --warn-bg: #fdf3e2;
  --bad: #b91c1c; --bad-bg: #fdecec;
  --info: #1d4ed8; --info-bg: #e9effd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 18, 20, .04), 0 4px 16px rgba(16, 18, 20, .05);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --display: 'Manrope', var(--font);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
.content a:not(.btn):not(.icon-btn) { color: var(--orange-600); }
.content a:not(.btn):not(.icon-btn):hover { text-decoration: underline; }
.table a:not(.btn):not(.icon-btn) { color: var(--ink); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.015em; line-height: 1.2; margin: 0 0 .6em; }
h2 { font-size: 17px; }
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 28px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.inline { display: inline; }

/* ------------------------------------------------ estrutura */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); color: #b4bac0; padding: 18px 14px; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; }
.side-brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; background: #fff; }
.side-brand span { font-family: var(--display); font-weight: 800; font-size: 17px; line-height: 1.1; }
.side-brand small { display: block; font-family: var(--font); font-weight: 500; font-size: 12px; color: #8a9097; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; font-weight: 500; transition: background .15s, color .15s; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.active { background: rgba(255, 90, 10, .14); color: #fff; }
.side-nav a.active .icon { color: var(--orange); }
.side-nav span { flex: 1; }
.pill { min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--orange); color: #fff; font-size: 12px; text-align: center; }
.side-sep { margin: 18px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #6a7077; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 8px 2px; border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 14px; }
.side-user div { flex: 1; min-width: 0; }
.side-user strong { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user small { font-size: 12px; }
.side-user button { background: none; border: 0; color: #8a9097; cursor: pointer; padding: 6px; border-radius: 8px; }
.side-user button:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.avatar { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--orange); color: #fff; font-weight: 800; font-family: var(--display); }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; min-height: 66px; padding: 12px 32px; background: rgba(244, 245, 247, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 21px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 0; cursor: pointer; padding: 6px; }
.content { padding: 26px 32px 60px; max-width: 1360px; }

/* ------------------------------------------------ componentes */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 1px solid transparent; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-600); }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-ghost:hover { border-color: #c8cdd3; }
.btn-danger-ghost { background: #fff; border-color: #f3c4c4; color: var(--bad); }
.btn-danger-ghost:hover { background: var(--bad-bg); }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13.5px; }
.btn-xs { min-height: 28px; padding: 3px 9px; font-size: 12.5px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; vertical-align: middle; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(255, 90, 10, .35); outline-offset: 2px; }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-mute { background: #eceef1; color: var(--muted); }
.alert { padding: 12px 16px; border-radius: 11px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: #14532d; border-color: #c4e8d2; }
.alert-error { background: var(--bad-bg); color: #7f1d1d; border-color: #f6caca; }
.alert-info { background: var(--info-bg); color: #1e3a8a; border-color: #cbd8f8; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head p { margin: 4px 0 0; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; margin-bottom: 20px; }
.sticky { position: sticky; top: 86px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); transition: border-color .15s; }
a.stat:hover { border-color: #c8cdd3; }
.stat span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stat strong { display: block; font-family: var(--display); font-size: 28px; margin: 6px 0 2px; }
.stat small { color: var(--muted); font-size: 12.5px; }
.stat-alert { border-color: #ffc9ad; background: linear-gradient(135deg, #fff, var(--orange-50)); }
.stat-alert strong { color: var(--orange-600); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 14px; border-bottom: 2px solid transparent; font-weight: 600; color: var(--muted); white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-color: var(--orange); }
.tabs b { font-weight: 600; font-size: 12px; background: #e9ebee; border-radius: 99px; padding: 1px 7px; margin-left: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.search { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; max-width: 460px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); }
.search:focus-within { border-color: var(--orange); }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; background: none; color: var(--ink); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
.table td { padding: 11px 10px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 2px solid var(--line); font-weight: 600; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: #fbfbfc; }
.num { text-align: right !important; }
.thumb-cell { width: 56px; }
.thumb { width: 48px; height: 48px; border-radius: 9px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.pagination { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 16px; }
.pagination a { min-width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; color: var(--ink) !important; text-decoration: none !important; }
.pagination a.active { background: var(--ink); color: #fff !important; border-color: var(--ink); }

/* ------------------------------------------------ formulários */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; gap: 24px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-grid .field { margin-bottom: 0; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.label { display: block; margin-bottom: 8px; }
.field label small { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea, .inline-form input, .inline-form select, .doc-row input, .spec-row input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid #d6dade; border-radius: 9px; background: #fff; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .inline-form input:focus, .inline-form select:focus, .spec-row input:focus, .doc-row input:focus { outline: 0; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 90, 10, .12); }
.field input:disabled { background: var(--bg); color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--orange); }
.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; width: 38px; height: 22px; border-radius: 99px; background: #cfd4d9; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--orange); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 3px solid rgba(255, 90, 10, .35); outline-offset: 2px; }
.input-prefix { display: flex; align-items: center; border: 1px solid #d6dade; border-radius: 9px; background: #fff; overflow: hidden; }
.input-prefix:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 90, 10, .12); }
.input-prefix span { padding: 0 0 0 10px; color: var(--muted); font-size: 13px; }
.input-prefix input { border: 0 !important; box-shadow: none !important; min-height: 38px; padding: 6px 10px 6px 6px; width: 100%; text-align: right; outline: 0; }
.money-field { margin-bottom: 10px; }
.price-grid td { padding: 6px 8px; }
.price-grid .input-prefix { width: 140px; margin-left: auto; }
.price-grid .input-prefix.changed { border-color: var(--orange); background: var(--orange-50); }
.price-grid .input-prefix.changed input { background: transparent; }
.sticky-bottom { position: sticky; bottom: 0; background: #fff; padding: 14px 0 2px; justify-content: space-between; border-top: 1px solid var(--line); }
.sticky-bottom .pagination { margin: 0; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form select { flex: 2; min-width: 220px; }
.inline-form input { flex: 1; min-width: 150px; width: auto; }
.note { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: #fafbfc; border: 1px solid var(--line); font-size: 14px; }
.cnpj-result { margin-bottom: 16px; padding: 12px 14px; border-radius: 10px; background: var(--info-bg); color: #1e3a8a; font-size: 13.5px; }
.cnpj-result.bad { background: var(--bad-bg); color: #7f1d1d; }

.spec-rows { display: flex; flex-direction: column; gap: 8px; }
.spec-row { display: grid; grid-template-columns: 22px 1fr 1.4fr 32px; gap: 8px; align-items: center; background: #fff; border-radius: 9px; }
.spec-row.dragging { opacity: .5; }
.drag { cursor: grab; color: #a2a8ae; font-size: 13px; letter-spacing: -2px; text-align: center; user-select: none; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 14px; }
.image-grid:empty { display: none; }
.image-tile { position: relative; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--bg); }
.image-tile img { width: 100%; height: 150px; object-fit: contain; background: #fff; }
.image-tile .badge { position: absolute; top: 8px; left: 8px; }
.image-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; }
.dropzone { display: flex; align-items: center; justify-content: center; text-align: center; padding: 22px; border: 2px dashed #d3d8dd; border-radius: 12px; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; position: relative; }
.dropzone:hover, .dropzone.over { border-color: var(--orange); background: var(--orange-50); }
.dropzone.small { padding: 14px; margin-top: 8px; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone span { display: inline-flex; align-items: center; gap: 8px; }
.dropzone strong { color: var(--ink); }
.curve-preview { max-height: 160px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; object-fit: contain; background: #fff; }
.doc-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--orange-600); }
.dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.dl-row { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 9px 0; border-bottom: 1px solid #eef0f2; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list span { width: 100%; color: var(--muted); font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 16px 8px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 3px solid var(--orange); }
.timeline p { margin: 5px 0 0; }

/* ------------------------------------------------ login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(700px 400px at 80% 0%, rgba(255, 90, 10, .2), transparent 60%), #0f1114; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 34px 32px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); }
.login-logo { height: 58px; margin-bottom: 20px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card .muted { margin: 0 0 22px; }
.login-back { display: block; text-align: center; margin-top: 18px; color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------ responsivo */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
  .side.open { transform: none; }
  .menu-btn { display: block; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .content { padding: 18px 16px 50px; }
  .grid-main, .grid-2, .form-grid-2 { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .stats, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar h1 { font-size: 18px; }
  .card { padding: 16px; }
  .spec-row { grid-template-columns: 1fr 32px; }
  .spec-row .drag { display: none; }
  .spec-row input:nth-of-type(2) { grid-column: 1; }
}
@media print {
  .side, .topbar, .no-print, .btn { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .grid-main { grid-template-columns: 1fr; }
  .card { box-shadow: none; border: 0; padding: 0 0 16px; }
  body { background: #fff; }
}
