/* ─── PORTAL NFS-e SOALHE CONTABILIDADE ─── */
/* Paleta baseada na identidade visual da Soalhe: Dourado, Prata, Preto */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* === SOALHE BRAND COLORS === */
  --gold:          #C9A227;       /* Dourado principal */
  --gold-dark:     #8B6914;       /* Dourado escuro (hover) */
  --gold-light:    #F5E9C0;       /* Dourado claro (fundo light) */
  --gold-xlight:   #FBF5E0;       /* Dourado muito claro */
  --silver:        #A8A9AD;       /* Prata (SOALHE) */
  --silver-dark:   #6B6E73;       /* Prata escuro */
  --ink:           #111111;       /* Preto do logo */
  --ink-mid:       #1F1F1F;       /* Quase-preto sidebar */

  /* === SISTEMA (mapear sobre paleta Soalhe) === */
  --primary:       var(--gold);
  --primary-dark:  var(--gold-dark);
  --primary-light: var(--gold-light);

  --success:       #059669;
  --success-light: #d1fae5;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --info:          #0891b2;
  --info-light:    #cffafe;

  /* === GRAYSCALE (fundo cinza claro como pedido) === */
  --gray-50:   #f9fafb;
  --gray-100:  #f0f0f2;   /* fundo principal: cinza muito claro */
  --gray-200:  #e5e7eb;
  --gray-300:  #d1d5db;
  --gray-400:  #9ca3af;
  --gray-500:  #6b7280;
  --gray-600:  #4b5563;
  --gray-700:  #374151;
  --gray-800:  #1f2937;
  --gray-900:  #111827;

  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.12), 0 4px 6px rgba(0,0,0,.06);
  --shadow-gold: 0 4px 16px rgba(201,162,39,.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
}

/* ─── LOGIN ─── */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--ink) 0%, #1a1500 60%, #0d0d0d 100%);
}

.login-box {
  background: white;
  padding: 44px 40px;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(201,162,39,.18);
  width: 100%; max-width: 420px;
  text-align: center;
}

/* Logo na tela de login */
.login-logo {
  display: flex; justify-content: center; margin-bottom: 20px;
}
.login-logo .soalhe-badge {
  width: 110px; height: 110px;
  filter: drop-shadow(0 4px 12px rgba(201,162,39,.4));
}

.login-box h1 {
  font-size: 22px;
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 4px;
}
.login-box .login-subtitle {
  color: var(--gray-500);
  font-size: 13px;
  margin-bottom: 28px;
}
.login-box .login-brand {
  font-size: 11px; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 6px;
}

/* ─── LAYOUT ─── */
.app { display: flex; min-height: 100vh; }

/* ─── SIDEBAR (preto do logo, dourado como acento) ─── */
.sidebar {
  width: 264px;
  background: var(--ink-mid);
  color: white;
  display: flex; flex-direction: column;
  position: fixed; height: 100vh; z-index: 100;
  transition: transform .3s;
  border-right: 1px solid rgba(201,162,39,.15);
}

.sidebar-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 12px;
  background: var(--ink);
}

/* Logo no sidebar */
.sidebar-logo {
  width: 44px; height: 44px; flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(201,162,39,.5));
}

.sidebar-brand {
  display: flex; flex-direction: column;
}
.sidebar-brand .brand-name {
  font-size: 14px; font-weight: 700; color: var(--gold);
  letter-spacing: .5px; line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: 10px; color: var(--silver);
  text-transform: uppercase; letter-spacing: 1px;
  margin-top: 1px;
}
.sidebar-header .badge {
  background: var(--gold);
  color: var(--ink);
  padding: 2px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 700;
  margin-left: auto; white-space: nowrap;
}

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: rgba(255,255,255,.65);
  cursor: pointer; transition: all .18s; font-size: 13.5px;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(201,162,39,.1);
  color: rgba(255,255,255,.95);
  border-left-color: rgba(201,162,39,.4);
}
.nav-item.active {
  background: rgba(201,162,39,.14);
  color: var(--gold);
  border-left-color: var(--gold);
  font-weight: 600;
}
.nav-item .icon { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px;
  color: rgba(255,255,255,.4);
}
.sidebar-footer a { color: rgba(201,162,39,.7); text-decoration: none; }
.sidebar-footer a:hover { color: var(--gold); }

