:root {
  --ink: #17231f;
  --muted: #62716b;
  --accent: #07543f;
  --accent-strong: #043d2d;
  --accent-soft: #e8f3ee;
  --gold: #b88a22;
  --gold-soft: #fff5d9;
  --bg: #f4f6f1;
  --surface: #fff;
  --surface-quiet: #f9fbf7;
  --border: #d6ded8;
  --danger: #982d2d;
  --danger-bg: #fff0ec;
  --ok: #126243;
  --radius: 8px;
  --container: 1120px;
  --font: "Source Sans 3", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f8f4 0, var(--bg) 18rem);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.brand {
  min-width: 0;
  color: var(--accent);
  text-decoration: none;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 1.15rem;
  line-height: 1.1;
}

.brand small,
.page-head p,
.panel-head p,
.login-brand p,
.empty,
.file-list,
.drop-copy small {
  color: var(--muted);
}

.user-nav {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .95rem;
}

.user-chip {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-nav a,
.download {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: .65rem .8rem;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}

.page {
  max-width: var(--container);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, .78fr);
  gap: 1.25rem;
  align-items: start;
}

.page-head {
  grid-column: 1 / -1;
  max-width: 48rem;
  padding-top: .75rem;
}

.eyebrow {
  margin: 0 0 .3rem;
  color: var(--gold);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .08rem;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--accent);
  line-height: 1.12;
}

h1 { font-size: clamp(2rem, 4vw, 3.2rem); }
h2 { font-size: 1.25rem; }

.upload-panel,
.result-panel,
.login-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(28, 45, 38, .08);
}

.upload-panel,
.result-panel {
  padding: 1.25rem;
}

.panel-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.panel-head p,
.login-brand p,
.page-head p {
  margin: .45rem 0 0;
}

form,
.field,
.upload-field {
  display: grid;
  gap: .75rem;
}

.drop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10rem;
  gap: .85rem;
}

label {
  color: var(--accent-strong);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .72rem .8rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus,
.drop-zone:focus-within {
  border-color: var(--gold);
  outline: 3px solid rgba(184, 138, 34, .2);
  outline-offset: 1px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.drop-zone {
  position: relative;
  min-height: 11rem;
  border: 1px dashed #9db0a6;
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: .85rem;
  background: var(--surface-quiet);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone.is-dragging { transform: translateY(-1px); }

.drop-icon {
  width: 3rem;
  height: 2rem;
  border-radius: var(--radius);
  display: inline-grid;
  place-items: center;
  background: var(--gold-soft);
  color: #6f4d00;
  font-size: .75rem;
  font-weight: 900;
}

.drop-copy strong {
  display: block;
  color: var(--accent-strong);
}

.drop-action {
  justify-self: start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .65rem;
  background: #fff;
  color: var(--accent);
  font-size: .9rem;
  font-weight: 800;
}

.file-list {
  min-height: 2.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  font-size: .9rem;
}

.file-chip {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .35rem .55rem;
  display: inline-flex;
  gap: .4rem;
  align-items: center;
  background: #fff;
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.file-chip.is-valid::before,
.file-chip.is-invalid::before {
  font-weight: 900;
}

.file-chip.is-valid::before {
  content: "OK";
  color: var(--ok);
}

.file-chip.is-invalid {
  border-color: rgba(152, 45, 45, .35);
  color: var(--danger);
}

.file-chip.is-invalid::before { content: "Tipo"; }

button,
.primary {
  min-height: 2.9rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: .78rem 1rem;
}

button:hover,
.primary:hover { background: var(--accent-strong); }

button:disabled {
  cursor: wait;
  opacity: .78;
}

.submit-button { justify-self: start; }

.inventory-panel {
  grid-column: 1 / -1;
}

.inventory-panel form + form,
.form-grid {
  margin-top: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.status {
  grid-column: 1 / -1;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  font-weight: 800;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(152, 45, 45, .25);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.metrics div {
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: .9rem;
  background: var(--surface-quiet);
}

.metrics strong {
  display: block;
  color: var(--accent);
  font-size: 1.8rem;
  line-height: 1;
}

.metrics span { color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: .6rem .4rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--accent-strong);
  font-size: .78rem;
  text-transform: uppercase;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  gap: .25rem;
  background: var(--surface-quiet);
}

.empty strong {
  color: var(--accent);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-shell { width: min(460px, 100%); }

.login-panel {
  padding: 1.4rem;
}

.login-brand {
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

@media (max-width: 900px) {
  .workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .drop-grid,
  .field-row,
  .form-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .download,
  .submit-button {
    width: 100%;
  }

  .brand small {
    display: none;
  }
}

@media (max-width: 360px) {
  .page,
  .header-inner,
  .login-page {
    padding-left: .8rem;
    padding-right: .8rem;
  }

  .upload-panel,
  .result-panel,
  .login-panel {
    padding: 1rem;
  }
}
