@import url('https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800&family=Playfair+Display:wght@600;700&family=JetBrains+Mono:wght@400;600&display=swap');
/* ── Variáveis ───────────────────────────────────────────────── */
:root {
  --bg:           #E0D6D4;
  --bg-card:      #EDE6E3;
  --bg-input:     #D8CECA;
  --primary:      #8B1B3F;
  --primary-dk:   #5E0521;
  --primary-lt:   #B5406A;
  --primary-pale: #F5ECF0;
  --border:       #C9BBBA;
  --border-lt:    #D8CECA;
  --text:         #1A0A10;
  --text-md:      #4A2030;
  --text-muted:   #8A6070;
  --white:        #FAF5F4;
  --shadow:       0 2px 12px rgba(94,5,33,.10);
  --shadow-lg:    0 8px 40px rgba(94,5,33,.18);
  --radius:       10px;
  --radius-sm:    6px;
  --radius-pill:  20px;
  --font:         'Figtree', sans-serif;
  --font-display: 'Playfair Display', serif;
  --font-mono:    'JetBrains Mono', monospace;
  --tr:           all .18s ease;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select { font-family: var(--font); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-lt); }

/* ── Loader ──────────────────────────────────────────────────── */
#app-loader {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; z-index: 9999;
}
.loader-logo { font-family: var(--font-display); font-size: 2rem; color: var(--primary); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Topbar ──────────────────────────────────────────────────── */
#topbar { position: sticky; top: 0; z-index: 100; background: var(--primary-dk); border-bottom: 2px solid var(--primary); padding: 0 2rem; box-shadow: 0 2px 16px rgba(94,5,33,.3); }
.topbar-inner { max-width: 1440px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 55px; height: 55px; background: var(--primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; border: 1px solid var(--primary-lt); }
.brand-name { font-family: var(--font-display); font-size: 1.6rem; color: var(--white); letter-spacing: -.01em; line-height: 1; }
.brand-sub { font-family: var(--font-mono); font-size: 9px; color: rgba(224,214,212,.4); letter-spacing: .14em; margin-top: 2px; }
.btn-new { display: flex; align-items: center; gap: 6px; background: var(--primary); color: var(--white); border: 1px solid var(--primary-lt); border-radius: var(--radius); padding: 9px 20px; font-size: 13px; font-weight: 700; transition: var(--tr); }
.btn-new:hover { background: var(--primary-lt); }
.btn-new .plus { font-size: 20px; line-height: 1; margin-top: -2px; }

/* ── Layout ──────────────────────────────────────────────────── */
#main { max-width: 1440px; margin: 0 auto; padding: 2rem 2rem 4rem; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; transition: var(--tr); cursor: default; box-shadow: var(--shadow); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card.featured { background: var(--primary); border-color: var(--primary-dk); }
.stat-card.featured .stat-value { color: var(--white); }
.stat-card.featured .stat-label { color: rgba(240,220,225,.65); }
.stat-value { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 5px; letter-spacing: .02em; }
.stat-card[data-status="publicado"]   .stat-value { color: #166534; }
.stat-card[data-status="atualizado"]  .stat-value { color: #1e40af; }
.stat-card[data-status="atualizando"] .stat-value { color: #92400e; }
.stat-card[data-status="criando"]     .stat-value { color: #6b21a8; }

/* ── Filters ─────────────────────────────────────────────────── */
.filters-block { margin-bottom: 1.5rem; }
.filter-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.filter-label { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); letter-spacing: .14em; text-transform: uppercase; flex-shrink: 0; min-width: 52px; }
.pill { background: transparent; border: 1px solid var(--border-lt); border-radius: var(--radius-pill); padding: 5px 14px; font-size: 12px; font-weight: 500; color: var(--text-muted); transition: var(--tr); white-space: nowrap; }
.pill:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }
.pill.active { background: var(--primary); color: var(--white); border-color: var(--primary-dk); font-weight: 700; }
.pill[data-sector="T.I"].active          { background: #1e4d7a; border-color: #133450; }
.pill[data-sector="Secretaria"].active   { background: #7a1e4d; border-color: #500d30; }
.pill[data-sector="RH"].active           { background: #1e6642; border-color: #0d4228; }
.pill[data-sector="Administração"].active{ background: #7a3d1e; border-color: #50260d; }
.pill[data-sector="Contabilidade"].active{ background: #4d1e7a; border-color: #300d50; }
.pill[data-status="publicado"].active    { background: #166534; border-color: #0d4222; }
.pill[data-status="atualizado"].active   { background: #1e40af; border-color: #1e3a8a; }
.pill[data-status="atualizando"].active  { background: #92400e; border-color: #78350f; }
.pill[data-status="criando"].active      { background: #6b21a8; border-color: #581c87; }

/* ── Search ──────────────────────────────────────────────────── */
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 15px; pointer-events: none; }
.search-input { width: 100%; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 8px 34px; font-size: 13px; color: var(--text); transition: var(--tr); outline: none; }
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139,27,63,.1); }
.btn-clear { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: var(--radius-pill); padding: 5px 14px; font-size: 12px; transition: var(--tr); }
.btn-clear:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--primary-dk); border-bottom: 2px solid var(--primary); }
thead th { padding: 12px 16px; text-align: left; font-family: var(--font-mono); font-size: 9px; font-weight: 700; color: rgba(224,214,212,.55); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--bg); transition: background .12s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--primary-pale); }
tbody td { padding: 13px 16px; vertical-align: middle; }
.doc-name { font-weight: 600; font-size: 13px; color: var(--text); }
.doc-meta { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.ver-cur { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--primary); }
.ver-pub { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.resp-cell { font-size: 13px; color: var(--text-md); }
.table-footer { padding: 10px 16px; border-top: 1px solid var(--bg); font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); background: var(--bg-card); }
.no-results { padding: 3rem; text-align: center; color: var(--text-muted); font-size: 14px; }
.loading-row td { padding: 2rem; text-align: center; }
.inline-spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; font-family: var(--font-mono); letter-spacing: .06em; white-space: nowrap; border-width: 1px; border-style: solid; }
.badge.publicado   { color: #166534; background: #dcfce7; border-color: #86efac; }
.badge.atualizado  { color: #1e40af; background: #dbeafe; border-color: #93c5fd; }
.badge.atualizando { color: #92400e; background: #fef3c7; border-color: #fcd34d; }
.badge.criando     { color: #6b21a8; background: #f3e8ff; border-color: #d8b4fe; }

/* ── Sector Tags ─────────────────────────────────────────────── */
.sector-tag { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; border-width: 1px; border-style: solid; }
.sector-tag.s-TI             { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }
.sector-tag.s-Secretaria     { color: #be185d; background: #fce7f3; border-color: #f9a8d4; }
.sector-tag.s-RH             { color: #15803d; background: #dcfce7; border-color: #bbf7d0; }
.sector-tag.s-Administracao  { color: #c2410c; background: #ffedd5; border-color: #fed7aa; }
.sector-tag.s-Contabilidade  { color: #7e22ce; background: #f3e8ff; border-color: #ddd6fe; }

/* ── Row actions ─────────────────────────────────────────────── */
.row-actions { display: flex; gap: 4px; }
.icon-btn { background: none; border: none; color: var(--text-muted); font-size: 15px; padding: 4px 6px; border-radius: var(--radius-sm); transition: var(--tr); }
.icon-btn:hover { background: var(--primary-pale); color: var(--primary); }
.file-count-btn { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted); border-radius: var(--radius-sm); padding: 4px 10px; font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 4px; transition: var(--tr); white-space: nowrap; }
.file-count-btn:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }
.file-count-btn.has-files { color: var(--primary); border-color: var(--primary); }

/* ── Modals ──────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(94,5,33,.35); backdrop-filter: blur(4px); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); transform: translateY(16px); transition: transform .2s ease; max-height: 90vh; overflow-y: auto; }
.overlay.open .modal { transform: translateY(0); }
.modal.wide { max-width: 660px; }
.modal-title { font-family: var(--font-display); font-size: 1.25rem; color: var(--primary-dk); margin-bottom: 4px; }
.modal-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 1.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 1.5rem; }
.modal-divider { border: none; border-top: 1px solid var(--border-lt); margin: 1.25rem 0; }

/* ── Form ────────────────────────────────────────────────────── */
.form-grid { display: flex; flex-direction: column; gap: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: .1em; text-transform: uppercase; }
.field input, .field select { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 9px 12px; font-size: 13px; outline: none; transition: var(--tr); width: 100%; }
.field input::placeholder { color: var(--text-muted); }
.field input:focus, .field select:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(139,27,63,.1); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: var(--radius); padding: 9px 20px; font-size: 13px; font-weight: 600; transition: var(--tr); }
.btn-secondary:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }
.btn-primary { background: var(--primary); color: var(--white); border: 1px solid var(--primary-dk); border-radius: var(--radius); padding: 9px 22px; font-size: 13px; font-weight: 700; transition: var(--tr); }
.btn-primary:hover { background: var(--primary-dk); }
.btn-primary:disabled { background: var(--border); color: var(--text-muted); border-color: var(--border); cursor: not-allowed; }
.btn-danger { background: #991b1b; color: #fecaca; border: 1px solid #7f1d1d; border-radius: var(--radius); padding: 9px 22px; font-size: 13px; font-weight: 700; transition: var(--tr); }
.btn-danger:hover { background: #7f1d1d; }

/* ── Upload Zone ─────────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.75rem; text-align: center; cursor: pointer; transition: var(--tr); background: var(--bg-card); }
.upload-zone:hover, .upload-zone.dragging { border-color: var(--primary); background: var(--primary-pale); }
.upload-icon { font-size: 2.2rem; margin-bottom: 8px; }
.upload-text { font-size: 13px; color: var(--text-muted); }
.upload-link { color: var(--primary); font-weight: 700; }
.upload-types { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-item { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.file-badge { flex-shrink: 0; padding: 2px 7px; border-radius: 4px; font-size: 9px; font-weight: 900; font-family: var(--font-mono); }
.file-badge.PDF  { background: #fee2e2; color: #dc2626; }
.file-badge.DOC  { background: #dbeafe; color: #2563eb; }
.file-badge.XLS  { background: #dcfce7; color: #16a34a; }
.file-badge.FILE { background: var(--bg); color: var(--text-muted); }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.file-download { color: var(--primary); font-size: 12px; font-weight: 700; flex-shrink: 0; padding: 2px 6px; transition: var(--tr); }
.file-download:hover { text-decoration: underline; }
.file-remove { background: none; border: none; color: var(--text-muted); font-size: 14px; padding: 2px 4px; flex-shrink: 0; transition: color .15s; }
.file-remove:hover { color: #dc2626; }

/* ── Status banner ───────────────────────────────────────────── */
.status-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 12px; }
.status-banner.publicado   { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.status-banner.atualizado  { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }
.status-banner.atualizando { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.status-banner.criando     { background: #f3e8ff; border: 1px solid #d8b4fe; color: #6b21a8; }

/* ── Detail Modal ────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.detail-cell { background: var(--bg-card); border: 1px solid var(--border-lt); border-radius: var(--radius-sm); padding: 11px 13px; }
.detail-cell-label { font-size: 9px; font-weight: 700; color: var(--text-muted); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 5px; }
.detail-cell-value { font-size: 13px; color: var(--text); }
.detail-cell-value.mono { font-family: var(--font-mono); color: var(--primary); font-weight: 600; }

/* ── Delete ──────────────────────────────────────────────────── */
.delete-center { text-align: center; }
.delete-icon { font-size: 3rem; margin-bottom: .75rem; display: block; }
.delete-title { font-family: var(--font-display); font-size: 1.2rem; color: var(--primary-dk); margin-bottom: 8px; }
.delete-sub { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 1.5rem; }

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 11px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px; animation: toastIn .22s ease; max-width: 320px; }
.toast.ok   { background: var(--primary); color: var(--white); border: 1px solid var(--primary-lt); }
.toast.err  { background: #7f1d1d; color: #fecaca; border: 1px solid #991b1b; }
.toast.info { background: #1e3a5f; color: #bfdbfe; border: 1px solid #1e40af; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 960px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } #main { padding: 1.25rem 1.25rem 3rem; } }
@media (max-width: 600px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } #topbar { padding: 0 1rem; } .detail-grid { grid-template-columns: 1fr 1fr; } .form-row { grid-template-columns: 1fr; } }

/* ── Error ──────────────────────────────────────────────── */
.field-error-input {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,.15) !important;
}
.field-error {
  font-size: 11px;
  color: #dc2626;
  margin-top: 3px;
  display: block;
}