:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #f0f2f5;
  --border: #e1e4e8;
  --text: #1a1d23;
  --text2: #5a6172;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --gray: #6b7280;
  --blue: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #161b22;
    --surface2: #1c2128;
    --border: #30363d;
    --text: #e6edf3;
    --text2: #8b949e;
    --shadow: 0 1px 4px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  }
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text2: #8b949e;
  --shadow: 0 1px 4px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* HEADER COMUM */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.logo-sub {
  font-size: 11px;
  color: var(--text2);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BOTÕES COMUNS */
.btn-theme {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.btn-theme:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-auth {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-auth:hover {
  background: var(--accent-hover);
}

.btn-auth.logado {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* TABS COMUNS */
.tabs {
  display: flex;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  border: none;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
  color: var(--text);
}

.tab.ativo {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* TOAST E NOTIFICAÇÕES */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastIn .2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

/* BADGES COMUNS */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.badge[data-status="A fazer"]      { background: #f3f4f6; color: #6b7280; }
.badge[data-status="Em andamento"] { background: #dbeafe; color: #1d4ed8; }
.badge[data-status="Concluído"]    { background: #dcfce7; color: #15803d; }
.badge[data-status="Bloqueado"]    { background: #fee2e2; color: #b91c1c; }

.badge[data-status="Aberta"]       { background: #fee2e2; color: #b91c1c; }
.badge[data-status="Em análise"]   { background: #fef3c7; color: #92400e; }
.badge[data-status="Resolvida"]    { background: #dcfce7; color: #15803d; }

[data-theme="dark"] .badge[data-status="Aberta"]       { background: #450a0a; color: #f87171; }
[data-theme="dark"] .badge[data-status="Em análise"]   { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge[data-status="Resolvida"]    { background: #14532d; color: #4ade80; }

.badge[data-cat="Manutenção"]      { background: #fef3c7; color: #92400e; }
.badge[data-cat="Gestão"]          { background: #dbeafe; color: #1e40af; }
.badge[data-cat="Melhoria"]        { background: #dcfce7; color: #166534; }
.badge[data-cat="Segurança"]       { background: #fee2e2; color: #991b1b; }

.badge[data-pri="Alta"]   { background: #fee2e2; color: #b91c1c; }
.badge[data-pri="Média"]  { background: #fef3c7; color: #92400e; }
.badge[data-pri="Baixa"]  { background: #f0fdf4; color: #166534; }

[data-theme="dark"] .badge[data-status="A fazer"]      { background: #374151; color: #9ca3af; }
[data-theme="dark"] .badge[data-status="Em andamento"] { background: #1e3a5f; color: #60a5fa; }
[data-theme="dark"] .badge[data-status="Concluído"]    { background: #14532d; color: #4ade80; }
[data-theme="dark"] .badge[data-status="Bloqueado"]    { background: #450a0a; color: #f87171; }

/* MODAL & FORMS GLOBAL SYSTEM */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  animation: fadeInOverlay .2s ease-out;
}
.modal-overlay.aberto {
  display: flex;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  margin: auto;
  border: 1px solid var(--border);
  overflow: hidden;
  animation: modalScaleUp .25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-titulo, .modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text2);
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}

.modal-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* FORM FIELDS COMUNS */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  margin-bottom: 0;
}

.field input, .field select, .field textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.field-full {
  grid-column: 1 / -1;
}

/* BOTÕES ESPECÍFICOS DE FORM */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: #fee2e2;
  color: var(--red);
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-danger:hover {
  background: #fecaca;
  border-color: #fca5a5;
}

/* RESPONSIVIDADE MOBILE-FIRST PARA MODAL */
@media (max-width: 600px) {
  .modal-overlay {
    padding: 0;
  }
  .modal {
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    margin: 0;
  }
  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
  }
  .modal-footer {
    position: sticky;
    bottom: 0;
    width: 100%;
    z-index: 10;
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
}
