:root {
  --red-700: #b91c1c;
  --red-600: #dc2626;
  --red-500: #ef4444;
  --red-050: #fef2f2;
  --gray-950: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-050: #f9fafb;
  --white: #ffffff;
  --primary: #2563eb;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --info: #6366f1;
  --green: #16a34a;
  --yellow: #d97706;
  --blue: #2563eb;
  --purple: #7c3aed;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
  --radius: 8px;
  --sidebar-width: 264px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--gray-050);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--gray-950);
  background: var(--gray-050);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--gray-200);
  background: var(--white);
}

.brand {
  padding: 24px;
  border-bottom: 1px solid var(--gray-100);
}

.brand strong {
  display: block;
  color: var(--red-600);
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 900;
}

.brand strong span {
  color: var(--gray-950);
  margin-left: 4px;
}

.brand small,
.sidebar-user small,
.eyebrow {
  display: block;
  color: var(--gray-400);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding: 16px;
}

.sidebar-nav a {
  border-radius: var(--radius);
  color: var(--gray-600);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 12px;
  transition: background 160ms ease, color 160ms ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--red-050);
  color: var(--red-700);
}

.sidebar-nav a[aria-disabled="true"] {
  opacity: 0.72;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--gray-100);
}

.avatar {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 0.75rem;
  font-weight: 900;
}

.sidebar-user strong {
  display: block;
  font-size: 0.85rem;
}

.app-shell {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.module-root {
  min-height: 100vh;
}

.loading-state {
  padding: 32px;
  color: var(--gray-500);
  font-weight: 700;
}

.module {
  padding: 28px;
}

.module-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 22px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.module-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--gray-500);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-actions,
.modal-actions,
.section-title-row,
.board-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions > * {
  white-space: nowrap;
}

.module-header h1,
.kanban-title-row h2,
.panel-header h2,
.modal-header h2 {
  margin: 0;
  color: var(--gray-950);
  line-height: 1.12;
}

.module-header h1 {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
}

.module-subtitle,
.kanban-title-row p,
.panel-header p,
.modal-header p {
  margin: 6px 0 0;
  color: var(--gray-500);
  font-size: 0.92rem;
}

.header-actions,
.modal-actions,
.section-title-row,
.board-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 850;
  min-height: 38px;
  padding: 0 14px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-button {
  background: var(--red-600);
  color: var(--white);
}

.primary-button:hover {
  background: var(--red-700);
}

.secondary-button {
  background: var(--gray-950);
  color: var(--white);
}

.secondary-button:hover {
  background: var(--gray-800);
}

.ghost-button {
  background: var(--white);
  border-color: var(--gray-200);
  color: var(--gray-700);
}

.ghost-button:hover {
  background: var(--gray-050);
  border-color: var(--gray-300);
}

.ghost-button.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.75rem;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  background: var(--gray-100);
  color: var(--gray-600);
  text-transform: uppercase;
}

.icon-button:hover {
  background: var(--red-050);
  color: var(--red-700);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 24px;
  background: rgba(17, 24, 39, 0.58);
}

.modal.is-open {
  display: flex;
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(90vh, 880px);
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.modal-card.large {
  width: min(860px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--gray-100);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.form-grid.one-column {
  grid-template-columns: 1fr;
}

.nested-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

label span,
.search-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--gray-500);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-950);
  outline: none;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red-500);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.09);
}

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

.form-section {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-050);
  padding: 14px;
}

.equipment-editor {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.equipment-row {
  display: grid;
  grid-template-columns: 1.5fr 0.7fr 0.9fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.toast-area {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 40px));
}

.toast {
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--red-600);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  color: var(--gray-800);
  padding: 12px 14px;
}

.toast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gray-950);
}

.toast.success {
  border-left-color: var(--green);
}

.toast.warning {
  border-left-color: var(--yellow);
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    display: none;
  }

  .module {
    padding: 18px;
  }

  .module-header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .header-actions > * {
    flex: 1 1 150px;
  }

  .form-grid,
  .nested-grid,
  .equipment-row {
    grid-template-columns: 1fr;
  }
}

/* Sidebar hidden state (login) */
.sidebar-hidden { display: none; }
.sidebar-hidden + .app-shell { margin-left: 0; }

/* Logout button */
.logout-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--red-600); }

/* Generic buttons (used by empresas, equipamentos, etc.) */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.btn-primary { background: var(--red-600, #dc2626); color: #fff; border-color: var(--red-600, #dc2626); }
.btn-primary:hover { background: var(--red-700, #b91c1c); }
.btn-secondary { background: #fff; color: var(--text-secondary, #374151); border-color: var(--border-color, #d1d5db); }
.btn-secondary:hover { background: var(--bg-secondary, #f9fafb); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn .icon { font-size: 18px; line-height: 0; }

/* Modal base (used generically) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.58);
  z-index: -1;
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border-color, #e5e7eb);
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  max-height: 90vh;
  overflow-y: auto;
  margin: 32px auto;
  animation: modalIn 0.2s ease;
}
.modal-content.modal-large { max-width: 700px; }
.modal-content.modal-xlarge { max-width: 900px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.modal-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary, #9ca3af);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary, #1f2937); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Empty state */
.empty-state {
  padding: 32px;
  color: var(--text-secondary, #9ca3af);
  font-weight: 600;
  text-align: center;
  font-size: 14px;
}
