/*
  Compras e Estoque — identidade visual própria.
  Conceito: "ficha de manifesto de armazém" — grafite + âmbar (cor de sinalização
  de depósito/logística), tipografia técnica (Space Grotesk + IBM Plex Mono pra
  dados numéricos), cantos retos, divisórias tracejadas lembrando talão de nota.
  Propositalmente bem diferente do GestãoIM (que é vermelho/branco, cantos
  arredondados) — pra dar de cara que são dois sistemas distintos.
*/

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #1c1917;
  --ink-soft: #78716c;
  --paper: #faf7f2;
  --panel: #ffffff;
  --line: #e2dccd;
  --navy: #21252b;
  --navy-soft: #2f3540;

  --accent: #b45309;
  --accent-soft: #fdf0e0;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.mono, .money, td[data-label*="Custo"], td[data-label*="Qtd"], td[data-label="CNPJ"] {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- Login ---------- */

.login-shell {
  display: flex;
  min-height: 100vh;
}

.login-brand-panel {
  flex: 1.1;
  background:
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255,255,255,0.035) 22px 23px),
    linear-gradient(160deg, var(--navy) 0%, #14161a 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  position: relative;
}
.login-brand-panel::before {
  content: "";
  position: absolute;
  top: 32px; left: 32px; right: 32px; bottom: 32px;
  border: 1px dashed rgba(255,255,255,0.18);
  pointer-events: none;
}
.login-brand-content { max-width: 420px; }
.login-brand-logo {
  width: 56px; height: 56px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 28px;
}
.login-brand-content h2 {
  font-size: 30px;
  color: #fff;
  margin-bottom: 12px;
}
.login-brand-content p {
  color: rgba(255,255,255,0.65);
  font-size: 15px;
  line-height: 1.6;
}

.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  padding: 40px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 28px; }

/* ---------- Formulários ---------- */

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin: 16px 0 6px;
}
label:first-of-type { margin-top: 0; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  margin-bottom: 4px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.btn-primary, .btn-secondary, .btn-small {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  padding: 11px 20px;
}
.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: #000; }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--ink); }

.btn-small {
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  font-size: 12px;
}
.btn-small:hover { background: #92400a; }

.link-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

.error-msg {
  display: none;
  background: var(--danger-soft);
  color: var(--danger);
  border-left: 3px solid var(--danger);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.helptext { font-size: 12px; color: var(--ink-soft); margin: -2px 0 16px; }

/* ---------- Estrutura geral ---------- */

.app-shell { min-height: 100vh; }

.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  border-bottom: 3px solid var(--accent);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
}
.topbar-title {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 17px;
  color: #fff;
}
.topbar-right { display: flex; align-items: center; gap: 18px; font-size: 13px; color: rgba(255,255,255,0.75); }
.topbar-right .link-btn { color: rgba(255,255,255,0.75); }
.topbar-right .link-btn:hover { color: #fff; }

.container { max-width: 1080px; margin: 0 auto; padding: 32px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
  overflow-x: auto;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 18px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title { font-size: 22px; }
.section-sub { color: var(--ink-soft); font-size: 13px; margin: 6px 0 22px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbf9f5;
}
.panel-head h2 { font-size: 15px; }

table { width: 100%; border-collapse: collapse; }
thead tr { background: #fbf9f5; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
tr:last-child td { border-bottom: none; }
.row-actions button {
  background: none; border: none;
  color: var(--accent);
  font-size: 12px; font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  margin-right: 12px;
  padding: 0;
}
.row-actions button.danger { color: var(--danger); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  font-size: 13px;
  border: 1px dashed var(--line);
}

/* ---------- Badges (status) ---------- */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.active { background: #dcfce7; color: #15803d; }
.badge.inactive { background: var(--danger-soft); color: var(--danger); }
.badge.admin { background: var(--navy); color: #fff; }
.badge.user { background: var(--accent-soft); color: var(--accent); }
.badge.warning { background: #fef9c3; color: #854d0e; }
.badge.visit-fresh { background: #dcfce7; color: #15803d; }
.badge.visit-stale { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: #dbeafe; color: #1d4ed8; }

/* ---------- Modais ---------- */

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(28, 25, 23, 0.6);
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-box {
  background: #fff;
  border-radius: 4px;
  border-top: 4px solid var(--accent);
  padding: 28px;
  width: 100%;
  max-width: 460px;
}
.modal-box h3 { font-size: 18px; margin-bottom: 18px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 4px;
}

/* ---------- Itens do pedido de compra ---------- */
.order-item-row {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fbf9f5;
  position: relative;
}
.order-item-row .item-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.order-item-row input {
  margin-bottom: 0;
  font-size: 13px;
  padding: 8px 10px;
}
.order-item-row .item-costs {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.order-item-row .item-costs strong { color: var(--accent); }
.order-item-row .remove-item-btn {
  background: none; border: none; color: var(--danger);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 12px; text-decoration: underline; padding: 0;
}

/* ---------- Responsivo ---------- */

@media (max-width: 720px) {
  .login-shell { flex-direction: column; }
  .login-brand-panel { padding: 32px 24px; }
  .container { padding: 20px 16px; }
  .topbar { padding: 12px 16px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  td {
    border: none;
    padding: 4px 20px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ink-soft);
    font-size: 11px;
    text-transform: uppercase;
  }
  .order-item-row .item-fields { grid-template-columns: 1fr; }
}
