@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@500;600;700&family=Source+Sans+3:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --font-body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-heading: "Lexend", "Source Sans 3", system-ui, sans-serif;

  --color-primary: #1e3a5f;
  --color-primary-hover: #16293f;
  --color-secondary: #2563eb;
  --color-accent: #16a34a;
  --color-background: #f8fafc;
  --color-foreground: #0f172a;
  --color-card: #ffffff;
  --color-muted: #eef2f7;
  --color-muted-foreground: #52627a;
  --color-border: #d7dee8;
  --color-destructive: #dc2626;
  --color-ring: #2563eb;

  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --radius: 10px;
}

:root[data-theme="dark"] {
  --color-primary: #3b82f6;
  --color-primary-hover: #2f6fdb;
  --color-secondary: #60a5fa;
  --color-accent: #22c55e;
  --color-background: #0b0f17;
  --color-foreground: #e6edf7;
  --color-card: #131a26;
  --color-muted: #1b2433;
  --color-muted-foreground: #8b98ad;
  --color-border: #263248;
  --color-destructive: #f87171;
  --color-ring: #60a5fa;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3 { font-family: var(--font-heading); }

a { color: var(--color-secondary); }

/* Visible keyboard focus everywhere, without disturbing layout */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
  border-radius: 6px;
}

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

/* ---------- Header ---------- */
header {
  padding: 14px 28px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

header h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--color-foreground);
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--color-muted);
  padding: 4px;
  border-radius: 10px;
  flex-wrap: wrap;
}

.tabbtn {
  border: none;
  background: transparent;
  color: var(--color-muted-foreground);
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tabbtn:hover { color: var(--color-foreground); background: rgba(15, 23, 42, 0.06); }
.tabbtn.active { background: var(--color-primary); color: #fff; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-muted-foreground);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { background: var(--color-muted); color: var(--color-foreground); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.theme-toggle-standalone {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  background: var(--color-card);
}

.user-chip {
  font-size: 13px;
  color: var(--color-muted-foreground);
  padding: 6px 12px;
  background: var(--color-muted);
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Layout ---------- */
main {
  padding: 28px;
  max-width: 1040px;
  margin: 0 auto 80px auto;
}

.login-page main,
main.login-page {
  max-width: 1040px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 26px;
  margin-bottom: 24px;
}
.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 14px;
  color: var(--color-foreground);
}

.login-card {
  max-width: 400px;
  margin: 64px auto;
}
.login-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: -6px 0 20px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; gap: 12px; } }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 14px 0 7px;
}

input, textarea, select {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: inherit;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, textarea:hover, select:hover { border-color: #b7c2d1; }
input:focus, textarea:focus, select:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
input[readonly], textarea[readonly], input:disabled, select:disabled {
  background: var(--color-muted);
  color: var(--color-muted-foreground);
  cursor: not-allowed;
  border-style: dashed;
}
textarea { min-height: 90px; resize: vertical; }
select { cursor: pointer; }

/* ---------- Buttons ---------- */
.btnbar { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

.action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-foreground);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.action:hover { background: var(--color-muted); border-color: #b7c2d1; }
.action.primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.action.primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.action svg { flex-shrink: 0; }

.remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--color-destructive);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  transition: background-color 0.15s ease;
}
.remove:hover { background: rgba(220, 38, 38, 0.1); }

/* ---------- Status bar / badges ---------- */
.status-bar {
  margin-bottom: 24px;
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 14px;
  flex-wrap: wrap;
}
.status-bar .hint { opacity: 0.5; }

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}
.badge-rascunho { background: #fdecea; color: #b3261e; border-color: #f6cbc6; }
.badge-aguardando_validacao { background: #fef3d6; color: #92610a; border-color: #f7e0a1; }
.badge-em_compra_entrega { background: #dfe9fd; color: #1d4ed8; border-color: #bdd2fa; }
.badge-a_pagar { background: #fef3d6; color: #92610a; border-color: #f7e0a1; }
.badge-concluido { background: #dcf5e3; color: #157347; border-color: #b6e6c4; }

:root[data-theme="dark"] .badge-rascunho { background: rgba(248, 113, 113, 0.15); color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }
:root[data-theme="dark"] .badge-aguardando_validacao { background: rgba(251, 191, 36, 0.15); color: #fcd34d; border-color: rgba(251, 191, 36, 0.3); }
:root[data-theme="dark"] .badge-em_compra_entrega { background: rgba(96, 165, 250, 0.15); color: #93c5fd; border-color: rgba(96, 165, 250, 0.3); }
:root[data-theme="dark"] .badge-a_pagar { background: rgba(251, 191, 36, 0.15); color: #fcd34d; border-color: rgba(251, 191, 36, 0.3); }
:root[data-theme="dark"] .badge-concluido { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }

.hint { font-size: 13px; color: var(--color-muted-foreground); }

/* ---------- Misc components ---------- */
.quote-item {
  background: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: 9px;
  padding: 16px;
  margin-bottom: 12px;
}

.history-item {
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--color-card);
}
.h-date { font-size: 12px; color: var(--color-muted-foreground); font-variant-numeric: tabular-nums; }
.h-title { font-weight: 600; font-size: 15px; margin: 2px 0 4px; }
.h-desc { font-size: 13px; color: var(--color-muted-foreground); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--color-muted-foreground);
  text-align: center;
}
.empty-state svg { opacity: 0.5; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

.tabela-pedidos { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tabela-pedidos th {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-muted);
  color: var(--color-muted-foreground);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tabela-pedidos th:first-child { border-top-left-radius: 8px; }
.tabela-pedidos th:last-child { border-top-right-radius: 8px; }
.tabela-pedidos td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--color-border); }
.tabela-pedidos tr:last-child td { border-bottom: none; }
.tabela-pedidos tr[onclick] { cursor: pointer; }
.tabela-pedidos tr[onclick]:hover { background: var(--color-muted); }
.tabela-pedidos tr[onclick]:focus-visible { outline: 2px solid var(--color-ring); outline-offset: -2px; }

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid transparent;
}
.flash-erro { background: #fdecea; color: #8c1d13; border-left-color: var(--color-destructive); }
.flash-sucesso { background: #e3f7ea; color: #0f5c33; border-left-color: var(--color-accent); }
.flash-aviso { background: #fef3d6; color: #6b4a05; border-left-color: #d97706; }

:root[data-theme="dark"] .flash-erro { background: rgba(248, 113, 113, 0.12); color: #fca5a5; }
:root[data-theme="dark"] .flash-sucesso { background: rgba(34, 197, 94, 0.12); color: #86efac; }
:root[data-theme="dark"] .flash-aviso { background: rgba(251, 191, 36, 0.12); color: #fcd34d; border-left-color: #fbbf24; }
