/* ============================================================
   Nutrichek Licit — Design tokens
   Paleta: azul claro suave, fundo claro, acentos discretos
   ============================================================ */

:root {
  /* Backgrounds */
  --bg:        #f6f9fc;
  --bg-2:      #eef3f9;
  --bg-card:   #ffffff;
  --bg-soft:   #f0f5fa;

  /* Texto */
  --ink:       #0f1e30;
  --ink-2:     #2c3e54;
  --ink-3:     #58708a;
  --dim:       #8a9bb0;
  --dim-2:     #b8c5d4;

  /* Linhas */
  --line:      #e1e9f2;
  --line-2:    #d2dde9;
  --line-soft: #ecf1f7;

  /* Acento principal: azul claro */
  --accent:       #5b9eff;
  --accent-deep:  #3d7fdc;
  --accent-soft:  #e6f0ff;
  --accent-glow:  rgba(91, 158, 255, 0.18);

  /* Status */
  --ok:        #4caf8a;
  --warn:      #f0a04b;
  --urgent:    #e26b6b;
  --neutral:   #b8c5d4;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(15, 30, 48, 0.04);
  --shadow:    0 4px 16px -4px rgba(15, 30, 48, 0.08);
  --shadow-lg: 0 24px 64px -12px rgba(15, 30, 48, 0.18);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  padding: 24px;
}

.login-bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.7;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  pointer-events: none;
}

.login-bg-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  pointer-events: none;
}

.login-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.login-brand-mark {
  width: 38px; height: 38px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.login-brand-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.login-brand-name span { color: var(--accent); }

.login-brand-sub {
  font-size: 11px;
  color: var(--dim);
  margin-top: 2px;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.login-desc {
  font-size: 13px;
  color: var(--ink-3);
  margin: 0 0 28px;
}

.login-erro {
  background: #fef2f2;
  color: #c44;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid #f5d6d6;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  font-weight: 500;
}

.field input {
  padding: 11px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  transition: border 0.15s, background 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-btn {
  margin-top: 8px;
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
}

.login-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ok);
  font-family: var(--font-mono);
}
.status-pill .dot {
  width: 6px; height: 6px;
  background: var(--ok);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(76, 175, 138, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}

.login-version {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dim);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   APP / TOPBAR
   ============================================================ */
.app {
  min-height: 100vh;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 34px; height: 34px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.brand-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.brand-name span { color: var(--accent); }

.brand-sub {
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.topbar-center { flex: 1; display: flex; justify-content: center; }

.status-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.status-live { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); }
.status-live .dot {
  width: 6px; height: 6px;
  background: var(--ok);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(76, 175, 138, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}
.status-bar .sep { color: var(--dim-2); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px; height: 34px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: all 0.15s;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 100px;
}
.user-avatar {
  width: 26px; height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-size: 12px; line-height: 1.2; color: var(--ink); }
.user-role { font-size: 10px; color: var(--dim); line-height: 1.2; font-family: var(--font-mono); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: 56px 28px 40px;
  max-width: 920px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 24px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 100px;
}
.eyebrow-bracket { color: var(--accent); }
.eyebrow-arrow { color: var(--accent); margin: 0 6px 0 4px; }

.hero-title {
  font-size: 46px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
  color: var(--ink);
}
.hero-soft {
  color: var(--accent-deep);
  font-weight: 400;
}

@media (max-width: 700px) { .hero-title { font-size: 32px; } }

.hero-desc {
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1.6;
  max-width: 560px;
  margin: 0;
}

/* ============================================================
   MÉTRICAS
   ============================================================ */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
@media (max-width: 900px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .metrics { grid-template-columns: 1fr; } }

.metric {
  background: var(--bg-card);
  padding: 22px 24px;
  transition: background 0.15s;
}
.metric:hover { background: var(--bg-soft); }

.metric-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.metric-icon {
  width: 24px; height: 24px;
  background: var(--accent-soft);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-deep);
}
.metric-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  font-weight: 500;
}
.metric-body {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px;
}
.metric-value {
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.metric-value.accent { color: var(--accent-deep); }
.metric-value.warn   { color: var(--warn); }

.sparkline { opacity: 0.85; }

.metric-delta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  margin-top: 8px;
}

/* ============================================================
   CONTROLES
   ============================================================ */
.controls {
  padding: 20px 28px 8px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  min-width: 240px;
  position: relative;
  display: flex; align-items: center;
}
.search-icon { position: absolute; left: 14px; color: var(--dim); pointer-events: none; }
.search input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  transition: border 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--dim); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-wrap {
  position: relative;
  display: flex; align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  transition: border 0.15s;
}
.select-wrap:hover { border-color: var(--line-2); }
.select-wrap-wide select { min-width: 170px; }

.select-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 8px;
}

