/* Identidade Carbo Clear: grafite da logo + verde da moldura */
:root {
  --bg: #f4f5f6;
  --card: #ffffff;
  --ink: #23272b;
  --ink-2: #3b3f43;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #eef0f2;
  --brand: #3f8a2b;
  --brand-600: #33731f;
  --brand-50: #eef7ea;
  --brand-100: #d9efd0;
  --warn: #93600a;
  --warn-bg: #fff5dc;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --info: #1d4ed8;
  --info-bg: #e8effd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-600); }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Estrutura ── */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
}
.sidebar .logo { display: block; padding: 4px 10px 22px; }
.sidebar .logo img { height: 46px; width: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; border: 0;
  background: none; color: var(--ink-2); font-weight: 500; cursor: pointer; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--line-2); }
.nav-item.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.sidebar .spacer { flex: 1; }
.me { border-top: 1px solid var(--line); padding: 14px 6px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink-2); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who span { font-size: 12px; color: var(--muted); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

.main { min-width: 0; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 26px 32px 18px; }
.page-head h1 { font-size: 22px; margin: 0; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 0 32px 40px; }
.mobile-top { display: none; }

/* ── Cartões e botões ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: start; gap: 12px; }
.card-head h2 { margin: 0; font-size: 15px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-600); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: var(--line-2); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f3c5c0; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.link-btn { background: none; border: 0; color: var(--brand-600); font-weight: 600; cursor: pointer; padding: 0; }

.input, .select, textarea.input {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; background: #fff; min-width: 0; width: 100%;
}
.input:focus, .select:focus { outline: 3px solid var(--brand-100); border-color: var(--brand); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.tag { display: inline-block; background: #eef1f4; border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); font-weight: 500; }
.tag-ca { background: var(--info-bg); color: var(--info); }
.tag-green { background: var(--brand-50); color: var(--brand-600); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-red { background: var(--danger-bg); color: var(--danger); }
.empty { padding: 32px 18px; color: var(--muted); text-align: center; }
.notice { margin: 12px 18px 0; padding: 10px 12px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }

/* ── Início ── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 18px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .label svg { color: var(--brand); }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; margin-top: 8px; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }
.hero { display: flex; align-items: center; gap: 20px; padding: 22px; margin-bottom: 20px;
  background: linear-gradient(120deg, #2b2f33 0%, #3b3f43 60%, #33731f 140%); color: #fff; border: 0; }
.hero h2 { margin: 0 0 4px; font-size: 18px; }
.hero p { margin: 0; opacity: .8; }
.hero .btn { margin-left: auto; background: var(--brand); }
.hero .btn:hover { background: #4b9f35; }

/* ── Nova cotação ── */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.filters { display: flex; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.filters .input { flex: 1 1 240px; width: auto; }
.filters .select { flex: 0 1 240px; width: auto; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; white-space: nowrap; }
.check input { accent-color: var(--brand); }
.product-list { max-height: 62vh; overflow: auto; }
.product { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.product:hover { background: #fafbfb; }
.product.selected { background: var(--brand-50); }
.product input { margin-top: 3px; accent-color: var(--brand); }
.product .desc { font-weight: 600; }
.meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; align-items: center; }
.selected-list { max-height: 52vh; overflow: auto; }
.sel-item { padding: 10px 18px; border-bottom: 1px solid var(--line-2); }
.sel-top { display: flex; gap: 8px; align-items: start; justify-content: space-between; }
.sel-top .desc { font-weight: 600; font-size: 13px; }
.sel-item label { display: block; font-size: 11px; color: var(--muted); margin: 6px 0 3px; text-transform: uppercase; letter-spacing: .4px; }
.sel-item .input { padding: 7px 10px; font-size: 13px; }
.remove { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
.remove:hover { color: var(--danger); }
.panel-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.panel-foot .radius { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.panel-foot .radius .select { width: auto; }
.panel-foot .btn { margin-left: auto; }

/* ── Resultado ── */
.progress { height: 8px; background: #e6e9ec; border-radius: 999px; overflow: hidden; margin: 0 0 20px; }
.progress > div { height: 100%; background: linear-gradient(90deg, #6cc04a, var(--brand)); transition: width .4s; }
.item-card { margin-bottom: 18px; overflow: hidden; }
.item-head { display: flex; gap: 12px; align-items: start; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.item-head h3 { margin: 0; font-size: 15px; }
.status { margin-left: auto; white-space: nowrap; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.st-na_fila { background: #eef1f4; color: var(--muted); }
.st-buscando { background: var(--info-bg); color: var(--info); }
.st-ok, .st-concluida { background: var(--brand-50); color: var(--brand-600); }
.st-erro { background: var(--danger-bg); color: var(--danger); }
.item-msg { padding: 8px 18px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 9px 12px; background: #f8f9fa; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.best td { background: #f4fbf1; }
tr.off td { color: var(--muted); }
.price { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.best-badge { display: inline-block; margin-top: 4px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; }
.store { font-weight: 600; min-width: 190px; max-width: 260px; }
.store small, .loc small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.store .contact { color: var(--ink); margin-top: 4px; }
td.open, td.loc, td.nowrap { white-space: nowrap; }
.ad-title { color: var(--muted); font-size: 12px; min-width: 240px; max-width: 420px; margin-bottom: 4px; }
.chip { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; margin: 2px 4px 2px 0; }
.chip-ok { background: var(--brand-50); color: var(--brand-600); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--danger-bg); color: var(--danger); }
details.more { border-top: 1px solid var(--line); }
details.more summary { padding: 10px 18px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
details.more[open] summary { border-bottom: 1px solid var(--line); }
.no-offer { padding: 14px 18px; color: var(--muted); font-size: 13px; }

/* ── Listas (histórico, últimas) ── */
.list-row { display: flex; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #fafbfb; }
.list-row .num { font-weight: 700; color: var(--brand-600); min-width: 44px; }
.list-row .what { flex: 1; min-width: 0; }
.list-row .what > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }

/* ── Tabelas de gestão ── */
.data td { vertical-align: middle; }
.data td.desc { font-weight: 600; min-width: 260px; }
.data td.desc small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.data .termo { color: var(--muted); font-size: 12px; max-width: 280px; }
.load-more { padding: 12px; text-align: center; border-top: 1px solid var(--line); }

/* ── Modal e aviso ── */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 24, 28, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(0,0,0,.25); max-height: calc(100vh - 32px); overflow: auto; }
.modal-head { padding: 18px 20px 6px; display: flex; align-items: start; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 10px 20px 4px; }
.modal-foot { padding: 14px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: 1px; background: var(--brand-50); color: var(--brand-600); padding: 12px; border-radius: 9px; text-align: center; margin: 8px 0; user-select: all; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 60; max-width: 380px; }
.toast.err { background: var(--danger); }

/* ── Login ── */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: linear-gradient(150deg, #2b2f33 0%, #3b3f43 55%, #2f5f22 130%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: flex-end; }
.login-side h2 { font-size: 28px; line-height: 1.2; margin: 0 0 10px; max-width: 460px; letter-spacing: -.3px; }
.login-side p { opacity: .8; max-width: 440px; margin: 0; }
.login-side .frame { width: 64px; height: 64px; border: 6px solid #6cc04a; border-right-color: transparent; margin-bottom: 28px; }
.login-form-wrap { display: grid; place-items: center; padding: 24px; background: #fff; }
.login-card { width: 100%; max-width: 360px; }
.login-card img { height: 56px; margin-bottom: 28px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.error { background: var(--danger-bg); color: var(--danger); padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .mobile-top img { height: 30px; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head { padding: 18px 16px 12px; }
  .content { padding: 0 16px 32px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: start; }
  .hero .btn { margin-left: 0; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
