:root{
  --cor-ivory: #F6F7EB;
  --cor-branco-cinza: #c5cfd9;
  --cor-branco-GM: #efefed;
  --cor-cinza:#7E7F83;
  --cor-cinza-600: #9fa0a2;
  --cor-cinza-GM: #a0a0a0; 
  --cor-azul:#1a365b;
  --cor-azul-bg: #0000001c;
  --cor-carvao-ford: #353535;

  --bdr-sm: 6px;
  --bdr-md: 8px;
  --bdr-lg: 10px;

  --cor-tabela-zebra: #f7f7f5;
  --cor-tabela-hover: #eeeeed;
  --cor-tabela-header-texto: #ffffff;
  --cor-borda: #e5e7eb;
}

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "DM Sans";
}

body{
  background-color: var(--cor-azul-bg);
  overflow-x: hidden;
}

header{
  background-color: var(--cor-azul);
  color: var(--cor-branco-GM);
  padding: 0.6rem 1rem 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header > div{
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

#btn-logout {
  color: var(--cor-branco-GM);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.75;
  transition: opacity 0.15s;
  white-space: nowrap;
}
#btn-logout:hover { opacity: 1; }

#logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

#logo-link > span{
  padding-left: 0.8rem;
  font-weight: 600;
}


#logo{
  width:130px;
  height:40px;
}

main {
  display: flex;
  gap: 1.5rem;
  padding: 0 1.5rem 0 1.5rem;
  align-items: flex-start;
}

#container-fluxo{
  flex: 2;              
  min-width: 0;       
  height: auto;     
  min-height: calc(100vh - 60px);
}

#container-exibicoes {
  flex: 0 0 260px;         
  display: flex;
  flex-direction: column; 
  position: sticky;
  top: 1.5rem;    
}

#nav-header{
  display: flex;
  width: 100vw;
  padding: 2rem 0 0 2.5rem;
  align-items: center;
}

#nav-pages{
  display: flex;
  list-style-type: none;
  margin-bottom: .8rem;
  gap: 2rem;
}

#nav-pages > li > a{
  text-decoration: none;
}

#nav-pages > li > a:link,
#nav-pages > li > a:visited{
  color: #353535;
  font-weight: 600;
}

#nav-pages > li > a.ativo {
  color: var(--cor-branco-GM);
  background-color: var(--cor-azul);
  padding: 4px 12px;
  border-radius: var(--bdr-sm);
}

#bloco-form{
  background: var(--cor-branco-GM);
  display: flex;
  gap: 1.5rem;
  border: 1px solid #7070701e;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  align-items: flex-start;
  border-radius: var(--bdr-sm);
  padding: 1rem;
}

.form-dados{
  flex: 1;
  min-width: 0;
  max-width: 42vw;
  background-color: var(--cor-branco-GM);
}

.bloco-tabela{
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  flex:2;
  gap: 32px;
}

#precificacao{
  background-color: #dfdfdf;
  padding: 1.25rem;
  border-radius: var(--bdr-sm);
}

.ideal{
  background-color: #ffffff !important;
}

.form-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  margin-bottom: 6px;
  font-size: 1rem;
  font-weight: 600;
  color: #444;
}

input,
select,
textarea {
  padding: 12px;
  border: 1px solid #dcdfe4;
  border-radius: 10px;
  font-size: 1rem;
  transition: 0.2s;
  background: #fafafa;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #3b82f6;
  background: white;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

#btn-submit{
  background-color: var(--cor-carvao-ford);
  padding: 12px 30px 12px 30px;
  margin-top: 1rem;
  width: 30%;
  color: #F6F7EB;
  font-size: 1rem;
  border-radius: var(--bdr-sm);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease-in-out;
}

#btn-submit:hover {
  background: #414141;
}

.input-money {
  display: flex;
  align-items: center;
  border: 1px solid #dcdfe4;
  border-radius: 10px;
  background: #fafafa;
  overflow: hidden;
}

.input-money span {
  padding: 0 12px;
  background: #eef2f7;
  color: #555;
  font-weight: bold;
  border-right: 1px solid #dcdfe4;
}

.input-money input {
  border: none;
  background: transparent;
  flex: 1;
  padding: 12px;
}

.input-money input:focus {
  outline: none;
}

.input-money:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

table {
  margin-top: 0;
  width: 100%;
  border-collapse: collapse;
  font-family: "DM Sans";
}

#tab-registros {
  overflow-y: auto;
  flex: 1;
  min-width: 0;
  max-height: 400px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

th, td {
  padding: 10px 14px;
  text-align: left;
}

th {
  background-color: var(--cor-carvao-ford);
  color: var(--cor-tabela-header-texto);
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

th:first-child { border-radius: var(--bdr-sm) 0 0 0; }
th:last-child  { border-radius: 0 var(--bdr-sm) 0 0; }

tbody td {
  border-bottom: 1px solid var(--cor-borda);
  color: var(--cor-carvao-ford);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:nth-of-type(even) {
  background-color: var(--cor-tabela-zebra);
}

tbody tr:hover {
  background-color: var(--cor-tabela-hover);
  cursor: pointer;
}

.card-resumo {
  flex: 1;
  min-width: 140px;
  background-color: var(--cor-branco-GM);
  border-radius: var(--bdr-md);
  padding: 1.5rem 1.8rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.card-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--cor-cinza);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-valor {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--cor-azul);
}

/* cor diferente por card */
#card-entradas .card-valor { color: #16a34a; }
#card-saidas   .card-valor { color: #dc2626; }
#card-balanco  .card-valor { color: var(--cor-azul); }
#card-total    .card-valor { color: var(--cor-carvao-ford); }

.icons{
  text-align: center;
  font-size: 1.3rem;
  margin: 0;
  padding: 0;
}

#calculadora-precificacao {
  margin-top: 1.5rem;
}

