/* ═══════════════════════════════════════════════
   OBRIGAÇÕES MEI — DAS, DASN, LIVRO CAIXA
   ═══════════════════════════════════════════════ */

/* ─── Nav badges ─────────────────────────────── */
.obrig-badge {
  font-size: .6rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 50px;
  margin-left: auto;
  flex-shrink: 0;
}
.obrig-nav-badge-red {
  background: var(--danger-light);
  color: var(--danger);
  font-size: .6rem;
  font-weight: 700;
  padding: .1rem .42rem;
  border-radius: 50px;
  margin-left: auto;
  flex-shrink: 0;
}
.obrig-nav-badge-warn {
  background: var(--accent-light);
  color: #B07520;
  font-size: .6rem;
  font-weight: 700;
  padding: .1rem .42rem;
  border-radius: 50px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ─── Section card ───────────────────────────── */
.obrig-section {
  background: #fff;
  border: 1px solid #e8ecea;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  margin-bottom: .85rem;
}
.obrig-section:last-child { margin-bottom: 0; }

.obrig-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f0f2f1;
  flex-wrap: wrap;
  gap: .6rem;
  background: #fafbfa;
}

.obrig-section-left {
  display: flex;
  align-items: center;
  gap: .85rem;
}

/* ─── DAS Info Tooltip ───────────────────────── */
.obrig-sh-title {
  display: flex;
  align-items: center;
  gap: .45rem;
}
.das-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: .6rem;
  font-weight: 800;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  transition: background var(--tr), color var(--tr);
  padding: 0;
}
.das-info-btn:hover { background: var(--primary); color: #fff; }

.obrig-section-das { position: relative; overflow: visible !important; }

.das-tooltip {
  display: none;
  position: absolute;
  top: 4rem;
  left: 1rem;
  z-index: 200;
  width: min(340px, calc(100vw - 2rem));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.13), 0 2px 8px rgba(0,0,0,.07);
  padding: 1.1rem 1.2rem 1rem;
  animation: tooltipIn .2s ease-out both;
}
.das-tooltip.open { display: block; }
@keyframes tooltipIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.das-tooltip-close {
  position: absolute;
  top: .6rem; right: .7rem;
  background: none; border: none;
  font-size: .75rem; color: var(--text-muted);
  cursor: pointer; padding: .2rem .3rem;
  border-radius: 4px;
  transition: color var(--tr);
}
.das-tooltip-close:hover { color: var(--text); }
.das-tooltip-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .7rem;
}
.das-tooltip p {
  font-size: .8rem;
  color: var(--text-sec);
  line-height: 1.55;
  margin-bottom: .85rem;
}
.das-tooltip-items { display: flex; flex-direction: column; gap: .6rem; }
.das-tooltip-item {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  font-size: .78rem;
  color: var(--text-sec);
  line-height: 1.5;
  padding: .5rem .6rem;
  background: var(--bg);
  border-radius: 8px;
}
.das-tooltip-item strong { color: var(--text); }
.das-tip-icon { font-size: .95rem; flex-shrink: 0; margin-top: .05rem; }

