:root {
  --bg: #F1F4F8;
  --bg-card: #FFFFFF;
  --bg-hover: #F6F9FC;
  --text-1: #1B2A38;
  --text-2: #4A5E72;
  --text-3: #8A9BAD;
  --border: #D2DCE6;
  --border-sub: #E6EDF4;
  --accent: #1B4E8A;
  --accent-light: #E8EFFE;
  --danger: #A83228;
  --success: #2A8C5E;
  --warn: #BC7010;
  --r: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,.11);
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text-1); font-size: 14px; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ---- LOGIN ---- */
.login-page { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #0F2744 0%, #1B4E8A 100%); }
.login-wrap { background: #fff; border-radius: 12px; padding: 44px 40px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 28px; }
.logo-mark { width: 40px; height: 40px; background: var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -1px; }
.logo-text strong { display: block; font-size: 15px; color: var(--text-1); }
.logo-text span { font-size: 11px; color: var(--text-3); }
.vertice-footer { font-size: 10px; color: rgba(255,255,255,.35); padding: 10px 18px 14px;
  border-top: 1px solid rgba(255,255,255,.07); text-align: center; }
.vertice-footer strong { color: rgba(255,255,255,.55); }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; color: var(--text-1); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600;
  color: var(--text-2); margin-bottom: 5px; }
.field input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--r); font-size: 14px; transition: border-color .15s; outline: none; }
.field input:focus { border-color: var(--accent); }
.error-msg { color: var(--danger); font-size: 12px; margin-bottom: 10px; min-height: 16px; }

/* ---- BUTTONS ---- */
.btn-primary { width: 100%; padding: 11px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--r); font-size: 14px; font-weight: 600;
  transition: background .15s; }
.btn-primary:hover { background: #163f73; }
.btn-primary:disabled { opacity: .6; }
.btn-secondary { padding: 8px 16px; background: transparent; color: var(--text-2);
  border: 1.5px solid var(--border); border-radius: var(--r); font-size: 13px;
  font-weight: 500; transition: all .15s; }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-2); }
.btn-danger { padding: 8px 16px; background: var(--danger); color: #fff;
  border: none; border-radius: var(--r); font-size: 13px; font-weight: 600; }
.btn-sm { padding: 5px 12px; font-size: 12px; font-weight: 600; border-radius: 4px;
  border: none; cursor: pointer; transition: opacity .15s; }
.btn-sm:hover { opacity: .85; }

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

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: #0F2744; color: #fff;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; }
.sidebar-logo { display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 14px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo img { filter: brightness(0) invert(1); }
.sidebar-logo .logo-text { text-align: center; }
.sidebar-logo .logo-text strong { display: block; font-size: 13px; color: #fff; }
.sidebar-logo .logo-text span { font-size: 10px; color: rgba(255,255,255,.45); }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  color: rgba(255,255,255,.65); font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent; transition: all .15s; cursor: pointer; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.1); border-left-color: #5B9CF6; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.user-info { font-size: 11px; color: rgba(255,255,255,.45); margin-bottom: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout { width: 100%; padding: 8px; background: rgba(255,255,255,.07); color: rgba(255,255,255,.65);
  border: 1px solid rgba(255,255,255,.1); border-radius: var(--r); font-size: 12px;
  font-weight: 500; transition: all .15s; }
