/* ============================================================
   Tridminas · Sistema de Gerenciamento de EPI
   Paleta alinhada aos outros sistemas internos (gestao/rei):
   fundo navy escuro + laranja como cor de marca, com
   vermelho/amarelo/verde/azul reservados para status.
   ============================================================ */

:root {
  --bg-950: #0a0d16;
  --bg-900: #10141f;
  --bg-800: #161b28;
  --bg-700: #1c2231;
  --bg-600: #262d3f;
  --border: #262c3d;
  --border-soft: #1e2433;

  --text-primary: #f5f6fa;
  --text-secondary: #c7ccd6;
  --text-muted: #8b93a7;
  --text-faint: #5d6577;

  --brand: #ff6b35;
  --brand-bright: #ff8552;
  --brand-dim: #cc4f1f;

  --success: #22c55e;
  --danger: #ef4444;
  --warning: #eab308;
  --info: #3b82f6;

  --radius: 8px;
  --radius-lg: 12px;
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-950);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brand); color: #fff; }
a { color: inherit; }

.hazard-strip {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--brand-dim), var(--brand), var(--brand-bright));
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background: var(--bg-950);
}

.login-visual {
  flex: 1.1;
  position: relative;
  background: radial-gradient(circle at 20% 20%, rgba(255, 107, 53, 0.14), transparent 55%), var(--bg-900);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 56px;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.login-visual .brand { position: relative; z-index: 1; }

.login-visual .brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 15px;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 28px;
}
.login-visual .brand-mark .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 12px var(--brand);
}

.login-visual h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 58px;
  line-height: 0.98;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0 0 18px;
  text-transform: uppercase;
}
.login-visual h1 em { font-style: normal; color: var(--brand); }

.login-visual p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 440px;
  line-height: 1.6;
  margin: 0 0 32px;
}

.login-visual .stat-row { display: flex; gap: 28px; position: relative; z-index: 1; }
.login-visual .stat-row div { color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.login-visual .stat-row strong { display: block; font-family: var(--font-display); font-size: 26px; color: var(--text-primary); font-weight: 700; }

.login-panel {
  flex: 0.85;
  background: var(--bg-950);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card { width: 100%; max-width: 360px; }
.login-card .eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 6px;
}
.login-card h2 { font-size: 24px; margin: 0 0 28px; font-weight: 700; color: var(--text-primary); }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  background: var(--bg-800);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  transition: border-color 0.15s;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-bright); box-shadow: var(--shadow-sm); }
.btn-dark { background: var(--bg-700); color: var(--text-primary); border: 1px solid var(--border); }
.btn-dark:hover { background: var(--bg-600); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--text-faint); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }
.login-hint { margin-top: 22px; font-size: 12px; color: var(--text-faint); line-height: 1.6; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  background: var(--bg-900);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.sidebar .brand { padding: 22px 22px 18px; border-bottom: 1px solid var(--border); }
.sidebar .brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 15px;
  display: flex; align-items: center; gap: 8px;
}
.sidebar .brand-mark .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.sidebar .brand-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; letter-spacing: 0.03em; }

.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--bg-800); color: #fff; }
.nav-item.active { background: rgba(255, 107, 53, 0.12); color: var(--brand-bright); }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand); border-radius: 0 3px 3px 0;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-chip .who { min-width: 0; }
.user-chip .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: 11px; color: var(--text-faint); }
.sidebar-footer .links { display: flex; gap: 6px; margin-top: 10px; }
.sidebar-footer .links button {
  flex: 1; background: var(--bg-800); border: 1px solid var(--border); color: var(--text-secondary);
  padding: 7px; border-radius: var(--radius); font-size: 11.5px; cursor: pointer;
}
.sidebar-footer .links button:hover { background: var(--bg-700); color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-950);
}

.topbar {
  height: 60px;
  flex-shrink: 0;
  background: var(--bg-900);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 26px;
  gap: 20px;
}
.topbar h1 { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: 0.01em; color: var(--text-primary); }
.topbar .sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
#topbarActions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

.content { flex: 1; overflow-y: auto; padding: 26px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }

.card {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; }

