:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --border: #e3e6ec;
  --text: #101014;
  --muted: #6e7280;
  --brand: #0e0775;
  --brand-hover: #150a9c;
  --accent: #21a4d3;
  --ring: rgba(14, 7, 117, 0.16);
  --shadow-panel: 0 1px 2px rgba(16, 16, 20, 0.04), 0 8px 24px rgba(16, 16, 20, 0.05);
  --shadow-raised: 0 2px 6px rgba(16, 16, 20, 0.06), 0 16px 40px rgba(16, 16, 20, 0.09);
  --error-bg: #fdecea;
  --error-fg: #9a2a1c;
  --warn-bg: #fef3da;
  --warn-fg: #7a5600;
  --ok-bg: #e2f4ee;
  --ok-fg: #146b4c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.75rem;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.brand__logo { height: 24px; width: auto; object-fit: contain; }
.brand__product {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--brand);
}

.topbar nav { display: flex; align-items: center; gap: 1.5rem; }
.topbar nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.15s ease;
}
.topbar nav a:hover { color: var(--accent); }
.user { color: var(--muted); font-size: 0.88rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  padding: 0;
}

main { padding: 2rem 1.75rem 3rem; max-width: 1400px; margin: 0 auto; }

h1 {
  margin-top: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink, var(--text));
}

h2 {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
}

section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-panel);
}

body.login-page .topbar { display: none; }
body.login-page main { padding: 0; max-width: none; margin: 0; }

.login-shell {
  display: flex;
  min-height: 100vh;
}

.login-brand {
  flex: 1 1 42%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 3rem;
  color: white;
  position: relative;
  background:
    radial-gradient(circle at 15% 12%, rgba(33, 164, 211, 0.35), transparent 55%),
    radial-gradient(circle, rgba(255, 255, 255, 0.16) 1.5px, transparent 1.5px) 0 0 / 26px 26px,
    linear-gradient(160deg, var(--brand) 0%, #05032d 100%);
}

.login-brand__lockup {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.9rem;
}

.login-brand__logo {
  width: 230px;
  height: auto;
}

.login-brand__product {
  padding-top: 0.9rem;
  border-top: 2px solid var(--accent);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.8);
}

.login-brand__tagline {
  max-width: 20ch;
  margin: 3rem 0 0;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.login-panel {
  flex: 1 1 58%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 3rem;
  background: var(--bg);
}

.login-footer {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.login-footer__logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.login-panel .login-box {
  border: none;
  margin: 0;
}

@media (max-width: 860px) {
  .login-shell { flex-direction: column; }
  .login-brand { flex: none; padding: 2.5rem 2rem; }
  .login-brand__logo { width: 190px; }
  .login-brand__tagline { font-size: 1.5rem; margin-top: 2rem; }
  .login-panel { flex: none; padding: 2.5rem 2rem; }
}

.login-box {
  max-width: 380px;
  width: 100%;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem;
  box-shadow: var(--shadow-raised);
}

.login-box form { display: flex; flex-direction: column; gap: 1.1rem; }
.login-box label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font: inherit;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236e7280' stroke-width='1.5' fill='none' fill-rule='evenodd' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}

select option {
  padding: 0.5rem 0.75rem;
  color: var(--text);
  background: var(--panel);
}
select option:checked {
  background: var(--brand);
  color: white;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

input[type="file"] {
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  padding: 0.4rem 0.85rem;
  margin-right: 0.75rem;
  border: none;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
input[type="file"]::file-selector-button:hover {
  background: var(--border);
}

button, .primary {
  padding: 0.6rem 1.3rem;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover, .primary:hover { background: var(--brand-hover); }
button:active, .primary:active { transform: scale(0.98); }
button:focus-visible, .primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

.error {
  background: var(--error-bg);
  color: var(--error-fg);
  padding: 0.65rem 1rem;
  border-radius: 10px;
}

.error-inline {
  color: var(--error-fg);
}

.success {
  background: var(--ok-bg);
  color: var(--ok-fg);
  padding: 0.65rem 1rem;
  border-radius: 10px;
}

.warning-box {
  background: var(--warn-bg);
  color: var(--warn-fg);
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
}
.warning-box ul { margin: 0.4rem 0 0; padding-left: 1.4rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-error { background: var(--error-bg); color: var(--error-fg); }

.files-table, .report-table {
  border-collapse: collapse;
  width: 100%;
}
.files-table th, .files-table td,
.report-table th, .report-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.7rem;
  text-align: left;
  font-size: 0.9rem;
}
.files-table th, .report-table th {
  background: var(--panel);
  color: var(--muted);
  font-weight: 500;
  position: sticky;
  top: 0;
}
.files-table tbody tr:hover, .report-table tbody tr:hover {
  background: #fafbfd;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
  margin: 1.1rem 0;
}
.upload-grid label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }

.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
}
.upload-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.meta-line { color: var(--muted); font-size: 0.9rem; }
.meta-line a { color: var(--accent); text-decoration: none; font-weight: 500; }
.meta-line a:hover { text-decoration: underline; }

.table-scroll { overflow-x: auto; }

.report-table td.notas-cell { min-width: 260px; color: var(--muted); }

.files-table td .inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.15rem 1.25rem 0.15rem 0;
}
.files-table td .inline-form select,
.files-table td .inline-form input {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}
.files-table td .inline-form select { padding-right: 2rem; }