.btn-logout:hover { background: rgba(255,255,255,.13); color: #fff; }

/* Main content */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }
.page-header { background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; }
.page-title { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.page-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.page-body { padding: 24px 28px; }

/* ---- STATS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-sub);
  border-radius: var(--r); padding: 16px 18px; }
.stat-n { font-size: 32px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 11px; color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card[data-c="green"] .stat-n { color: var(--success); }
.stat-card[data-c="blue"]  .stat-n { color: var(--accent); }
.stat-card[data-c="amber"] .stat-n { color: var(--warn); }
.stat-card[data-c="red"]   .stat-n { color: var(--danger); }

/* ---- ALERTS ---- */
.alerts-box { background: #FEF9E7; border: 1px solid #F5CBA7; border-radius: var(--r);
  padding: 14px 16px; margin-bottom: 20px; }
.alerts-title { font-size: 12px; font-weight: 700; color: #7D6608; margin-bottom: 8px; }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,.05); font-size: 13px; }
.alert-item:last-child { border: none; padding-bottom: 0; }
.alert-badge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 10px;
  white-space: nowrap; }
.badge-red { background: #FBEBE9; color: var(--danger); }
.badge-amber { background: #FDF2E0; color: var(--warn); }
.badge-green { background: #E6F4ED; color: var(--success); }

/* ---- TABLE ---- */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border-sub);
  border-radius: var(--r); overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border-sub); flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; padding: 8px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r); font-size: 13px; outline: none; }
.search-input:focus { border-color: var(--accent); }
.filter-select { padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: var(--r); font-size: 13px; background: var(--bg-card);
  color: var(--text-1); outline: none; cursor: pointer; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: var(--text-3);
  background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border-sub); cursor: pointer;
  transition: background .1s; }
tbody tr:last-child { border: none; }
tbody tr:hover { background: var(--bg-hover); }
td { padding: 11px 14px; font-size: 13px; }
.td-name { font-weight: 600; color: var(--text-1); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-forn { color: var(--text-2); max-width: 180px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* Status badge */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap; }

/* Vencimento pill */
.venc-pill { font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.venc-ok   { background: #E6F4ED; color: var(--success); }
.venc-warn { background: #FDF2E0; color: var(--warn); }
.venc-late { background: #FBEBE9; color: var(--danger); }
.venc-none { background: var(--bg); color: var(--text-3); }

/* ---- MODAL / DETAIL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: flex-start; justify-content: flex-end;
  opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-panel { background: var(--bg-card); width: 560px; max-width: 96vw;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,.18);
  transform: translateX(40px); transition: transform .22s; }
.modal-overlay.open .modal-panel { transform: translateX(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg-card); z-index: 10; }
.modal-head-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-3);
  cursor: pointer; padding: 4px 8px; border-radius: 4px; line-height: 1; }
.modal-close:hover { background: var(--bg-hover); color: var(--text-1); }
.modal-body { padding: 22px; flex: 1; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; position: sticky;
  bottom: 0; background: var(--bg-card); }

/* Form fields in modal */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px; }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--border);
  border-radius: var(--r); font-size: 13px; font-family: inherit;
  background: var(--bg-card); color: var(--text-1); outline: none; transition: border-color .15s; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--accent); }
.fld textarea { resize: vertical; min-height: 80px; }
.fld.fld-check { display: flex; align-items: center; gap: 8px; padding-top: 20px; }
.fld.fld-check input { width: auto; }
.fld.fld-check label { margin: 0; text-transform: none; font-size: 13px; font-weight: 500;
  color: var(--text-1); letter-spacing: 0; }
.section-sep { border: none; border-top: 1px solid var(--border-sub); margin: 18px 0; }
.section-label { font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-3); margin-bottom: 12px; }

/* History */
.history-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-sub); }
.history-item:last-child { border: none; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  margin-top: 5px; flex-shrink: 0; }
.history-text { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.history-text strong { color: var(--text-1); }
.history-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Files */
.file-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg); border-radius: var(--r); margin-bottom: 8px; }
.file-icon { font-size: 20px; flex-shrink: 0; }
.file-name { font-size: 13px; font-weight: 600; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 11px; color: var(--text-3); }
.upload-zone { border: 2px dashed var(--border); border-radius: var(--r);
  padding: 24px; text-align: center; color: var(--text-3); font-size: 13px;
  cursor: pointer; transition: all .15s; }
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent);
  background: var(--accent-light); color: var(--accent); }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text-1); color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 999; transform: translateY(60px);
  opacity: 0; transition: all .25s; pointer-events: none; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border-sub); margin-bottom: 18px; }
.tab { padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-3);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Responsive */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-panel { width: 100vw; }
}