.kpi-card { position: relative; overflow: hidden; }
.kpi-card .kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.kpi-card .kpi-value { font-family: var(--font-display); font-size: 40px; font-weight: 700; margin-top: 6px; line-height: 1; color: var(--text-primary); }
.kpi-card .kpi-foot { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.kpi-card.accent-yellow .kpi-value { color: var(--brand); }
.kpi-card.accent-red .kpi-value { color: var(--danger); }
.kpi-card.accent-green .kpi-value { color: var(--success); }

/* ---------- Alerts ---------- */
.alert-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.28);
  border-left: 4px solid var(--warning);
  padding: 13px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.alert-banner strong { font-weight: 700; color: var(--text-primary); }
.alert-banner.danger { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.28); }
.alert-banner .icon { flex-shrink: 0; color: var(--warning); }
.alert-banner.danger .icon { color: var(--danger); }

.alert-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.alert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius); background: var(--bg-700);
  border-left: 3px solid var(--warning);
  font-size: 13px;
}
.alert-row.overdue { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.07); }
.alert-row .who { font-weight: 600; color: var(--text-primary); }
.alert-row .what { color: var(--text-muted); }
.pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  background: rgba(234, 179, 8, 0.16); color: #fbbf24; white-space: nowrap;
}
.pill.overdue { background: rgba(239, 68, 68, 0.16); color: #f87171; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 700; padding: 10px 12px; border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; color: var(--text-secondary); }
tbody tr:hover { background: var(--bg-700); }
tbody tr:last-child td { border-bottom: none; }
tbody td strong { color: var(--text-primary); }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

.status-tag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.02em; }
.status-tag.ativo { background: rgba(34, 197, 94, 0.14); color: #4ade80; }
.status-tag.devolvido { background: rgba(139, 147, 167, 0.14); color: var(--text-muted); }
.status-tag.baixo { background: rgba(239, 68, 68, 0.14); color: #f87171; }
.status-tag.ok { background: rgba(34, 197, 94, 0.14); color: #4ade80; }

.icon-btn {
  background: none; border: none; cursor: pointer; padding: 6px; border-radius: var(--radius);
  color: var(--text-muted); display: inline-flex;
}
.icon-btn:hover { background: var(--bg-700); color: var(--text-primary); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.toolbar select {
  padding: 9px 12px; border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--bg-800); color: var(--text-primary); font-size: 13px;
}
.search-box { position: relative; }
.search-box input { padding-left: 34px; width: 260px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(5, 7, 12, 0.7);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 700; color: var(--text-primary); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.close-x { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; line-height: 1; }
.close-x:hover { color: var(--text-primary); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--bg-700); color: #fff;
  border: 1px solid var(--border);
  padding: 13px 18px; border-radius: var(--radius); font-size: 13.5px; box-shadow: var(--shadow-lg);
  z-index: 200; display: flex; align-items: center; gap: 10px; transform: translateY(20px); opacity: 0;
  transition: transform 0.2s, opacity 0.2s; border-left: 4px solid var(--brand);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-left-color: var(--danger); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { margin: 4px 0 14px; font-size: 13.5px; }

/* ---------- Chart wrappers ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }

/* ---------- Ficha (printable) ---------- */
.ficha-view { max-width: 900px; margin: 0 auto; background: #fff; color: #1a1f2e; }
.ficha-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--brand); padding-bottom: 14px; margin-bottom: 18px; }
.ficha-header h2 { font-family: var(--font-display); text-transform: uppercase; margin: 0; font-size: 22px; color: #1a1f2e; }
.ficha-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 20px; margin-bottom: 18px; font-size: 13px; color: #1a1f2e; }
.ficha-meta-grid div span { display: block; font-size: 10.5px; text-transform: uppercase; color: #8b93a7; letter-spacing: 0.04em; margin-bottom: 2px; }
.termo-box { font-size: 11.5px; line-height: 1.6; background: #f4f6f8; border: 1px solid #e2e6ec; padding: 14px; border-radius: var(--radius); margin-bottom: 20px; color: #333c4d; }
.ficha-view .card-title { color: #5d6577; }
.ficha-view table thead th { color: #8b93a7; border-bottom-color: #e2e6ec; }
.ficha-view table tbody td { color: #333c4d; border-bottom-color: #eef1f4; }
.ficha-view table tbody td strong { color: #1a1f2e; }

@media print {
  .no-print { display: none !important; }
  .content { overflow: visible !important; padding: 0 !important; }
  body { background: #fff; }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 90; height: 100vh; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  #globalSearch { width: 140px; }
}

.hidden { display: none !important; }