#resultados-margem {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.2rem;
}

#resultados-margem .card-valor {
  cursor: pointer;
  transition: color 0.2s;
}

#resultados-margem .card-valor.copiado {
  color: #16a34a;
}

#resultados-margem .card-valor.copiado::after {
  content: ' ✓';
  font-size: 1.5rem;
}

/* ── Bottom sheet ── */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.overlay-acoes {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  align-items: flex-end;
}

.overlay-acoes.aberto {
  display: flex;
}

.sheet-acoes {
  background: white;
  width: 100%;
  border-radius: var(--bdr-lg) var(--bdr-lg) 0 0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slideUp 0.22s ease-out;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--cor-borda);
}

.sheet-descricao {
  font-weight: 600;
  font-size: 1rem;
  color: var(--cor-carvao-ford);
}

.sheet-valor {
  font-weight: 600;
  font-size: 1rem;
  color: var(--cor-azul);
}

.sheet-botoes {
  display: flex;
  gap: 1rem;
}

.btn-sheet {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--bdr-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-editar {
  background-color: var(--cor-azul);
  color: white;
}

.btn-editar:hover { background-color: #1e3f6e; }

.btn-excluir {
  background-color: #dc2626;
  color: white;
}

.btn-excluir:hover { background-color: #b91c1c; }

.btn-fechar-sheet {
  background: none;
  border: 1px solid var(--cor-borda);
  border-radius: var(--bdr-md);
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--cor-cinza);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-fechar-sheet:hover { background-color: var(--cor-branco-GM); }

@media (min-width: 768px) {
  .overlay-acoes {
    align-items: center;
    justify-content: center;
  }

  .sheet-acoes {
    width: 400px;
    border-radius: var(--bdr-lg);
    animation: fadeIn 0.15s ease-out;
  }
}

@media (max-width: 767px) {
  main{
    flex-direction: column;
    padding: 0 1rem;
  }

  #logo{
    width: auto;
    height: auto;
    max-height: 28px;
    max-width: 110px;
  }

  header > div {
    justify-content: flex-start;
  }

  #logo-link > span{
    padding: 0 0.8rem;
    font-size: 0.95rem;
  }

  #nav-header{
    width: 100%;
    max-width: 100%;
    padding: 12px 1rem 0;
    justify-content: flex-start;
    align-items: center;
  }

  #nav-pages{
    gap: 1.4rem;
  }

  .form-dados{
    max-width: 100%;
  }

  .card-resumo{
    padding: 8px;
    align-items: center;
    flex: 1;
    min-width: 140px;
  }
  
  .card-valor{
    font-size: 1.3rem;
  }

  .icons{
    display: flex;
    justify-content: center;
    align-items: center;
  }

  #btn-submit{
    width: 100%;
  }

  #tab-registros{
    overflow-x: auto;
    position: relative;
  }

  #tab-registros::after{
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.08));
    pointer-events: none;
  }

  #bloco-form{
    align-items: stretch;
    justify-content: center;
    flex-direction: column;
    margin-right: 1rem;
  }
  
  #container-fluxo{
    max-width: clamp(360px, 100vw, 390px);
  }

  #container-exibicoes {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0 16px 80px 16px;
    gap: 10px;
  }

  #resultados-margem {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media(min-width: 768px) and (max-width: 880px) and (orientation:landscape){
  
  main {
    flex-direction: column;
    padding: 0 1rem;
  }

  #container-fluxo {
    min-height: auto;
    width: 100%;
  }

  #bloco-form {
    flex-direction: column;
    align-items: stretch;
  }

  .form-dados {
    max-width: 100%;
  }

  #container-exibicoes {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    flex: unset;
    width: 100%;
    gap: 1rem;
  }

  .card-resumo {
    padding: 0.8rem 1rem;
    min-width: 120px;
  }

  .card-valor {
    font-size: 1.2rem;
  }
}

@media (min-width: 768px) and (max-width: 880px) and (orientation: portrait) {
  main {
    flex-direction: column;
    padding: 0 1rem;
  }

  #container-fluxo {
    min-height: auto;
    width: 100%;
  }

  #bloco-form {
    flex-direction: column;
    align-items: stretch;
  }

  .form-dados {
    max-width: 100%;
  }

  #container-exibicoes {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    flex: unset;
    width: 100%;
    gap: 1rem;
  }
}


@media (min-width: 881px) and (max-width: 1024px) {
  #container-fluxo{
    flex: 3;
  }
  #container-exibicoes {
    flex: 0 0 220px; 
  }

  .form-container {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .card-resumo {
    padding: 1rem 1.2rem;
  }

  #resultados-margem {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .card-valor {
    font-size: 1.3rem;
  }

  #btn-submit{
    width: 100%;
  }
}