.select-wrap select, .select-wrap input {
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  padding: 11px 8px 11px 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 60px;
}
.select-wrap input { width: 80px; cursor: text; font-family: var(--font-mono); }
.select-wrap select:focus, .select-wrap input:focus { outline: none; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  box-shadow: 0 1px 3px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ============================================================
   CHIPS
   ============================================================ */
.chips-bar {
  padding: 4px 28px 22px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.chips-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* ============================================================
   TABELA
   ============================================================ */
.table-section { padding: 0 28px; }

.table-head {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.table-head .dim { color: var(--dim); }
.table-head-right { display: flex; gap: 16px; }
.legend {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--dim);
  font-size: 10px;
}
.legend .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
}
.dot.ok      { background: var(--ok); }
.dot.warn    { background: var(--warn); }
.dot.urgent  { background: var(--urgent); animation: pulse 1.2s ease-in-out infinite; }
.dot.neutral { background: var(--neutral); }

.rows { display: flex; flex-direction: column; }

.row {
  display: grid;
  grid-template-columns: 64px 1fr 130px 110px 36px;
  gap: 16px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  align-items: center;
  transition: all 0.15s;
  animation: rowIn 0.4s ease-out backwards;
}
@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.row:hover {
  background: var(--bg-soft);
  padding-left: 14px;
  padding-right: 14px;
}
.row.priority {
  background: linear-gradient(90deg, var(--accent-soft) 0%, transparent 70%);
  border-left: 2px solid var(--accent);
  padding-left: 4px;
}
.row.priority:hover { padding-left: 14px; }

@media (max-width: 800px) {
  .row {
    grid-template-columns: 24px 1fr 100px;
    gap: 10px;
  }
  .row-data, .row-arrow { display: none; }
  .row-num { display: none; }
}

.row-id {
  display: flex; align-items: center; gap: 8px;
}
.row-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dim);
}

.row-main { min-width: 0; }
.row-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  flex-wrap: wrap;
}
.tag {
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dot-sep { color: var(--dim-2); }
.row-loc {
  color: var(--dim);
  display: inline-flex; align-items: center; gap: 4px;
}
.match-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.row-objeto {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  margin: 0 0 4px;
  color: var(--ink);
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-orgao {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  color: var(--dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-valor, .row-data { text-align: right; }
.valor-num, .data-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.valor-label, .data-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
}
.data-label.urgent { color: var(--urgent); }

.row-arrow {
  color: var(--dim);
  display: flex; justify-content: center;
  transition: all 0.15s;
}
.row:hover .row-arrow {
  transform: translate(2px, -2px);
  color: var(--accent);
}

/* ============================================================
   STATES (loading, error, empty)
   ============================================================ */
.state-box {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 24px;
  text-align: center;
  color: var(--ink-3);
}
.state-icon { color: var(--dim); margin-bottom: 14px; }
.state-text {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  margin-bottom: 6px;
}
.state-sub {
  font-size: 12px;
  color: var(--ink-3);
  max-width: 480px;
  line-height: 1.5;
}
.state-error .state-text { color: var(--urgent); }

.spin { animation: spinAnim 0.8s linear infinite; }
@keyframes spinAnim { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 30, 48, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 760px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 36px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 7px;
  border-radius: 7px;
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--ink); border-color: var(--line-2); }

.modal-tag-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.modal-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
  padding: 4px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 4px;
}
.modal-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dim);
}

.modal-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  color: var(--ink);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 20px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
@media (max-width: 600px) { .modal-grid { grid-template-columns: 1fr; } }

.modal-cell { padding: 14px 18px; background: var(--bg-card); }
.highlight-cell { background: var(--bg-soft); }

.modal-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-bottom: 4px;
}
.modal-val { font-size: 13px; color: var(--ink); line-height: 1.4; }
.modal-val.mono { font-family: var(--font-mono); font-size: 12px; }
.accent-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-deep);
}

.modal-section {
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.modal-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  display: flex;
  justify-content: space-between;
  padding: 28px 28px 24px;
  margin-top: 40px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dim);
}
.footer-left, .footer-right { display: flex; gap: 8px; }
.dim { color: var(--dim-2); }

@media (max-width: 600px) {
  .footer { flex-direction: column; gap: 6px; }
}