.main-content { flex: 1; margin-left: 264px; }

/* ─── TOPBAR ─── */
.topbar {
  background: white;
  padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
  border-bottom: 2px solid var(--gold-light);
}
.topbar h1 { font-size: 18px; font-weight: 700; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.content { padding: 24px; }

/* ─── CARDS ─── */
.card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 2px solid var(--gold-light);
}
.card-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }

/* ─── KPI CARDS ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: white; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  border-left: 4px solid var(--gold);
  position: relative; overflow: hidden;
}
.kpi-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 60px; height: 100%;
  background: linear-gradient(to left, rgba(201,162,39,.04), transparent);
}
.kpi-card.success { border-left-color: var(--success); }
.kpi-card.success::after { background: linear-gradient(to left, rgba(5,150,105,.04), transparent); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-card.danger::after { background: linear-gradient(to left, rgba(220,38,38,.04), transparent); }
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.info { border-left-color: var(--info); }
.kpi-label { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--gray-800); }
.kpi-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ─── FORMS ─── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
.form-group label .req { color: var(--danger); }

input, select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px; font-size: 14px; color: var(--gray-800);
  transition: border-color .2s, box-shadow .2s;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,162,39,.15);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

.form-section {
  background: var(--gold-xlight);
  border-radius: 6px; padding: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(201,162,39,.2);
}
.form-section-title {
  font-size: 14px; font-weight: 700; color: var(--gold-dark);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .18s; text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Botão principal: dourado */
.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, #B8920E 100%);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(201,162,39,.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #D4AF37 0%, var(--gold) 100%);
  box-shadow: 0 4px 16px rgba(201,162,39,.4);
  transform: translateY(-1px);
}

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #b45309; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gold);
  color: var(--gold-dark);
}
.btn-outline:hover { background: var(--gold-xlight); }

.btn-outline-gray {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline-gray:hover { background: var(--gray-50); }

.btn-sm  { padding: 6px 12px; font-size: 12px; }
.btn-xs  { padding: 4px 8px; font-size: 11px; }
.btn-icon { padding: 8px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── TABLE ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--ink);
  color: var(--gold);
  padding: 10px 12px; text-align: left;
  font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 2px solid var(--gold);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; color: var(--gray-700); }
tr:hover td { background: var(--gold-xlight); }

/* ─── BADGES ─── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-gray    { background: var(--gray-200);      color: var(--gray-600); }
.badge-gold    { background: var(--gold-light);    color: var(--gold-dark); }

/* ─── STATUS MESSAGES ─── */
.status { padding: 12px 16px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; display: none; }
.status.ok   { display: block; background: var(--success-light); color: var(--success); border: 1px solid #a7f3d0; }
.status.er   { display: block; background: var(--danger-light);  color: var(--danger);  border: 1px solid #fca5a5; }
.status.wt   { display: block; background: var(--warning-light); color: var(--warning); border: 1px solid #fcd34d; }
.status.info { display: block; background: var(--info-light);    color: var(--info);    border: 1px solid #67e8f9; }

/* ─── TABS ─── */
.tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 20px; cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--gray-500); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .2s;
}
.tab:hover { color: var(--gold-dark); }
.tab.active { color: var(--gold-dark); border-bottom-color: var(--gold); font-weight: 700; }

.pane { display: none; }
.pane.active { display: block; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.6); z-index: 1000;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 14px;
  width: 90%; max-width: 700px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.4), 0 0 0 1px rgba(201,162,39,.15);
}
.modal-header {
  padding: 20px; border-bottom: 1px solid var(--gold-light);
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(to right, var(--ink) 0%, #1a1500 100%);
  border-radius: 14px 14px 0 0;
}
.modal-header h3 { font-size: 16px; color: var(--gold); font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--silver); }
.modal-close:hover { color: var(--gold); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--gold-light); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-400); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── LOADING ─── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(201,162,39,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── FILE INPUT ─── */
.file-input-wrap { position: relative; }
.file-input-wrap input[type="file"] { padding: 8px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
}

/* ─── UTILITIES ─── */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-500); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── FILTERS BAR ─── */
.filters-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters-bar select, .filters-bar input { max-width: 220px; }

/* ─── CERT INFO ─── */
.cert-info {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--success-light);
  border-radius: 6px; font-size: 12px; color: var(--success);
}
.cert-info.none { background: var(--warning-light); color: var(--warning); }

