/* =========================================================
   Sistema de Requisição de Compras — Morais Transportes
   Design system: tokens + layout + componentes
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root{
  /* cor de marca */
  --blue-50:  #eef1fd;
  --blue-100: #dbe3fb;
  --blue-500: #4169E1;
  --blue-600: #3557c9;
  --blue-700: #2F4FBF;
  --blue-900: #1c2f75;

  /* neutros */
  --ink-900: #131A28;
  --ink-700: #2A3444;
  --ink-500: #64748B;
  --ink-300: #A3AEC2;
  --line:    #E2E7F0;
  --surface: #FFFFFF;
  --bg:      #F5F7FB;
  --bg-sunken: #EEF1F8;

  /* status */
  --green:      #16A34A;
  --green-bg:   #E7F7ED;
  --red:        #DC2626;
  --red-bg:     #FCEAEA;
  --amber:      #D97706;
  --amber-bg:   #FDF1DE;
  --blue-info-bg: #E9EEFC;

  /* type */
  --f-display: 'Sora', sans-serif;
  --f-body: 'Inter', sans-serif;
  --f-mono: 'JetBrains Mono', monospace;

  /* layout */
  --sidebar-w: 264px;
  --navbar-h: 68px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(19,26,40,.06);
  --shadow-md: 0 8px 24px -8px rgba(19,26,40,.16);
  --shadow-pop: 0 16px 40px -12px rgba(19,26,40,.28);
}

*,*::before,*::after{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0;
  font-family: var(--f-body);
  background: var(--bg);
  color: var(--ink-900);
  -webkit-font-smoothing:antialiased;
  font-size:14px;
  line-height:1.5;
}
h1,h2,h3,h4{ font-family: var(--f-display); color: var(--ink-900); margin:0; letter-spacing:-0.01em; }
p{ margin:0; }
a{ color:inherit; text-decoration:none; }
ul{ margin:0; padding:0; list-style:none; }
button{ font-family:inherit; cursor:pointer; }
input,select,textarea{ font-family:inherit; font-size:14px; }
code, .mono{ font-family: var(--f-mono); }

