:root {
  --bg: #050505;
  --bg-elevated: #0e0e0e;
  --surface: rgba(18, 18, 18, 0.82);
  --surface-solid: #141414;
  --surface-hover: #1a1a1a;
  --ink: #f5f5f5;
  --ink-soft: #9a9a9a;
  --ink-muted: #6b6b6b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --gold: #c4a574;
  --gold-light: #d4bc94;
  --gold-dark: #a88958;
  --gold-glow: rgba(196, 165, 116, 0.35);
  --primary: #c4a574;
  --primary-hover: #d4bc94;
  --danger: #e05252;
  --danger-soft: rgba(224, 82, 82, 0.12);
  --warning: #d4924a;
  --warning-soft: rgba(212, 146, 74, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

* { box-sizing: border-box; }
html {
  height: auto;
  -webkit-text-size-adjust: 100%;
}

html, body { margin: 0; padding: 0; }

body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

/* ─── LOGIN ─── */

.login-body {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 48px;
}

.login-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 50%, rgba(196, 165, 116, 0.06), transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 20%, rgba(196, 165, 116, 0.04), transparent 50%),
    #000;
  z-index: 0;
}

.login-neural {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='600' viewBox='0 0 800 600'%3E%3Cg fill='none' stroke='%23c4a574' stroke-opacity='0.18'%3E%3Cline x1='120' y1='80' x2='280' y2='160'/%3E%3Cline x1='280' y1='160' x2='420' y2='90'/%3E%3Cline x1='420' y1='90' x2='560' y2='200'/%3E%3Cline x1='120' y1='80' x2='180' y2='280'/%3E%3Cline x1='180' y1='280' x2='340' y2='320'/%3E%3Cline x1='340' y1='320' x2='500' y2='260'/%3E%3Cline x1='500' y1='260' x2='560' y2='200'/%3E%3Cline x1='280' y1='160' x2='340' y2='320'/%3E%3Cline x1='60' y1='400' x2='180' y2='280'/%3E%3Cline x1='60' y1='400' x2='220' y2='480'/%3E%3Cline x1='220' y1='480' x2='340' y2='320'/%3E%3Cline x1='220' y1='480' x2='400' y2='520'/%3E%3Cline x1='400' y1='520' x2='500' y2='260'/%3E%3C/g%3E%3Cg fill='%23c4a574'%3E%3Ccircle cx='120' cy='80' r='3' opacity='0.9'/%3E%3Ccircle cx='280' cy='160' r='4' opacity='0.95'/%3E%3Ccircle cx='420' cy='90' r='3' opacity='0.85'/%3E%3Ccircle cx='560' cy='200' r='3' opacity='0.8'/%3E%3Ccircle cx='180' cy='280' r='3' opacity='0.75'/%3E%3Ccircle cx='340' cy='320' r='4' opacity='0.9'/%3E%3Ccircle cx='500' cy='260' r='3' opacity='0.8'/%3E%3Ccircle cx='60' cy='400' r='3' opacity='0.7'/%3E%3Ccircle cx='220' cy='480' r='3' opacity='0.75'/%3E%3Ccircle cx='400' cy='520' r='3' opacity='0.65'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: left center;
  mask-image: linear-gradient(90deg, #000 0%, #000 55%, transparent 85%);
  pointer-events: none;
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 48px;
  align-items: center;
}

.login-brand {
  padding: 20px 0;
}

.login-logo-main {
  width: min(280px, 65vw);
  height: auto;
  display: block;
  margin-bottom: 24px;
}

.login-tagline {
  margin: 0 0 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--gold);
  text-transform: uppercase;
}

.login-slogan {
  margin: 0;
  max-width: 420px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.45;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.92);
}

.login-slogan .gold {
  color: var(--gold);
  font-weight: 500;
}

.login-project {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.login-project-logo-patria {
  height: 72px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.login-project-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
}

.login-card {
  background: rgba(12, 12, 12, 0.75);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(196, 165, 116, 0.22);
  border-radius: 20px;
  padding: 36px 32px 32px;
  box-shadow:
    0 0 0 1px rgba(196, 165, 116, 0.06) inset,
    0 24px 48px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(196, 165, 116, 0.04);
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}

.login-subtitle {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 20px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--ink-muted);
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 14px 44px 14px 44px;
  font: inherit;
  font-size: 14px;
  color: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap input::placeholder {
  color: var(--ink-muted);
}

.input-wrap input:focus {
  outline: none;
  border-color: rgba(196, 165, 116, 0.5);
  box-shadow: 0 0 0 3px rgba(196, 165, 116, 0.12);
}

.toggle-password {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--ink-muted);
  display: grid;
  place-items: center;
}

.toggle-password svg {
  width: 18px;
  height: 18px;
}

.toggle-password:hover {
  color: var(--gold);
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -4px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}

