/* Modern Corporate / ERP Design System - IVA Digital */

:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1e293b;
  background: #f0f4f8;
  --brand-primary: #007a5e;
  --brand-primary-hover: #00634c;
  --brand-navy: #14213d;
  --brand-blue: #194c70;
  --brand-blue-hover: #123752;
  --surface-white: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-accent: #edf8f5;
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-dashed: #94a3b8;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 24px 0;
  background-color: #f0f4f8;
}

main {
  width: min(1440px, calc(100% - 48px));
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  background: var(--surface-white);
  border-top: 6px solid var(--brand-primary);
  border-radius: 0 0 8px 8px;
  padding: 32px 42px 48px;
  box-shadow: 0 10px 30px rgba(20, 33, 61, 0.07), 0 1px 3px rgba(20, 33, 61, 0.04);
}

/* ERP Header Navigation Tabs */
nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-light);
}

nav a {
  padding: 9px 18px;
  color: var(--brand-blue);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  background: var(--surface-subtle);
  transition: all 0.15s ease;
}

nav a:hover {
  background: var(--surface-accent);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

nav a[aria-current="page"] {
  color: #ffffff;
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  box-shadow: 0 2px 5px rgba(20, 33, 61, 0.18);
}

.logout {
  margin-left: auto;
  color: var(--text-subtle);
  border-color: var(--border-light);
}

.logout:hover {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error);
}

/* Typography & Headings */
h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.page-desc {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 10px 0 22px;
  line-height: 1.55;
  max-width: 1000px;
}

p {
  line-height: 1.55;
  color: var(--text-muted);
}

/* Authentication / Login */
.access-token {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: min(100%, 420px);
  margin: 22px 0;
  font-weight: 600;
  color: var(--text-main);
}

.access-token input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-main);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.access-token input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 94, 0.15);
}

.login-main {
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(100%, 440px);
  background: var(--surface-white);
  padding: 36px 32px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  box-shadow: 0 8px 25px rgba(20, 33, 61, 0.08);
}

/* Step-by-Step Helper Guide Strip */
.help-guide {
  margin: 20px 0 24px;
  padding: 16px 20px;
  background: var(--surface-subtle);
  border: 1px solid #dbe7e2;
  border-left: 4px solid var(--brand-primary);
  border-radius: 4px;
}

.help-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.step-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-badge {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.step-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.step-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.step-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.step-desc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #e6f1ed;
  color: #0b5541;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Drop Zones & File Upload */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 22px 0 18px;
  padding: 30px 20px;
  border: 2px dashed var(--border-dashed);
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-subtle);
  transition: all 0.15s ease;
}

.drop-zone:hover,
.drop-zone.drag {
  background: var(--surface-accent);
  border-color: var(--brand-primary);
}

.drop-zone.has-file {
  background: #f0faf7;
  border-color: var(--brand-primary);
  border-style: solid;
}

.drop-zone.is-processing {
  cursor: wait;
  opacity: 0.7;
}

.drop-icon {
  color: var(--brand-primary);
  opacity: 0.85;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.drop-zone:hover .drop-icon,
.drop-zone.drag .drop-icon {
  transform: translateY(-2px);
  opacity: 1;
}

input[type="file"] {
  display: none;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 18px 0;
}

.file-grid .drop-zone {
  margin: 0;
  min-height: 140px;
}

/* Actions & Buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 22px 0 10px;
}

button, .button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--brand-primary);
  color: #ffffff;
  padding: 11px 22px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 122, 94, 0.25);
  transition: all 0.15s ease;
}

button:hover:not(:disabled), .button:hover {
  background: var(--brand-primary-hover);
  box-shadow: 0 3px 6px rgba(0, 122, 94, 0.3);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button.secondary, .button.secondary {
  background: var(--brand-blue);
  box-shadow: 0 1px 3px rgba(25, 76, 112, 0.25);
}

button.secondary:hover:not(:disabled) {
  background: var(--brand-blue-hover);
  box-shadow: 0 3px 6px rgba(25, 76, 112, 0.3);
}

button:disabled {
  background: var(--border-medium);
  color: var(--text-subtle);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Feedback, Status & Notices */
.status {
  min-height: 1.5em;
  margin: 16px 0 0;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--brand-primary);
}

.status.error {
  color: var(--error);
}

.status.processing::before {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: status-spinner 0.7s linear infinite;
}

@keyframes status-spinner {
  to { transform: rotate(360deg); }
}

small {
  color: var(--text-subtle);
  font-size: 0.85rem;
}

.notice {
  margin: 18px 0;
  padding: 14px 18px;
  border: 1px solid var(--warning-border);
  border-left: 4px solid var(--warning);
  border-radius: 4px;
  background: var(--warning-bg);
  color: #78350f;
  font-size: 0.9rem;
}

.notice strong {
  color: #451a03;
}

.notice ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

/* Results & KPI Summary Cards */
.results {
  margin-top: 36px;
  border-top: 1px solid var(--border-light);
  padding-top: 24px;
}

.results[hidden], .downloads[hidden] {
  display: none;
}

.results h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 32px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.results h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--brand-primary);
  border-radius: 2px;
}

#period {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 8px 0 16px;
  padding: 8px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  display: inline-block;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 0 24px;
}

.summary span {
  background: var(--surface-white);
  border: 1px solid var(--border-medium);
  border-left: 4px solid var(--brand-primary);
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: inline-flex;
  align-items: center;
}

/* Modern Corporate ERP Data Tables */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  max-height: 65vh;
  box-shadow: 0 2px 6px rgba(20, 33, 61, 0.04);
  background: var(--surface-white);
  margin: 14px 0 28px;
  position: relative;
}

.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

table {
  width: 100%;
  min-width: 1050px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

th, td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: middle;
}

/* Header: Corporate Navy */
th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 2px solid var(--brand-primary);
}

/* Tabular numbers for financial precision */
td.number, th.number {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
}

/* Zebra striping */
tbody tr:nth-child(even) {
  background: var(--surface-subtle);
}

tbody tr:hover {
  background: var(--surface-accent) !important;
  transition: background-color 0.12s ease;
}

/* Sticky accounting footer */
tfoot {
  position: sticky;
  bottom: 0;
  z-index: 5;
  font-weight: 700;
  background: var(--surface-accent);
  box-shadow: 0 -2px 6px rgba(0, 122, 94, 0.08);
}

tfoot td {
  border-top: 2px solid var(--brand-primary);
  border-bottom: none;
  color: #0b4737;
  font-size: 0.92rem;
  padding: 12px 14px;
}

.detail {
  display: block;
  font-size: 0.8rem;
  color: #334155;
  padding: 1px 0;
  font-variant-numeric: tabular-nums;
}

/* Error Table in Validador */
.error-table {
  min-width: 760px;
}

.error-table th {
  background: #450a0a;
  border-bottom: 2px solid var(--error);
  color: #fee2e2;
}

.error-table tbody tr:hover {
  background: var(--error-bg) !important;
}

.error-table td:nth-child(4) {
  color: var(--error);
  font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 700px) {
  body {
    padding: 0;
  }
  main {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    padding: 24px 18px;
  }
  nav {
    margin-bottom: 24px;
  }
  nav a {
    flex: 1 1 auto;
    text-align: center;
  }
  h1 {
    font-size: 1.65rem;
  }
  .help-steps {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .help-guide {
    padding: 14px 16px;
  }
  .file-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}