:focus-visible{
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===================== LAYOUT SHELL ===================== */
.app-shell{
  display:flex;
  min-height:100vh;
}

/* ---- Sidebar ---- */
.sidebar{
  width: var(--sidebar-w);
  flex-shrink:0;
  background: linear-gradient(180deg,#16224F 0%, #101A3F 100%);
  color: #C9D2EE;
  position:fixed;
  top:0; left:0; bottom:0;
  display:flex;
  flex-direction:column;
  z-index:40;
  transition: transform .25s ease;
}
.sidebar__brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:22px 22px 18px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.sidebar__brand-mark{
  width:36px; height:36px;
  border-radius:10px;
  background: linear-gradient(135deg, var(--blue-500), #7C9BFF);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--f-display); font-weight:800; color:#fff; font-size:15px;
  flex-shrink:0;
}
.sidebar__brand-text b{ display:block; color:#fff; font-family:var(--f-display); font-size:14px; font-weight:700; line-height:1.25;}
.sidebar__brand-text span{ display:block; font-size:11px; color:#8B98C4; margin-top:2px; }

.sidebar__scroll{ flex:1; overflow-y:auto; padding:14px 12px 20px; }
.sidebar__group{ margin-bottom:6px; }
.sidebar__label{
  font-size:10.5px; text-transform:uppercase; letter-spacing:.08em;
  color:#5E6CA0; padding:16px 12px 6px; font-weight:600;
}
.sidebar__link{
  display:flex; align-items:center; gap:11px;
  padding:10px 12px; border-radius:10px;
  color:#B7C1E6; font-size:13.5px; font-weight:500;
  margin-bottom:2px; position:relative;
}
.sidebar__link svg{ width:18px; height:18px; flex-shrink:0; opacity:.85; }
.sidebar__link:hover{ background:rgba(255,255,255,.06); color:#fff; }
.sidebar__link.is-active{ background: var(--blue-500); color:#fff; box-shadow: var(--shadow-sm); }
.sidebar__link.is-active svg{ opacity:1; }
.sidebar__badge{
  margin-left:auto; background:var(--amber); color:#fff; font-size:10.5px;
  font-weight:700; padding:1px 6px; border-radius:20px;
}
.sidebar__footer{
  padding:14px 20px 18px; border-top:1px solid rgba(255,255,255,.08);
  font-size:11px; color:#5E6CA0;
}

/* ---- Main column ---- */
.main{
  margin-left: var(--sidebar-w);
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

/* ---- Navbar ---- */
.navbar{
  height: var(--navbar-h);
  background: var(--surface);
  border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between;
  padding:0 26px;
  position:sticky; top:0; z-index:30;
  gap:16px;
}
.navbar__left{ display:flex; align-items:center; gap:14px; min-width:0; }
.navbar__menu-btn{
  display:none; background:none; border:1px solid var(--line); border-radius:8px;
  width:36px; height:36px; align-items:center; justify-content:center; color:var(--ink-700);
}
.navbar__crumb{ display:flex; flex-direction:column; }
.navbar__crumb small{ color:var(--ink-500); font-size:11.5px; }
.navbar__crumb strong{ font-family:var(--f-display); font-size:16px; font-weight:700; }

.navbar__search{
  display:flex; align-items:center; gap:8px;
  background:var(--bg-sunken); border:1px solid var(--line);
  border-radius:10px; padding:8px 12px; width:280px; color:var(--ink-500);
}
.navbar__search input{ border:none; background:none; outline:none; width:100%; color:var(--ink-900); font-size:13px; }
.navbar__search svg{ width:16px; height:16px; flex-shrink:0; }

.navbar__right{ display:flex; align-items:center; gap:14px; flex-shrink:0; }
.icon-btn{
  width:38px; height:38px; border-radius:10px; border:1px solid var(--line);
  background:var(--surface); display:flex; align-items:center; justify-content:center;
  color:var(--ink-700); position:relative;
}
.icon-btn svg{ width:18px; height:18px; }
.icon-btn .dot{
  position:absolute; top:6px; right:7px; width:7px; height:7px; border-radius:50%;
  background:var(--red); border:2px solid var(--surface);
}
.navbar__user{ display:flex; align-items:center; gap:10px; padding-left:12px; border-left:1px solid var(--line); }
.avatar{
  width:36px; height:36px; border-radius:50%;
  background: linear-gradient(135deg,var(--blue-500),#7C9BFF);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-family:var(--f-display); font-weight:700; font-size:13px; flex-shrink:0;
}
.navbar__user-meta{ line-height:1.25; display:none; }
.navbar__user-meta strong{ display:block; font-size:13px; }
.navbar__user-meta span{ font-size:11.5px; color:var(--ink-500); }

/* ---- content ---- */
.content{ padding:26px; flex:1; }
.page-head{ margin-bottom:22px; display:flex; align-items:flex-end; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.page-head h1{ font-size:22px; }
.page-head p{ color:var(--ink-500); margin-top:4px; font-size:13.5px; }

/* ===================== COMPONENTS ===================== */

/* Buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 16px; border-radius:10px; font-size:13.5px; font-weight:600;
  border:1px solid transparent; transition:.15s ease; white-space:nowrap;
}
.btn svg{ width:16px; height:16px; }
.btn-primary{ background:var(--blue-500); color:#fff; }
.btn-primary:hover{ background:var(--blue-700); }
.btn-secondary{ background:var(--surface); color:var(--ink-700); border-color:var(--line); }
.btn-secondary:hover{ border-color:var(--blue-500); color:var(--blue-500); }
.btn-ghost{ background:transparent; color:var(--ink-500); }
.btn-ghost:hover{ color:var(--ink-900); background:var(--bg-sunken); }
.btn-danger{ background:var(--red-bg); color:var(--red); }
.btn-danger:hover{ background:var(--red); color:#fff; }
.btn-success{ background:var(--green); color:#fff; }
.btn-success:hover{ background:#128a3e; }
.btn-sm{ padding:7px 12px; font-size:12.5px; border-radius:8px; }
.btn-block{ width:100%; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

/* Cards */
.card{
  background:var(--surface); border:1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-pad{ padding:20px; }
.card-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 20px; border-bottom:1px solid var(--line); gap:12px; flex-wrap:wrap;
}
.card-head h3{ font-size:15.5px; font-weight:700; }
.card-head p{ font-size:12.5px; color:var(--ink-500); margin-top:2px; }

/* KPI cards */
.kpi-grid{ display:grid; grid-template-columns:repeat(6,1fr); gap:16px; margin-bottom:24px; }
.kpi{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-md);
  padding:18px; display:flex; flex-direction:column; gap:10px; box-shadow:var(--shadow-sm);
  position:relative; overflow:hidden;
}
.kpi::before{ content:''; position:absolute; left:0; top:0; bottom:0; width:3px; background:var(--kpi-accent, var(--blue-500)); }
.kpi__top{ display:flex; align-items:center; justify-content:space-between; }
.kpi__icon{
  width:34px; height:34px; border-radius:9px; display:flex; align-items:center; justify-content:center;
  background: var(--kpi-bg, var(--blue-50)); color:var(--kpi-accent, var(--blue-500)); flex-shrink:0;
}
.kpi__icon svg{ width:17px; height:17px; }
.kpi__value{ font-family:var(--f-display); font-size:26px; font-weight:800; }
.kpi__label{ font-size:12px; color:var(--ink-500); font-weight:500; }
.kpi__trend{ font-size:11.5px; font-weight:600; }
.kpi__trend.up{ color:var(--green); }
.kpi__trend.down{ color:var(--red); }

/* Tables */
.table-wrap{ overflow-x:auto; }
table.grid{ width:100%; border-collapse:collapse; font-size:13.5px; min-width:640px; }
table.grid thead th{
  text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.05em;
  color:var(--ink-500); font-weight:600; padding:12px 16px; background:var(--bg-sunken);
  border-bottom:1px solid var(--line); white-space:nowrap;
}
table.grid thead th:first-child{ border-top-left-radius:0; }
table.grid tbody td{ padding:13px 16px; border-bottom:1px solid var(--line); vertical-align:middle; color:var(--ink-700); }
table.grid tbody tr:last-child td{ border-bottom:none; }
table.grid tbody tr{ transition:background .12s; }
table.grid tbody tr:hover{ background:var(--bg-sunken); }
table.grid td.num, table.grid th.num{ text-align:right; }
.cell-strong{ color:var(--ink-900); font-weight:600; }
.cell-id{ font-family:var(--f-mono); color:var(--ink-500); font-size:12.5px; }

/* Status pills */
.pill{
  display:inline-flex; align-items:center; gap:6px; padding:4px 10px 4px 8px;
  border-radius:20px; font-size:11.5px; font-weight:600; white-space:nowrap;
}
.pill::before{ content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }
.pill-amber{ background:var(--amber-bg); color:var(--amber); }
.pill-blue{ background:var(--blue-info-bg); color:var(--blue-600); }
.pill-green{ background:var(--green-bg); color:var(--green); }
.pill-red{ background:var(--red-bg); color:var(--red); }
.pill-gray{ background:var(--bg-sunken); color:var(--ink-500); }

/* Forms */
.form-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:16px; }
.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:16px; }
.field label{ font-size:12.5px; font-weight:600; color:var(--ink-700); }
.field label .req{ color:var(--red); }
.field small{ font-size:11.5px; color:var(--ink-500); }
.input, select.input, textarea.input{
  border:1px solid var(--line); border-radius:9px; padding:10px 12px;
  background:var(--surface); color:var(--ink-900); outline:none; transition:.12s;
  width:100%;
}
.input:focus{ border-color:var(--blue-500); box-shadow:0 0 0 3px var(--blue-100); }
textarea.input{ resize:vertical; min-height:80px; }
.input-icon-wrap{ position:relative; }
.input-icon-wrap svg{ position:absolute; left:12px; top:50%; transform:translateY(-50%); width:16px; height:16px; color:var(--ink-500); }
.input-icon-wrap .input{ padding-left:36px; }

.checkbox-row{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--ink-700); }
.checkbox-row input{ width:16px; height:16px; accent-color:var(--blue-500); }

/* Modal */
.modal-overlay{
  position:fixed; inset:0; background:rgba(19,26,40,.5); backdrop-filter:blur(2px);
  display:none; align-items:center; justify-content:center; z-index:100; padding:20px;
}
.modal-overlay.is-open{ display:flex; }
.modal{
  background:var(--surface); border-radius:var(--radius-lg); width:100%; max-width:560px;
  box-shadow:var(--shadow-pop); max-height:88vh; display:flex; flex-direction:column; overflow:hidden;
}
.modal.modal-lg{ max-width:920px; }
.modal__head{ display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--line); }
.modal__head h3{ font-size:16px; }
.modal__close{ width:32px; height:32px; border-radius:8px; border:none; background:var(--bg-sunken); display:flex; align-items:center; justify-content:center; color:var(--ink-500); }
.modal__close:hover{ background:var(--red-bg); color:var(--red); }
.modal__body{ padding:22px; overflow-y:auto; }
.modal__foot{ display:flex; justify-content:flex-end; gap:10px; padding:16px 22px; border-top:1px solid var(--line); background:var(--bg-sunken); }

/* Badges de perfil */
.role-badge{ font-size:11px; font-weight:700; padding:3px 9px; border-radius:6px; }
.role-admin{ background:#1c2f75; color:#fff; }
.role-comprador{ background:var(--blue-100); color:var(--blue-700); }
.role-usuario{ background:var(--bg-sunken); color:var(--ink-700); }

/* Empty state */
.empty{ text-align:center; padding:52px 20px; color:var(--ink-500); }
.empty svg{ width:44px; height:44px; margin-bottom:12px; opacity:.5; }
.empty strong{ display:block; color:var(--ink-900); font-size:14.5px; margin-bottom:4px; font-family:var(--f-display); }

/* Timeline (histórico estilo rastreamento) */
.tracking{ position:relative; padding-left:6px; }
.tracking__item{ position:relative; padding:0 0 26px 34px; }
.tracking__item::before{ /* linha */
  content:''; position:absolute; left:9px; top:22px; bottom:-4px; width:2px; background:var(--line);
}
.tracking__item:last-child::before{ display:none; }
.tracking__node{
  position:absolute; left:0; top:0; width:20px; height:20px; border-radius:50%;
  background:var(--surface); border:2px solid var(--blue-500); display:flex; align-items:center; justify-content:center;
}
.tracking__node.is-done{ background:var(--green); border-color:var(--green); }
.tracking__node.is-done svg{ width:10px; height:10px; stroke:#fff; }
.tracking__node.is-current{ border-color:var(--amber); box-shadow:0 0 0 4px var(--amber-bg); }
.tracking__meta{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.tracking__title{ font-weight:600; color:var(--ink-900); font-size:13.5px; }
.tracking__time{ font-size:11.5px; color:var(--ink-500); font-family:var(--f-mono); }
.tracking__desc{ font-size:12.5px; color:var(--ink-500); margin-top:3px; }

/* Tabs */
.tabs{ display:flex; gap:4px; border-bottom:1px solid var(--line); padding:0 20px; }
.tab{ padding:12px 6px; font-size:13px; font-weight:600; color:var(--ink-500); border-bottom:2px solid transparent; margin-bottom:-1px; }
.tab.is-active{ color:var(--blue-600); border-color:var(--blue-500); }

/* Comparativo de cotações */
.quote-compare{ display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:14px; }
.quote-card{ border:1px solid var(--line); border-radius:var(--radius-md); padding:16px; position:relative; background:var(--surface); }
.quote-card.is-best{ border-color:var(--green); box-shadow:0 0 0 3px var(--green-bg); }
.quote-card.is-approved{ border-color:var(--green); background:var(--green-bg); }
.quote-card__badge{ position:absolute; top:-10px; right:14px; background:var(--green); color:#fff; font-size:10.5px; font-weight:700; padding:3px 9px; border-radius:20px; }
.quote-card__supplier{ font-family:var(--f-display); font-weight:700; font-size:14px; margin-bottom:2px; }
.quote-card__cnpj{ font-family:var(--f-mono); font-size:11px; color:var(--ink-500); margin-bottom:12px; }
.quote-card__price{ font-family:var(--f-display); font-size:22px; font-weight:800; color:var(--blue-700); }
.quote-card__price small{ font-family:var(--f-body); font-size:11px; color:var(--ink-500); font-weight:500; }
.quote-card dl{ margin:12px 0 0; font-size:12px; }
.quote-card .qrow{ display:flex; justify-content:space-between; padding:6px 0; border-top:1px dashed var(--line); }
.quote-card .qrow span:first-child{ color:var(--ink-500); }
.quote-card .qrow span:last-child{ font-weight:600; color:var(--ink-700); }

/* Stepper (nova solicitação) */
.stepper{ display:flex; align-items:center; gap:0; margin-bottom:26px; }
.stepper__step{ display:flex; align-items:center; gap:10px; flex:1; }
.stepper__circle{ width:30px; height:30px; border-radius:50%; background:var(--bg-sunken); color:var(--ink-500); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; flex-shrink:0; }
.stepper__step.is-active .stepper__circle{ background:var(--blue-500); color:#fff; }
.stepper__step.is-done .stepper__circle{ background:var(--green); color:#fff; }
.stepper__label{ font-size:12.5px; font-weight:600; color:var(--ink-500); }
.stepper__step.is-active .stepper__label{ color:var(--ink-900); }
.stepper__line{ flex:1; height:2px; background:var(--line); margin:0 4px; }

/* Login page */
.login-wrap{ min-height:100vh; display:flex; }
.login-aside{
  flex:1.1; background: radial-gradient(circle at 20% 20%, #24337B, #101A3F 65%); position:relative; overflow:hidden;
  display:flex; flex-direction:column; justify-content:space-between; padding:48px; color:#fff;
}
.login-aside__grid{ position:absolute; inset:0; background-image:linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size:36px 36px; mask-image: radial-gradient(circle at 30% 30%, black, transparent 70%); }
.login-aside__route{ position:relative; z-index:1; }
.login-aside__quote{ position:relative; z-index:1; max-width:420px; font-family:var(--f-display); font-size:22px; font-weight:600; line-height:1.35; }
.login-aside__quote span{ display:block; margin-top:14px; font-family:var(--f-body); font-size:13px; font-weight:500; color:#9AA8DA; }
.login-form-side{ flex:1; display:flex; align-items:center; justify-content:center; padding:32px; background:var(--surface); }
.login-box{ width:100%; max-width:380px; }
.login-box .sidebar__brand-mark{ margin-bottom:18px; }

/* Utility */
.flex{ display:flex; } .items-center{ align-items:center; } .justify-between{ justify-content:space-between; }
.gap-8{ gap:8px; } .gap-10{ gap:10px; } .gap-12{ gap:12px; } .gap-16{ gap:16px; }
.mt-4{margin-top:4px;} .mt-8{margin-top:8px;} .mt-16{margin-top:16px;} .mt-24{margin-top:24px;}
.text-muted{ color:var(--ink-500); } .text-sm{ font-size:12.5px; }
.w-full{ width:100%; }
.hide-mobile{ display:initial; }

/* Toast */
.toast-wrap{ position:fixed; top:20px; right:20px; z-index:200; display:flex; flex-direction:column; gap:10px; }
.toast{
  background:var(--ink-900); color:#fff; padding:13px 16px; border-radius:10px; font-size:13px;
  display:flex; align-items:center; gap:10px; box-shadow:var(--shadow-pop); min-width:260px;
  animation: toast-in .25s ease;
}
.toast.success{ background:#0f3d24; }
.toast.error{ background:#4a1414; }
@keyframes toast-in{ from{ opacity:0; transform:translateY(-8px);} to{ opacity:1; transform:translateY(0);} }

/* Overlay para mobile sidebar */
.sidebar-overlay{ display:none; position:fixed; inset:0; background:rgba(19,26,40,.5); z-index:39; }
.sidebar-overlay.is-open{ display:block; }

/* ===================== RESPONSIVE ===================== */
@media (min-width: 900px){
  .navbar__user-meta{ display:block; }
}

@media (max-width: 1100px){
  .kpi-grid{ grid-template-columns:repeat(3,1fr); }
}

@media (max-width: 860px){
  .sidebar{ transform:translateX(-100%); }
  .sidebar.is-open{ transform:translateX(0); }
  .main{ margin-left:0; }
  .navbar__menu-btn{ display:flex; }
  .navbar__search{ display:none; }
  .form-grid{ grid-template-columns:1fr; }
  .login-aside{ display:none; }
  .kpi-grid{ grid-template-columns:repeat(2,1fr); }
}

@media (max-width: 560px){
  .kpi-grid{ grid-template-columns:1fr; }
  .content{ padding:16px; }
  .page-head{ flex-direction:column; align-items:flex-start; }
  .card-head{ flex-direction:column; align-items:flex-start; }
  .modal__foot{ flex-direction:column-reverse; }
  .modal__foot .btn{ width:100%; }
}