.remember input {
  accent-color: var(--gold);
}

.btn-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
  padding: 15px 24px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  color: #1a1208;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 8px 24px rgba(196, 165, 116, 0.25);
}

.btn-login svg {
  width: 20px;
  height: 20px;
}

.btn-login:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 12px 32px rgba(196, 165, 116, 0.35);
}

/* ─── SHARED ─── */

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(224, 82, 82, 0.3);
}

.muted { color: var(--ink-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #1a1208;
}

.btn-secondary {
  background: rgba(196, 165, 116, 0.12);
  color: var(--gold-light);
  border: 1px solid rgba(196, 165, 116, 0.25);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover { color: var(--gold); }

.upload-btn { position: relative; overflow: hidden; }

/* ─── DASHBOARD ─── */

body.dashboard-body {
  background:
    radial-gradient(ellipse 60% 40% at 10% 0%, rgba(196, 165, 116, 0.05), transparent 50%),
    var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(8, 8, 8, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-logos {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 18px;
  border-right: 1px solid var(--line);
}

.topbar-logos img {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.topbar-logos img:first-child {
  filter: brightness(0) invert(1);
}

.topbar h1 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.topbar p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.topbar-right { flex-wrap: wrap; justify-content: flex-end; }

.updated-label {
  font-size: 13px;
  color: var(--ink-soft);
}

.updated-label strong { color: var(--gold); }

.container {
  width: min(1440px, calc(100% - 40px));
  margin: 28px auto 48px;
  display: grid;
  gap: 22px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card,
.panel {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.5;
}

.kpi-card.danger::before { background: linear-gradient(90deg, transparent, var(--danger), transparent); }
.kpi-card.warning::before { background: linear-gradient(90deg, transparent, var(--warning), transparent); }

.kpi-label {
  display: block;
  color: var(--ink-soft);
  font-size: 13px;
}

.kpi-value-wrap,
.stat-value-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  margin-top: 8px;
}

.kpi-value,
.fit-value {
  display: block;
  margin-top: 0;
  font-size: clamp(13px, 1.9vw, 26px);
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  line-height: 1.15;
  max-width: 100%;
}

.stat-value-wrap {
  margin-top: 4px;
}

.stat-value-wrap .fit-value {
  font-size: clamp(12px, 1.6vw, 18px);
}

.expiry-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  color: #fff;
}

.charts-grid,
.expiry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel { padding: 22px 24px; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.expiry-panel.vencidos { border-top: 3px solid var(--danger); }
.expiry-panel.proximos { border-top: 3px solid var(--warning); }

.expiry-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.expiry-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 130px;
  flex: 1;
  max-width: 100%;
  overflow: hidden;
}

.expiry-list {
  display: grid;
  gap: 10px;
  max-height: 340px;
  overflow: auto;
}

.expiry-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.15s;
}

.expiry-item:hover { background: rgba(196, 165, 116, 0.05); }

.expiry-item-title {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}

.expiry-item-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.expiry-badge {
  align-self: start;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.expiry-badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(224, 82, 82, 0.25);
}

.expiry-badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid rgba(212, 146, 74, 0.25);
}

.expiry-empty {
  padding: 28px;
  text-align: center;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 14px;
  border: 1px dashed var(--line);
}

.table-header { align-items: end; }

input[type="search"],
.search-input {
  width: 100%;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-size: 14px;
  color: #fff;
}

input[type="search"]:focus,
.search-input:focus {
  outline: none;
  border-color: rgba(196, 165, 116, 0.45);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
  font-size: 13px;
}

thead {
  background: rgba(255, 255, 255, 0.03);
  position: sticky;
  top: 0;
}

th {
  color: var(--gold);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

td { color: rgba(255, 255, 255, 0.88); }

tbody tr:hover { background: rgba(196, 165, 116, 0.04); }

.table-loading {
  text-align: center;
  padding: 24px !important;
}

.table-foot {
  margin: 12px 4px 0;
  font-size: 13px;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--surface-solid);
  color: var(--gold-light);
  border: 1px solid rgba(196, 165, 116, 0.3);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
}

/* scrollbar */
.expiry-list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.expiry-list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(196, 165, 116, 0.3);
  border-radius: 99px;
}

@media (max-width: 1024px) {
  .login-body {
    align-items: flex-start;
    padding-top: 28px;
    padding-bottom: 40px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    max-width: 440px;
    width: 100%;
  }

  .login-brand {
    text-align: center;
  }

  .login-logo-main {
    margin-left: auto;
    margin-right: auto;
  }

  .login-slogan {
    margin-left: auto;
    margin-right: auto;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .login-shell { max-width: 100%; }

  .charts-grid,
  .expiry-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-left { flex-wrap: wrap; }

  .topbar-logos {
    border-right: none;
    padding-right: 0;
  }

  .topbar-right { justify-content: flex-start; }
}
