:root {
  --bg: #F1F4F6;
  --surface: #FFFFFF;
  --ink: #1B2733;
  --ink-soft: #5B6B79;
  --primary: #1E3A5F;
  --primary-dark: #142942;
  --primary-soft: #E7EDF3;
  --accent: #D9A62E;
  --accent-soft: #FBF1DA;
  --danger: #C0392B;
  --danger-soft: #FBEAE8;
  --success: #2E7D46;
  --success-soft: #E7F4EB;
  --border: #DCE3E9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 41, 66, 0.06), 0 4px 14px rgba(20, 41, 66, 0.06);
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0;
  color: var(--primary-dark);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 15px;
}

a { color: inherit; }

/* ---------- App shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.topbar h1 {
  color: white;
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.topbar .icon-btn {
  color: white;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.icon-btn:hover { background: rgba(0,0,0,0.06); }
.topbar .icon-btn:hover { background: rgba(255,255,255,0.14); }

main.content {
  flex: 1;
  padding: 16px;
  padding-bottom: 90px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Bottom safe area for mobile ---------- */
.bottom-spacer { height: 24px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
}

/* Work-order ticket motif: dashed perforation on top, used for order/venda cards */
.ticket {
  position: relative;
  border-top: none;
  padding-top: 20px;
}
.ticket::before {
  content: "";
  position: absolute;
  top: 0; left: 14px; right: 14px;
  border-top: 2px dashed var(--border);
}

.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--primary-dark);
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.muted { color: var(--ink-soft); font-size: 13px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-accent { background: var(--accent); color: #3A2C05; }

.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }

.btn-danger { background: var(--danger); color: white; }

.btn-full { width: 100%; }

.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

.btn[disabled] { opacity: .45; cursor: not-allowed; }

.fab {
  position: fixed;
  right: 20px;
  bottom: 84px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #3A2C05;
  border: none;
  box-shadow: 0 6px 18px rgba(217,166,46,0.5);
  font-size: 26px;
  cursor: pointer;
  z-index: 15;
}

/* ---------- Forms ---------- */

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
}
.field .suffix-wrap { position: relative; }
.field .suffix-wrap span {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); font-size: 13px;
}

.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap input { padding-left: 38px; }
.search-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft);
}

/* ---------- Stepper (qty +/-) ---------- */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 18px; cursor: pointer; color: var(--primary);
}
.stepper .val { min-width: 24px; text-align: center; font-weight: 600; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 20px;
}
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: #8A6A16; }
.badge-success { background: var(--success-soft); color: var(--success); }

/* ---------- Dashboard grid ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dash-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; text-align: center;
  min-height: 108px; justify-content: center;
}
.dash-tile:hover { border-color: var(--primary); }
.dash-tile .ico { color: var(--primary); }
.dash-tile span { font-size: 13.5px; font-weight: 600; color: var(--ink); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--primary-dark), var(--primary) 60%, var(--bg) 60%);
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-mark {
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--primary); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 28px;
  margin: -56px auto 18px; box-shadow: var(--shadow);
}
.login-card h2 { font-size: 19px; margin-bottom: 4px; }
.login-card p.muted { margin-bottom: 20px; }
.error-text { color: var(--danger); font-size: 13.5px; margin: 6px 0 4px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; text-decoration: none; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px; font-size: 10.5px; font-weight: 600;
  cursor: pointer; background: none; border: none;
}
.bottom-nav a.active { color: var(--primary); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 48px 16px; color: var(--ink-soft);
}
.empty h3 { color: var(--ink-soft); font-size: 16px; margin-bottom: 6px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 25, 38, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
  animation: sheet-up .18s ease-out;
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-sheet h3 { margin-bottom: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 10px 18px; border-radius: 30px;
  font-size: 13.5px; box-shadow: var(--shadow); z-index: 60;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px);} to { opacity:1; transform: translate(-50%,0);} }

/* ---------- Report bars ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-label { width: 78px; font-size: 12px; color: var(--ink-soft); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--primary-soft); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; border-radius: 6px; }
.bar-value { width: 26px; text-align: right; font-size: 12.5px; font-weight: 600; }

/* ---------- Utility ---------- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 700; margin: 18px 0 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.link-btn { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; }

@media print {
  .topbar, .bottom-nav, .fab, .no-print { display: none !important; }
  main.content { padding: 0; max-width: 100%; }
}
