/* ============================================================
   AMG Logistica — Cotacao Rapida de Frete
   Mobile-first. Tokens de marca em :root.
   ============================================================ */

:root {
  --orange: #f26a21;
  --orange-600: #d95a15;
  --orange-700: #b8460f;
  --orange-50: #fff1e8;
  --ink: #262220;
  --muted: #6b6560;
  --line: #e8e3dd;
  --bg: #f7f5f2;
  --card: #ffffff;
  --ok: #1a9c5b;
  --ok-bg: #e5f6ec;
  --err: #d64545;
  --err-bg: #fdecec;
  --warn-bg: #fff5e6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --maxw: 1100px;
  --formw: 620px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.25; color: var(--orange-700); margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 1.25em; }
p { margin: 0 0 1em; }
a { color: var(--orange-600); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Header / footer ---------- */
.site-header { background: var(--card); color: var(--ink); border-bottom: 3px solid var(--orange); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; text-decoration: none; }
.brand__logo { height: 42px; width: auto; display: block; }
.site-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.site-nav a {
  color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 500;
  padding: 8px 10px; border-radius: var(--radius-sm);
}
.site-nav a:hover { background: var(--orange-50); color: var(--orange-700); }

.page { flex: 1 0 auto; padding: 24px 16px 48px; }

.site-footer { background: var(--card); color: var(--muted); border-top: 3px solid var(--orange); padding: 28px 0; margin-top: auto; font-size: .85rem; }
.site-footer__slogan { color: var(--orange-700); font-weight: 700; letter-spacing: .02em; margin-bottom: 12px; }
.disclaimers { margin: 0 0 12px; padding-left: 18px; }
.disclaimers li { margin-bottom: 4px; }
.site-footer__copy { margin: 0; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 20px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.btn--primary { background: var(--orange); color: #fff; }
.btn--primary:hover { background: var(--orange-600); }
.btn--ghost { background: #fff; color: var(--orange-700); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--orange); }
.btn--block { width: 100%; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: .85rem; background: var(--orange-700); color: #fff; }
.btn--sm.btn--ghost { background: #fff; color: var(--orange-700); }
.btn--danger { background: var(--err-bg); color: #a12b2b; border-color: #f2c7c7; }
.btn--danger:hover { background: #f7d7d7; }
.linkbtn { background: none; border: 0; color: var(--orange-600); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

/* ---------- Hero / home ---------- */
.hero {
  background: linear-gradient(160deg, var(--orange), var(--orange-600));
  color: #fff; border-radius: var(--radius); padding: 32px 24px; margin-bottom: 24px;
}
.hero h1 { color: #fff; font-size: 1.8rem; }
.hero p { color: rgba(255, 255, 255, .92); max-width: 46ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.hero .btn--primary { background: #fff; color: var(--orange-700); }
.hero .btn--primary:hover { background: var(--orange-50); }
.hero .btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .55); }
.hero .btn--ghost:hover { border-color: #fff; background: rgba(255, 255, 255, .14); }

.steps { margin-bottom: 24px; }
.steps__list { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 12px; }
.steps__list li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 14px 52px; position: relative; box-shadow: var(--shadow); }
.steps__list li::before {
  content: counter(s); position: absolute; left: 14px; top: 14px;
  width: 26px; height: 26px; border-radius: 50%; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.steps__list strong { display: block; }
.steps__list span { color: var(--muted); font-size: .9rem; }

.benefits { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.benefits div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: var(--shadow); }
.benefits strong { display: block; color: var(--orange-700); }
.benefits span { color: var(--muted); font-size: .85rem; }

/* ---------- Form shell / cards ---------- */
.form-shell { max-width: var(--formw); margin: 0 auto; }
.form-shell--narrow { max-width: 460px; }
.lead { color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card--muted { background: #fafbfc; }
.choice-card { display: block; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.choice-card:hover { border-color: var(--orange); box-shadow: 0 4px 16px rgba(242,106,33,.12); }
.choice-card .btn { pointer-events: none; margin-top: 6px; }
.card--center { max-width: 460px; margin: 24px auto; text-align: center; }
.card--center .stack { margin-top: 16px; }
.stack { display: grid; gap: 10px; }

.notice { background: var(--warn-bg); border: 1px solid #f0d9b5; border-radius: var(--radius-sm); padding: 10px 14px; font-size: .9rem; }
.notice--error { background: var(--err-bg); border-color: #f2c7c7; color: #a12b2b; }
.notice--ok { background: var(--ok-bg); border-color: #bfe6cf; color: #1a7a49; }

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field label, .field__legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--orange); outline-offset: 1px; border-color: var(--orange);
}
.field--error input, .field--error select, .field--error textarea { border-color: var(--err); background: #fff8f8; }
.field-static {
  width: 100%; min-height: 46px; padding: 10px 12px; margin: 0; box-sizing: border-box;
  display: flex; align-items: center; font-weight: 600; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.req { color: var(--err); }
.hint { color: var(--muted); font-size: .8rem; margin: 4px 0 0; }
.error-msg { color: var(--err); font-size: .82rem; margin: 4px 0 0; font-weight: 500; }
.section-title { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }

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

/* segmented Sim/Nao */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.segmented__opt { position: relative; }
.segmented__opt input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__opt span { display: block; padding: 10px 22px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--muted); }
.segmented__opt input:checked + span { background: var(--orange); color: #fff; }
.segmented__opt input:focus-visible + span { outline: 2px solid var(--orange); outline-offset: -2px; }

/* ---------- Stepper / wizard ---------- */
.stepper { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 18px; counter-reset: st; }
.stepper li {
  flex: 1; text-align: center; font-size: .72rem; font-weight: 600; color: var(--muted);
  padding: 8px 4px; border-radius: var(--radius-sm); background: #eef1f5; counter-increment: st;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stepper li::before { content: counter(st) ". "; }
.stepper li.is-active { background: var(--orange); color: #fff; }
.stepper li.is-done { background: var(--ok-bg); color: var(--ok); }

.step { border: 0; padding: 0; margin: 0; }
.step legend { font-weight: 700; font-size: 1.05rem; color: var(--orange-700); margin-bottom: 12px; padding: 0; }
.step-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }
.step-actions .btn { flex: 0 0 auto; }

.notice + .stepper { margin-top: 12px; }

/* ---------- Confirmation / detail ---------- */
.check-mark {
  width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok);
  display: grid; place-items: center; font-size: 2rem; margin: 4px auto 12px;
}
.code-highlight { background: #f1f4f8; border-radius: var(--radius-sm); padding: 12px; font-size: .9rem; color: var(--muted); }
.code-highlight strong { font-size: 1.25rem; color: var(--orange-700); letter-spacing: .02em; }

.detail { max-width: var(--formw); margin: 0 auto; }
.detail__head, .two-col .detail__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; color: var(--muted); margin: 0; }
.detail__foot { margin-top: 8px; }

.kv { display: grid; grid-template-columns: 1fr; gap: 8px 16px; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

.items { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.items td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.items td:last-child { text-align: right; font-weight: 600; }
.items__total td { border-bottom: 0; border-top: 2px solid var(--orange-700); font-size: 1.05rem; color: var(--orange-700); padding-top: 12px; }

.actions-card { display: grid; gap: 14px; }
.adjust summary { cursor: pointer; font-weight: 600; color: var(--orange-600); }
.adjust[open] summary { margin-bottom: 10px; }
.total-preview { background: #f1f4f8; border-radius: var(--radius-sm); padding: 10px 12px; font-size: .95rem; margin: 4px 0 12px; }
.total-preview strong { color: var(--orange-700); }
.total-preview--final { background: var(--orange); color: #fff; }
.total-preview--final strong { color: #fff; }

.decision-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.decision-box h3 { margin-bottom: 8px; }
.reprova-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Quote list (client) ---------- */
.quote-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.quote-list__item a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.quote-list__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.quote-list__route { font-weight: 600; }
.quote-list__meta { color: var(--muted); font-size: .82rem; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.badge--em_analise { background: var(--warn-bg); color: #a5691a; }
.badge--respondida { background: #e4edff; color: #2453b8; }
.badge--negociacao { background: #f3e8ff; color: #7a3ec0; }
.badge--aprovada { background: var(--ok-bg); color: #1a7a49; }
.badge--reprovada { background: var(--err-bg); color: #a12b2b; }
.badge--inativa { background: #eee; color: var(--muted); }
.badge--frete_solicitado { background: #fff0da; color: #a5691a; }
.badge--em_validacao { background: #fff0da; color: #a5691a; }
.badge--oc_emitida { background: #e0f2ff; color: #0f6fa3; }
.badge--enviada_logistica { background: var(--orange-700); color: #fff; }

.badge--aguardando_confirmacao { background: var(--warn-bg); color: #a5691a; }
.badge--programado { background: #e4edff; color: #2453b8; }
.badge--confirmado { background: var(--ok-bg); color: #1a7a49; }
.badge--reagendado { background: #f3e8ff; color: #7a3ec0; }
.badge--carregado { background: var(--orange-700); color: #fff; }
.badge--cancelado { background: var(--err-bg); color: #a12b2b; }

.alerta { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; }
.alerta--HOJE { background: #a12b2b; color: #fff; }
.alerta--AMANHÃ { background: #d95a15; color: #fff; }
.alerta--PRÓXIMO { background: #fff0da; color: #a5691a; }
.alerta--ATRASADO { background: #a12b2b; color: #fff; }

/* ---------- Admin ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.is-active { color: var(--orange-700); border-bottom-color: var(--orange); }
.tab__count { display: inline-block; background: #eef1f5; border-radius: 999px; padding: 1px 8px; font-size: .78rem; margin-left: 4px; }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input, .search-bar select { flex: 1 1 160px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; }
.search-bar input[type="search"] { flex: 2 1 220px; }

.proxima-acao { color: var(--muted); font-size: .85rem; }

/* ---------- Formacao de preco (FC -> margem -> FE) ---------- */
.pricing-block { background: #f7f9fb; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.pricing-block h3 { margin-top: 0; }
.pricing-total { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 8px; font-weight: 700; color: var(--orange-700); }
.pricing-total--final { background: var(--orange); color: #fff; border: 0; }
.pricing-total--final strong { color: #fff; }
.adicional-hint { display: inline-block; background: var(--ok-bg); color: #1a7a49; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.margem-slider { width: 100%; accent-color: var(--orange); height: 22px; margin: 4px 0 14px; cursor: pointer; }

.history-table td, .history-table th { font-size: .82rem; }

/* ---------- Agenda de Carregamentos ---------- */
.agenda-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.calendar-nav h2 { margin: 0; text-transform: capitalize; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar__dow { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; padding-bottom: 4px; }
.calendar__day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); min-height: 92px; padding: 6px; font-size: .78rem; }
.calendar__day--outro-mes { opacity: .4; }
.calendar__day--hoje { border-color: var(--orange); border-width: 2px; }
.calendar__day-num { font-weight: 700; color: var(--orange-700); margin-bottom: 4px; }
.calendar__item { display: block; background: #eef1f5; border-radius: 6px; padding: 3px 5px; margin-bottom: 3px; text-decoration: none; color: var(--ink); font-size: .72rem; line-height: 1.3; }
.calendar__item:hover { background: #e2e6ec; }

@media (max-width: 720px) {
  .calendar { grid-template-columns: repeat(7, minmax(38px, 1fr)); }
  .calendar__day { min-height: 60px; padding: 3px; font-size: .68rem; }
  .calendar__dow { font-size: .6rem; }
}

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; }
.admin-table th { background: #f7f9fb; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.admin-table tr:last-child td { border-bottom: 0; }

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

.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 18px; }
.doc-actions form { margin: 0; }

.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 240px; margin-bottom: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.edit-form { display: flex; gap: 6px; align-items: center; }
.edit-input { min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-weight: 600; width: 100%; max-width: 220px; }
.edit-input:focus { outline: 2px solid var(--orange); outline-offset: 1px; border-color: var(--orange); }

/* ---------- Responsive ---------- */
@media (min-width: 600px) {
  h1 { font-size: 1.75rem; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .benefits { grid-template-columns: repeat(4, 1fr); }
  .page { padding: 32px 16px 56px; }
}

@media (min-width: 1000px) {
  .two-col { grid-template-columns: 1fr 1fr; align-items: start; }
  .steps__list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { border-bottom: 8px solid var(--bg); }
  .admin-table td { border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; }
  .admin-table td::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: .78rem; }
  .admin-table td[data-label=""]::before { content: ""; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