/* ─── Icon box ───────────────────────────────── */
.obrig-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.obrig-icon-red   { background: #fef2f2; box-shadow: 0 0 0 1px rgba(220,38,38,.1); }
.obrig-icon-blue  { background: #eff6ff; box-shadow: 0 0 0 1px rgba(59,130,246,.1); }
.obrig-icon-green { background: #f0fdf4; box-shadow: 0 0 0 1px rgba(22,163,74,.1); }

.obrig-sh-title {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.obrig-sh-sub {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .15rem;
  font-weight: 500;
}

/* ─── DASN right column (PRO + prazo empilhados) */
.obrig-dasn-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .35rem;
  flex-shrink: 0;
  align-self: flex-start;
}
.obrig-dasn-right .pro-badge-sm { margin-left: 0; }

/* ─── Badge pills ────────────────────────────── */
.obrig-badge-pill {
  font-size: .68rem;
  font-weight: 700;
  padding: .24rem .75rem;
  border-radius: 50px;
  white-space: nowrap;
  letter-spacing: .02em;
}
.obrig-badge-red   { background: #fef2f2; color: #b91c1c; border: 1px solid rgba(185,28,28,.12); }
.obrig-badge-amber { background: #fffbeb; color: #92400e; border: 1px solid rgba(146,64,14,.12); }
.obrig-badge-green { background: #f0fdf4; color: #166534; border: 1px solid rgba(22,101,52,.12); }
.obrig-badge-gray  { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border-light); }

/* ─── DAS rows ───────────────────────────────── */
.obrig-das-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid #f0f2f1;
  flex-wrap: wrap;
  transition: background .15s;
}
.obrig-das-row:last-child { border-bottom: none; }
.obrig-das-row:hover { background: rgba(27,140,90,.02); }
.obrig-das-row-vencido,
.obrig-row-vencido { background: #fff8f8; }
.obrig-das-row-vencido:hover,
.obrig-row-vencido:hover { background: #fef2f2; }

.obrig-das-month {
  font-size: .855rem;
  font-weight: 700;
  color: var(--text);
  min-width: 100px;
}
.obrig-das-date {
  font-size: .775rem;
  color: var(--text-muted);
  min-width: 110px;
  font-variant-numeric: tabular-nums;
}
.obrig-das-val {
  font-size: .855rem;
  font-weight: 700;
  color: var(--text);
  min-width: 80px;
  font-variant-numeric: tabular-nums;
}
.obrig-das-spacer { flex: 1; }

/* ─── Tags inline ────────────────────────────── */
.obrig-tag {
  font-size: .68rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: .01em;
}
.obrig-tag-red   { background: #fef2f2; color: #b91c1c; }
.obrig-tag-amber { background: #fffbeb; color: #92400e; }
.obrig-tag-green { background: #f0fdf4; color: #166534; }
.obrig-tag-gray  { background: var(--bg); color: var(--text-muted); }

/* ─── Row buttons ────────────────────────────── */
.obrig-row-btn {
  font-size: .775rem;
  padding: .38rem .85rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-sec);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all var(--tr);
  white-space: nowrap;
  flex-shrink: 0;
}
.obrig-row-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.obrig-row-btn-primary {
  background: #fef2f2;
  color: #b91c1c;
  border-color: rgba(185,28,28,.2);
  font-weight: 700;
}
.obrig-row-btn-primary:hover {
  background: #fee2e2;
  border-color: rgba(185,28,28,.35);
}

/* ─── Body section ───────────────────────────── */
.obrig-body { padding: 1.1rem 1.25rem; }

/* ─── DASN stats row ─────────────────────────── */
.obrig-stats-row {
  display: flex;
  gap: .7rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.obrig-stat {
  flex: 1;
  min-width: 110px;
  background: #fafbfa;
  border: 1px solid #eef0ef;
  border-radius: 10px;
  padding: .8rem 1rem;
  transition: box-shadow .15s;
}
.obrig-stat:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.obrig-stat-label {
  font-size: .68rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.obrig-stat-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

/* ─── DASN preview (free blur) ───────────────── */
.obrig-dasn-preview {
  border: 1.5px dashed #d1d5d3;
  border-radius: 10px;
  padding: 1rem;
  position: relative;
  min-height: 110px;
  background: #fafbfa;
}
.obrig-dasn-preview-content {
  transition: filter .25s;
}
.obrig-dasn-field {
  font-size: .83rem;
  color: var(--text-sec);
  line-height: 2;
}
.obrig-dasn-field strong { color: var(--text); }
.obrig-dasn-overlay {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.88);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.obrig-dasn-overlay-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .25rem;
}
.obrig-dasn-overlay-sub {
  font-size: .78rem;
  color: var(--text-muted);
}

/* ─── DASN pro form ──────────────────────────── */
.obrig-dasn-pro { margin-top: .6rem; }
.obrig-dasn-pro-form {
  border: 1px solid #eef0ef;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: #fafbfa;
}
.obrig-dasn-pro-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  margin-bottom: .85rem;
  align-items: end;
}
.obrig-dasn-label {
  font-size: .68rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: .3rem;
}
.obrig-dasn-val {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.obrig-dasn-select {
  width: 100%;
  padding: .48rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: .83rem;
  background: #fff;
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.obrig-dasn-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.obrig-dasn-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ─── Livro Caixa — Month cards ──────────────── */
.livro-months-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .55rem;
  margin-bottom: 1rem;
}
.livro-month-card {
  background: #fff;
  border: 1px solid #e8ecea;
  border-radius: 10px;
  padding: .75rem .9rem;
  cursor: pointer;
  transition: all var(--tr);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.livro-month-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(27,140,90,.12);
  transform: translateY(-2px);
}
.livro-mc-name {
  font-size: .68rem;
  color: var(--text-muted);
  margin-bottom: .28rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.livro-mc-val {
  font-size: .98rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.livro-mc-count {
  font-size: .66rem;
  margin-top: .2rem;
  color: var(--text-muted);
}
.livro-mc-pos { color: var(--primary) !important; }
.livro-mc-neg { color: var(--danger) !important; }
.livro-month-card--active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 4px 14px rgba(27,140,90,.12);
}
.livro-month-card--active .livro-mc-name { color: var(--primary); }

/* ─── Livro table — Desktop ──────────────────── */
.livro-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .845rem;
}
.livro-table thead tr {
  background: #f5f7f6;
  border-bottom: 2px solid #e8ecea;
}
.livro-table th {
  font-size: .67rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .7rem 1rem;
  text-align: left;
  white-space: nowrap;
}
.livro-table th:nth-child(4),
.livro-table th:nth-child(5),
.livro-table th:nth-child(6) { text-align: right; }

.livro-table tbody tr {
  border-bottom: 1px solid #f0f2f1;
  transition: background .12s;
}
.livro-table tbody tr:last-child { border-bottom: none; }
.livro-table tbody tr:hover { background: rgba(27,140,90,.025); }

.livro-table td {
  padding: .72rem 1rem;
  color: var(--text-sec);
  font-size: .845rem;
  vertical-align: middle;
}
.livro-table td:nth-child(4),
.livro-table td:nth-child(5),
.livro-table td:nth-child(6) { text-align: right; font-variant-numeric: tabular-nums; }

/* Value colors — must override td base color */
.livro-inc { color: var(--primary) !important; font-weight: 700; }
.livro-exp { color: var(--danger) !important; font-weight: 700; }
.livro-saldo-pos { color: var(--primary) !important; font-weight: 700; }
.livro-saldo-neg { color: var(--danger) !important; font-weight: 700; }

/* Total row */
.livro-total-row td {
  background: #f5f7f6;
  border-top: 2px solid #e0e5e2 !important;
  font-weight: 700 !important;
  font-size: .845rem;
}
.livro-total-row td:nth-child(1) { color: var(--text); }

/* ─── Export row ─────────────────────────────── */
.livro-export-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.livro-pro-upsell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eff6ff;
  border: 1px solid rgba(59,130,246,.15);
  border-radius: 10px;
  padding: .8rem 1rem;
  margin-top: .8rem;
  gap: .8rem;
  flex-wrap: wrap;
}

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 900px) {
  .obrig-das-row { gap: .5rem; }
  .obrig-das-date { min-width: unset; }
  .obrig-dasn-pro-row { grid-template-columns: 1fr 1fr; }
  .livro-months-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .livro-table th,
  .livro-table td { padding: .6rem .75rem; }
}

@media (max-width: 600px) {
  /* ── Section head ── */
  .obrig-section-head { flex-direction: row; align-items: center; gap: .5rem; flex-wrap: nowrap; }

  /* ── DAS: cards instead of flat rows ── */
  #obrigDasRows { display: flex; flex-direction: column; gap: 0; }

  .obrig-das-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "month  status"
      "date   date"
      "val    action";
    gap: .18rem .5rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid #f0f2f1;
    align-items: start;
  }
  .obrig-das-row:last-child { border-bottom: none; }

  .obrig-das-month  { grid-area: month;  min-width: unset; font-size: .92rem; align-self: center; }
  .obrig-das-date   { grid-area: date;   min-width: unset; font-size: .75rem; margin-top: .05rem; }
  .obrig-das-val    { grid-area: val;    min-width: unset; font-size: 1rem; font-weight: 800; align-self: center; margin-top: .3rem; }
  .obrig-das-spacer { display: none; }

  /* Status tag — top right */
  .obrig-das-row .obrig-tag {
    grid-area: status;
    align-self: center;
    justify-self: end;
    font-size: .65rem;
    padding: .22rem .6rem;
  }

  /* Action button — bottom right */
  .obrig-das-row .obrig-row-btn {
    grid-area: action;
    align-self: center;
    justify-self: end;
    font-size: .75rem;
    padding: .32rem .75rem;
    margin-top: .3rem;
  }

  /* Vencido card tint */
  .obrig-row-vencido { background: #fff8f8; }

  /* ── DASN stats: 3 cols → 1 col ── */
  .obrig-stats-row { flex-direction: column; gap: .5rem; }

  /* ── DASN pro form ── */
  .obrig-dasn-pro-row { grid-template-columns: 1fr; }
  .livro-export-row { flex-direction: column; align-items: flex-start; }
  .livro-pro-upsell { flex-direction: column; align-items: flex-start; }
  .livro-months-grid { grid-template-columns: repeat(3, 1fr); gap: .45rem; }
  .livro-mc-val { font-size: .88rem; }

  /* Allow card shadows to show — override section overflow:hidden */
  #pgLivro .obrig-section { overflow: visible; }
  /* Mobile: container padding so cards don't touch section edge */
  .livro-table-wrap { padding: .75rem; background: #f5f7f6; border-radius: 0 0 14px 14px; }

  /* Mobile: cards instead of table rows */
  .livro-table thead { display: none; }
  .livro-table,
  .livro-table tbody { display: block; }
  .livro-table tbody { display: flex; flex-direction: column; gap: .55rem; }
  .livro-table tbody tr {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: .2rem .65rem;
    background: #fff !important;
    border: 1px solid #e8ecea !important;
    border-radius: 12px;
    padding: .85rem 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  }
  .livro-table tbody tr:hover { background: #fff !important; }
  /* Data — full width, small muted label */
  .livro-table td:nth-child(1) {
    grid-column: 1 / 3;
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0;
    border: none;
  }
  /* Descrição — full width, main text */
  .livro-table td:nth-child(2) {
    grid-column: 1 / 3;
    font-weight: 700;
    font-size: .875rem;
    color: var(--text);
    padding: 0;
    border: none;
  }
  /* Categoria — left col */
  .livro-table td:nth-child(3) {
    grid-column: 1 / 2;
    padding: 0;
    border: none;
    font-size: .75rem;
    color: var(--text-muted);
  }
  /* Entradas — right col */
  .livro-table td:nth-child(4) {
    grid-column: 2 / 3;
    text-align: right;
    padding: 0;
    border: none;
    font-size: .82rem;
  }
  /* Saídas — left col, 2nd data row */
  .livro-table td:nth-child(5) {
    grid-column: 1 / 2;
    padding: 0;
    border: none;
    font-size: .82rem;
  }
  /* Saldo — right col, 2nd data row */
  .livro-table td:nth-child(6) {
    grid-column: 2 / 3;
    text-align: right;
    padding: 0;
    border: none;
    font-size: .82rem;
  }
  /* Labels before value cells */
  .livro-table td:nth-child(4)::before { content: "Entrada"; display: block; font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: .1rem; }
  .livro-table td:nth-child(5)::before { content: "Saída"; display: block; font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: .1rem; }
  .livro-table td:nth-child(6)::before { content: "Saldo"; display: block; font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: .1rem; }
  .livro-total-row { display: none !important; }
}
