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

:root {
  --blue: #2563EB;
  --violet: #7C3AED;
  --purple: #A855F7;
  --bg: #0F1117;
  --bg-raised: #171922;
  --surface: #2A2E36;
  --surface-hover: #343945;
  --line: rgba(229, 231, 235, 0.10);
  --text: #FFFFFF;
  --text-secondary: #E5E7EB;
  --text-muted: rgba(229, 231, 235, 0.58);
  --gradient: linear-gradient(115deg, var(--blue) 0%, var(--violet) 55%, var(--purple) 100%);
  --good: #34D399;
  --warn: #FBBF24;
  --bad: #F87171;
  --radius: 12px;
  --header-h: 56px;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-secondary);
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Exo 2', 'Inter', sans-serif;
  color: var(--text);
  margin: 0 0 0.35em;
  letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }

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

/* ---------- layout shell ---------- */

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}

.brand {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}
.menu-btn:hover { background: var(--surface); }

.header-spacer { flex: 1; }

.header-empresa {
  font-size: 0.82rem;
  color: var(--text-muted);
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar {
  position: fixed;
  top: var(--header-h);
  left: -100%;
  bottom: 0;
  width: min(280px, 84vw);
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  transition: left 0.18s ease;
  z-index: 39;
  padding: 0.75rem 0 2rem;
}
.sidebar.open { left: 0; }

.nav-group { margin-bottom: 1.1rem; }
.nav-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.4rem 1.1rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { border-left-color: var(--violet); color: var(--text); background: var(--surface); }
.nav-icon { width: 1.1em; text-align: center; opacity: 0.85; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 38;
  display: none;
}
.scrim.open { display: block; }

main.content {
  margin-top: var(--header-h);
  padding: 1.25rem 1rem 5rem;
  max-width: 1080px;
}

body.no-chrome main.content { margin-top: 0; max-width: none; padding: 0; }

@media (min-width: 900px) {
  .menu-btn { display: none; }
  .sidebar { left: 0; }
  .scrim { display: none !important; }
  main.content { margin-left: var(--sidebar-w); padding: 1.75rem 2rem 4rem; }
  .sidebar { width: var(--sidebar-w); }
}

/* ---------- flashes ---------- */

.flash { padding: 0.7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-ok { background: rgba(52, 211, 153, 0.12); color: #6EE7B7; border: 1px solid rgba(52,211,153,0.25); }
.flash-erro { background: rgba(248, 113, 113, 0.12); color: #FCA5A5; border: 1px solid rgba(248,113,113,0.25); }

/* ---------- cards / kpis ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.kpi {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: relative;
  overflow: hidden;
}
.kpi.accent::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient);
}
.kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.kpi-value {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-value.good { color: var(--good); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.bad { color: var(--bad); }
.kpi-sub { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.2rem; }

.section {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.5rem;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.section-title-row h2 { font-size: 1.05rem; margin: 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--gradient); border: none; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.3); color: #FCA5A5; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- tables & lists ---------- */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
table.data th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255,255,255,0.02); }
.empty-state { color: var(--text-muted); padding: 1.5rem 0; text-align: center; font-size: 0.9rem; }

.pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.pill-good { background: rgba(52,211,153,0.14); color: var(--good); }
.pill-warn { background: rgba(251,191,36,0.14); color: var(--warn); }
.pill-bad { background: rgba(248,113,113,0.14); color: var(--bad); }
.pill-muted { background: rgba(229,231,235,0.1); color: var(--text-muted); }

/* ---------- forms ---------- */

.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-field { display: flex; flex-direction: column; gap: 0.35rem; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.form-field .help { font-size: 0.74rem; color: var(--text-muted); }
.form-field input[type=text],
.form-field input[type=number],
.form-field input[type=date],
.form-field input[type=email],
.form-field input[type=password],
.form-field select,
.form-field textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  color: var(--text);
}
.form-field textarea { resize: vertical; min-height: 4.5rem; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: 2px solid var(--violet);
  outline-offset: 1px;
}
.checkbox-field { flex-direction: row; align-items: center; gap: 0.55rem; }
.checkbox-field input { width: 1.05rem; height: 1.05rem; }

.form-actions { margin-top: 1.4rem; display: flex; gap: 0.7rem; }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
}
.login-card .brand { font-size: 1.8rem; display: block; margin-bottom: 0.2rem; }
.login-tag { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.6rem; }

/* ---------- operação diária ---------- */

.op-list { display: flex; flex-direction: column; gap: 0.6rem; }
.op-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
}
.op-order {
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.op-info { flex: 1; min-width: 0; }
.op-name { font-weight: 600; color: var(--text); }
.op-meta { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.op-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.95rem;
  cursor: pointer;
  line-height: 1;
}
.op-btn.active-embarcou { background: rgba(52,211,153,0.18); border-color: rgba(52,211,153,0.4); color: var(--good); }
.op-btn.active-entregue { background: rgba(37,99,235,0.2); border-color: rgba(37,99,235,0.4); color: #93C5FD; }
.op-btn.active-ausente { background: rgba(248,113,113,0.18); border-color: rgba(248,113,113,0.4); color: var(--bad); }
.op-btn.active-cancelado { background: rgba(229,231,235,0.14); border-color: rgba(229,231,235,0.3); color: var(--text-muted); }

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--line);
}
.tab.active { background: var(--gradient); color: #fff; border: none; }

.copy-box {
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.small { font-size: 0.8rem; }
