:root {
  --bg: #1B4D2E;
  --surface: #205A36;
  --surface2: #26693F;
  --line: #3A8354;
  --gold: #F2B93D;
  --gold-light: #FBD776;
  --cream: #F7FBF3;
  --muted: #B7DCC0;
  --muted-dark: #86BE95;
  --green: #4CD07D;
  --teal: #4FC3E0;
  --danger: #F1746A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.font-serif { font-family: Georgia, "Times New Roman", serif; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---- Login ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.login-card img { height: 56px; margin-bottom: 18px; }
.login-card h1 { font-size: 1.25rem; margin: 0 0 4px; color: var(--cream); }
.login-card p.sub { font-size: .875rem; color: var(--muted); margin: 0 0 22px; }
.field-label { display: block; font-size: .75rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--cream);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: .875rem;
  margin-bottom: 16px;
}
.input:focus { outline: none; box-shadow: 0 0 0 2px var(--gold); }
.btn-gold {
  width: 100%;
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-size: .875rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-gold:hover { background: var(--gold-light); }
.btn-gold:disabled { opacity: .6; cursor: default; }
.alert-danger {
  font-size: .8125rem;
  color: var(--danger);
  background: rgba(241,116,106,.1);
  border: 1px solid rgba(241,116,106,.3);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.alert-warn {
  display: flex; align-items: center; gap: 8px;
  font-size: .875rem; color: var(--gold-light);
  background: rgba(242,185,61,.1);
  border: 1px solid rgba(242,185,61,.3);
  border-radius: 6px; padding: 8px 12px; margin-bottom: 16px;
}

/* ---- App shell ---- */
header.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-inner img { height: 44px; }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title h1 { font-size: 1.25rem; margin: 0; letter-spacing: -0.01em; }
.topbar-title p { font-size: .75rem; color: var(--muted); margin: 2px 0 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: .875rem; flex-wrap: wrap; }
.topbar-right .who { color: var(--muted); }
.topbar-right .who span { text-transform: capitalize; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 12px; font-size: .8125rem; transition: color .15s, border-color .15s;
}
.btn-outline:hover { color: var(--cream); border-color: var(--muted-dark); }

main.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.count { font-size: .875rem; color: var(--muted); }

table.pedidos {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: .875rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.pedidos thead tr { background: var(--surface2); color: var(--muted); font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; }
table.pedidos th, table.pedidos td { text-align: left; padding: 12px 16px; vertical-align: top; }
table.pedidos tbody tr { border-top: 1px solid var(--line); }
table.pedidos tbody tr:hover { background: rgba(255,255,255,.03); }

.cliente-btn { background: none; border: none; color: var(--cream); font-family: Georgia, serif; padding: 0; }
.cliente-btn:hover { color: var(--gold-light); }

.filecell-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed var(--line); border-radius: 6px; padding: 12px 8px;
  cursor: pointer; font-size: .75rem; color: var(--muted-dark); transition: .15s;
}
.filecell-empty:hover, .filecell-empty.drag { border-color: var(--gold); background: rgba(242,185,61,.1); color: var(--gold-light); }
.filecell-filled {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: var(--surface2);
}
.filecell-filled .fname { flex: 1; font-size: .75rem; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filecell-filled button { background: none; border: none; color: var(--muted); }
.filecell-filled button:hover.danger { color: var(--danger); }
.filecell-filled button:hover { color: var(--gold-light); }
.filecell-busy { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }

select.status-select {
  background: var(--surface2);
  font-size: .75rem; font-weight: 500;
  border-radius: 999px; padding: 6px 12px;
  border: 1px solid var(--line); color: var(--cream);
}
.status-pendente { color: var(--muted); border-color: var(--muted-dark) !important; }
.status-enviado { color: var(--gold-light); border-color: var(--gold) !important; }
.status-transito { color: var(--teal); border-color: var(--teal) !important; }
.status-entregue { color: var(--green); border-color: var(--green) !important; }

.updated-cell { font-size: .75rem; color: var(--muted-dark); }
.row-del { background: none; border: none; color: var(--muted-dark); }
.row-del:hover { color: var(--danger); }

.empty-state { text-align: center; padding: 80px 0; border: 2px dashed var(--line); border-radius: 8px; color: var(--muted); }
.loading-state { text-align: center; padding: 80px 0; color: var(--muted); }

/* ---- Modais ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  width: 100%; display: flex; flex-direction: column; overflow: hidden;
}
.modal-box.viewer { max-width: 780px; max-height: 85vh; }
.modal-box.users { max-width: 640px; max-height: 85vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-family: Georgia, serif; font-size: 1.1rem; margin: 0; }
.modal-head .actions { display: flex; align-items: center; gap: 12px; }
.modal-head button { background: none; border: none; color: var(--muted); }
.modal-head button:hover { color: var(--cream); }
.modal-body { flex: 1; overflow: auto; padding: 20px; }
.viewer-frame { background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; height: 70vh; }
.viewer-frame img { max-width: 100%; max-height: 100%; border-radius: 4px; }
.viewer-frame iframe { width: 100%; height: 100%; background: var(--cream); border: none; border-radius: 4px; }

.user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 20px; }
.user-form .span2 { grid-column: 1 / -1; }
.user-table { width: 100%; font-size: .875rem; border-collapse: collapse; }
.user-table th { text-align: left; font-size: .6875rem; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.user-table td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.user-table .role-cell { text-transform: capitalize; }
.user-table .del-btn { background: none; border: none; color: var(--muted); float: right; }
.user-table .del-btn:hover { color: var(--danger); }

.hidden { display: none !important; }