/* ─── NAV LINKS ─── */
a.nav-item { text-decoration: none; }

/* ─── LC116 SELECTION ─── */
.lc116-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; transition: background .15s;
  border-bottom: 1px solid var(--gray-100); font-size: 13px;
}
.lc116-item:hover { background: var(--gold-xlight); }
.lc116-item.selected { background: var(--gold-light); }
.lc116-item input[type="checkbox"] { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }
.lc116-item .lc-code { font-weight: 700; color: var(--gold-dark); min-width: 50px; }
.lc116-item .lc-desc { flex: 1; color: var(--gray-700); font-size: 12px; }
.lc116-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--gold-light); color: var(--gold-dark);
  padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
}
.lc116-tag .remove {
  cursor: pointer; font-weight: bold; color: var(--danger); margin-left: 2px;
  font-size: 13px; line-height: 1;
}
.lc116-tag .remove:hover { color: var(--danger); }
.lc116-grupo-header {
  padding: 6px 12px; background: var(--gray-100);
  font-weight: 700; font-size: 11px; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .5px;
  position: sticky; top: 0;
}

/* ─── PAGE (ensure display toggling works) ─── */
.page { display: none; }
.page.active { display: block; }

/* ═══ ACTION BUTTONS — ultra-compactos (classe .ab) ═══
   Usados na coluna "Ações" das tabelas de notas.
   Todos na mesma linha, sem quebra desnecessária.
*/
.acoes-td { padding: 6px 8px !important; }

.acoes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

/* Botão-base compacto */
.ab {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.4;
}
.ab:disabled { opacity: .45; cursor: not-allowed; }

/* Variantes */
.ab-primary  { background: var(--gold); color: var(--ink); }
.ab-primary:hover  { background: #D4AF37; box-shadow: 0 2px 8px rgba(201,162,39,.35); transform: translateY(-1px); }

.ab-outline  { background: white; border-color: var(--gray-300); color: var(--gray-700); }
.ab-outline:hover  { border-color: var(--gold); color: var(--gold-dark); background: var(--gold-xlight); }

.ab-gold     { background: var(--gold-xlight); border-color: var(--gold); color: var(--gold-dark); }
.ab-gold:hover     { background: var(--gold-light); }

.ab-blue     { background: #EFF6FF; border-color: #3B82F6; color: #1D4ED8; }
.ab-blue:hover     { background: #DBEAFE; }

.ab-purple   { background: #FAF5FF; border-color: #7C3AED; color: #5B21B6; }
.ab-purple:hover   { background: #EDE9FE; }

.ab-teal     { background: #F0FFF4; border-color: #059669; color: #065F46; }
.ab-teal:hover     { background: #D1FAE5; }

.ab-gray     { background: var(--gray-100); border-color: var(--gray-300); color: var(--gray-600); }
.ab-gray:hover     { background: var(--gray-200); }

.ab-warn     { background: var(--warning-light); border-color: var(--warning); color: #92400E; }
.ab-warn:hover     { background: #FDE68A; }

.ab-danger   { background: var(--danger-light); border-color: var(--danger); color: #991B1B; }
.ab-danger:hover   { background: #FECACA; }

/* Botão ícone só (lixeira) */
.ab-danger-icon {
  background: transparent; border-color: var(--danger);
  color: var(--danger); padding: 4px 7px;
  font-size: 13px;
}
.ab-danger-icon:hover { background: var(--danger); color: white; }

/* ─── RESPONSIVO: celular — botões empilham mas ficam menores ─── */
@media (max-width: 640px) {
  .acoes-row { gap: 3px; }
  .ab { padding: 3px 6px; font-size: 10px; }
  .ab-danger-icon { padding: 3px 6px; font-size: 12px; }
  /* Tabela de notas: scroll horizontal no mobile */
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

/* ─── SCROLLBAR SOALHE ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: rgba(201,162,39,.4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ─── GOLD DIVIDER / ACENTO ─── */
.gold-accent { display: block; width: 36px; height: 3px; background: var(--gold); border-radius: 2px; margin: 8px auto 0; }

/* ─── TOPBAR MOBILE TOGGLE ─── */
.sidebar-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-600); }
@media (max-width: 768px) { .sidebar-toggle { display: block; } }
