@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ──────────────────────────────────────────────
   DESIGN TOKENS
   ────────────────────────────────────────────── */
:root {
  --orange: #E85F1C;
  --orange-dark: #C44C13;
  --orange-light: #FFF3ED;
  --blue: #1A365D;
  --blue-soft: #2B4C7E;
  --blue-light: #E8EDF4;
  --bg: #F0F4F8;
  --text: #111827;
  --muted: #6B7280;
  --line: #E2E8F0;
  --card: #FFFFFF;
  --success: #059669;
  --success-bg: #ECFDF5;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --info: #2563EB;
  --info-bg: #EFF6FF;
  --sidebar-w: 272px;
  --topbar-h: 0px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-glow: 0 0 20px rgba(232,95,28,0.15);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ──────────────────────────────────────────────
   RESET & GLOBALS
   ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; transition: var(--transition); }
img { max-width: 100%; }
::selection { background: var(--orange); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ──────────────────────────────────────────────
   ANIMATIONS
   ────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(100%) scale(0.9); }
}
@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.animate-in { animation: fadeInUp 0.4s ease-out both; }
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }

/* ──────────────────────────────────────────────
   APP SHELL
   ────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}
.main-content {
  padding: 24px 32px 60px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  animation: fadeIn 0.3s ease-out;
}

/* ──────────────────────────────────────────────
   SIDEBAR
   ────────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(175deg, #0F2441 0%, var(--blue) 40%, var(--blue-soft) 100%);
  color: #fff;
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.08);
  z-index: 100;
}
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

/* Brand */
.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
  padding: 0 4px;
}
.brand-dot {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--orange), #FF8A50);
  box-shadow: 0 4px 12px rgba(232,95,28,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-dot svg { width: 20px; height: 20px; fill: #fff; }
.brand-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.brand-subtitle {
  color: rgba(255,255,255,.5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Menu */
.menu {
  display: grid;
  gap: 4px;
  flex: 1;
}
.menu-link {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
  border: 1px solid transparent;
  position: relative;
}
.menu-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: var(--transition);
}
.menu-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  transform: translateX(3px);
}
.menu-link:hover svg { opacity: 1; }
.menu-link.active {
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(232,95,28,0.3);
  border-color: rgba(255,255,255,0.1);
}
.menu-link.active svg { opacity: 1; }
.menu-separator {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 4px;
}

/* Sidebar Note / User Info */
.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,.9);
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
}
.sidebar-note strong {
  color: #fff;
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}
.sidebar-note p { margin: 0; opacity: 0.6; font-size: 12px; }

/* Mobile hamburger */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--blue);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  color: #fff;
}
.mobile-toggle svg { width: 22px; height: 22px; fill: #fff; }

/* ──────────────────────────────────────────────
   TOPBAR
   ────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
}
.topbar-left { flex: 1; }
.topbar-greeting {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-greeting svg { width: 16px; height: 16px; }
.eyebrow {
  color: var(--orange);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 6px;
}
h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--blue);
  line-height: 1.2;
}
h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--blue);
}
.muted { color: var(--muted); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--orange-light), #FFE8D6);
  color: var(--orange-dark);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  border: 1px solid rgba(232,95,28,0.18);
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.35;
  box-sizing: border-box;
}

.chip.phase-chip {
  background: #FFF7ED;
  color: #C2410C;
  border: 1px solid #FED7AA;
  font-size: 10.5px;
  padding: 3px 9px;
  box-shadow: 0 1px 2px rgba(232,95,28,0.06);
}

.service-item-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px 10px;
  width: 100%;
  min-width: 0;
}

.service-item-title {
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
  word-break: normal;
  overflow-wrap: break-word;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search bar in topbar */
.topbar-search {
  position: relative;
}
.topbar-search input {
  width: 260px;
  padding: 9px 14px 9px 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.topbar-search input:focus {
  width: 320px;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,95,28,0.1);
  outline: none;
}
.topbar-search input::placeholder { color: #A0AEC0; }
.topbar-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #A0AEC0;
  pointer-events: none;
}
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 360px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
  z-index: 500;
  display: none;
  max-height: 400px;
  overflow-y: auto;
  animation: fadeInUp 0.2s ease-out;
}
.search-results-dropdown.visible { display: block; }
.search-group-title {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.search-result-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  border-bottom: 1px solid #F7FAFC;
}
.search-result-item:hover { background: var(--orange-light); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item .sr-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.search-result-item .sr-icon svg { width: 16px; height: 16px; }
.search-result-item .sr-icon.proposals { background: var(--info-bg); color: var(--info); }
.search-result-item .sr-icon.clients { background: var(--success-bg); color: var(--success); }
.search-result-item .sr-icon.services { background: var(--warning-bg); color: var(--warning); }
.search-result-item .sr-text { flex: 1; }
.search-result-item .sr-text strong { display: block; font-size: 13px; font-weight: 600; }
.search-result-item .sr-text small { color: var(--muted); font-size: 11px; }
.search-no-results {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ──────────────────────────────────────────────
   PANELS & CARDS
   ────────────────────────────────────────────── */
.panel, .card, .login-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0,0,0,0.03);
  transition: box-shadow var(--transition), transform var(--transition);
}
.panel:hover { box-shadow: var(--shadow-lg); }
.panel { padding: 24px; margin-bottom: 24px; }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 { display: flex; align-items: center; gap: 8px; }
.panel-header h2 svg { width: 20px; height: 20px; color: var(--orange); flex-shrink: 0; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card.mini {
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0%, #FAFBFC 100%);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.card.mini:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(232,95,28,0.15);
}
.card.mini::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--orange), #FF8A50);
  opacity: 0;
  transition: var(--transition);
}
.card.mini:hover::before { opacity: 1; }
.card.mini span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card.mini strong {
  font-size: 26px;
  display: block;
  margin-top: 8px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.015em;
  animation: countUp 0.5s ease-out both;
}
.card.mini small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.card.mini .card-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.12;
}
.card.mini .card-icon svg { width: 24px; height: 24px; }

/* ──────────────────────────────────────────────
   GRIDS
   ────────────────────────────────────────────── */
.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  width: 100%;
}
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.form-grid.compact { grid-template-columns: 1fr; gap: 14px; }

/* ──────────────────────────────────────────────
   FORMS
   ────────────────────────────────────────────── */
label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  width: 100%;
}
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #D1D5DB;
  background: #FAFBFC;
  transition: var(--transition);
  font-size: 14px;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(232,95,28,0.08);
}
input::placeholder, textarea::placeholder { color: #A0AEC0; }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* ──────────────────────────────────────────────
   BUTTONS
   ────────────────────────────────────────────── */
.primary-button, .secondary-button, .danger-button, .success-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.primary-button svg, .secondary-button svg, .danger-button svg, .success-button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.primary-button {
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(232,95,28,0.25);
  border: 1px solid rgba(255,255,255,0.15);
}
.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232,95,28,0.35);
}
.primary-button:active { transform: translateY(0); }
.secondary-button {
  background: #fff;
  color: var(--blue);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.secondary-button:hover { background: #F8FAFC; border-color: #CBD5E1; transform: translateY(-1px); }
.danger-button {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #FEE2E2;
}
.danger-button:hover { background: #FEE2E2; transform: translateY(-1px); }
.success-button {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #A7F3D0;
}
.success-button:hover { background: #D1FAE5; transform: translateY(-1px); }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* Icon buttons */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--muted);
  padding: 0;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--orange); color: var(--orange); background: var(--orange-light); transform: translateY(-1px); }
.icon-btn.danger:hover { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.icon-btn.success:hover { border-color: var(--success); color: var(--success); background: var(--success-bg); }

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--blue);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
  z-index: 50;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ──────────────────────────────────────────────
   TABLES
   ────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.estimate-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  table-layout: auto;
}
.estimate-table th {
  background: #F8FAFC;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}
.estimate-table th.sortable { cursor: pointer; user-select: none; }
.estimate-table th.sortable:hover { color: var(--orange); }
.estimate-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #F1F5F9;
  background: #fff;
  font-size: 13px;
  vertical-align: middle;
  transition: background var(--transition-fast);
}
.estimate-table tr:last-child td { border-bottom: none; }
.estimate-table tbody tr:hover td { background: #FAFBFE; }

/* Inputs e selects dentro de tabelas */
.estimate-table input,
.estimate-table select {
  padding: 7px 10px;
  font-size: 13px;
  min-height: 38px;
  box-sizing: border-box;
  width: 100%;
}
.estimate-table input[type="number"] {
  padding: 7px 6px;
}
.estimate-table .col-service-td,
.estimate-table td:has(input[name="service_name[]"]) {
  min-width: 220px;
}
.estimate-table td:has(select[name="level_id[]"]) {
  min-width: 170px;
}
.estimate-table .line-subtotal {
  white-space: nowrap;
}
.table-link {
  color: var(--orange);
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
  transition: var(--transition-fast);
}
.table-link:hover { color: var(--orange-dark); }
.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Table inline filter */
.table-filter {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.table-filter input {
  padding: 8px 14px 8px 36px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 280px;
  background: #F8FAFC url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A0AEC0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 12px center no-repeat;
}

/* ──────────────────────────────────────────────
   CALC GRAPHIC (modernized)
   ────────────────────────────────────────────── */
.calc-graphic {
  margin-top: 20px;
  margin-bottom: 24px;
  border-collapse: collapse;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: #fff;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
  float: right;
  width: 360px;
}
.calc-graphic td {
  padding: 10px 16px;
  border-bottom: 1px solid #F1F5F9;
  text-align: right;
}
.calc-graphic tr:last-child td { border-bottom: none; }
.calc-graphic td.label {
  font-weight: 700;
  background: #F8FAFC;
  text-transform: uppercase;
  width: 60%;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-align: left;
}
.calc-graphic tr.total-row td {
  background: linear-gradient(135deg, #DCFCE7, #D1FAE5);
  font-weight: 800;
  font-size: 15px;
  color: var(--success);
}
.calc-graphic tr.total-row td.label {
  background: linear-gradient(135deg, #DCFCE7, #D1FAE5);
  color: var(--success);
  font-size: 12px;
}
.clearfix::after { content: ""; clear: both; display: table; }

/* ──────────────────────────────────────────────
   STATUS BADGES
   ────────────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status.rascunho { background: #F1F5F9; color: #475569; }
.status.rascunho::before { background: #94A3B8; }
.status.enviada { background: #EFF6FF; color: #1D4ED8; }
.status.enviada::before { background: #3B82F6; }
.status.aprovada { background: #ECFDF5; color: #047857; }
.status.aprovada::before { background: #10B981; }
.status.perdida { background: #FEF2F2; color: #B91C1C; }
.status.perdida::before { background: #EF4444; }

/* ──────────────────────────────────────────────
   BARS / CHARTS
   ────────────────────────────────────────────── */
.bars { display: grid; gap: 12px; }
.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 140px;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  transition: var(--transition-fast);
  border-radius: var(--radius-sm);
}
.bar-row:hover { background: #F8FAFC; }
.bar-meta strong { font-size: 13px; }
.bar-meta span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.bar-track {
  background: #EDF2F7;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  background: linear-gradient(90deg, var(--orange), #FF8A50);
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
}
.bar-value { text-align: right; font-weight: 700; font-size: 13px; }

/* ──────────────────────────────────────────────
   FLASH / TOAST
   ────────────────────────────────────────────── */
.flash {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  animation: fadeInUp 0.3s ease-out;
}
.flash svg { width: 20px; height: 20px; flex-shrink: 0; }
.flash.success { background: var(--success-bg); color: var(--success); border-color: #A7F3D0; }
.flash.error { background: var(--error-bg); color: var(--error); border-color: #FECACA; }

/* Toast container */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  min-width: 320px;
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
  animation: toastIn 0.35s var(--transition) both;
  position: relative;
  overflow: hidden;
}
.toast.removing { animation: toastOut 0.3s ease-in both; }
.toast-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.toast-icon svg { width: 18px; height: 18px; }
.toast.success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast.error .toast-icon { background: var(--error-bg); color: var(--error); }
.toast-body { flex: 1; }
.toast-body strong { display: block; font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.toast-body p { margin: 0; font-size: 12px; color: var(--muted); }
.toast-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  transition: var(--transition-fast);
}
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 16px; height: 16px; }
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.toast.success .toast-progress { background: var(--success); animation: toastProgress 5s linear both; }
.toast.error .toast-progress { background: var(--error); animation: toastProgress 5s linear both; }

/* ──────────────────────────────────────────────
   MODAL
   ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,36,65,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 440px;
  width: calc(100vw - 40px);
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.modal-box h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--blue);
}
.modal-box p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ──────────────────────────────────────────────
   MISC
   ────────────────────────────────────────────── */
.calc-stack { display: grid; gap: 12px; }
.calc-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--orange-light);
  border: 1px solid #FFE0C2;
  border-radius: var(--radius-md);
}
.accent-panel { background: linear-gradient(180deg, #fff, #FFF8F2); }

/* Paper / Print view */
.paper-letterhead { display: grid; grid-template-columns: 20px 1fr; gap: 20px; }
.letter-strip {
  border-radius: 14px;
  background: linear-gradient(180deg, var(--orange), #FF8A50);
  min-height: 100%;
  padding: 18px 5px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.letter-strip .line { width: 8px; border-radius: 999px; background: rgba(255,255,255,.8); }
.letter-strip .line.long { height: 110px; }
.letter-strip .line.short { height: 45px; }
.print-sheet {
  background: #fff;
  padding: 28px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(0,0,0,0.03);
}
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--line);
}
.logo-wordmark {
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--orange);
  font-size: 20px;
}
.print-grid { grid-template-columns: repeat(5, 1fr); }

/* ──────────────────────────────────────────────
   MODERN SPLIT LOGIN (MINDTEK BRANDED UX)
   ────────────────────────────────────────────── */
.login-page {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: #0B192C;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  overflow-x: hidden;
}
.login-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  min-height: 100vh;
  width: 100%;
}

/* Lado Esquerdo: Showcase & Branding */
.login-showcase {
  background: linear-gradient(145deg, #071322 0%, #0F2441 50%, #1A365D 100%);
  color: #fff;
  padding: 48px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-showcase::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(rgba(232, 95, 28, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  pointer-events: none;
}
.showcase-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.glow-1 {
  width: 320px;
  height: 320px;
  background: rgba(232, 95, 28, 0.18);
  top: -60px;
  left: -60px;
}
.glow-2 {
  width: 400px;
  height: 400px;
  background: rgba(43, 76, 126, 0.35);
  bottom: -100px;
  right: -100px;
}

.showcase-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  gap: 36px;
}

.showcase-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand-dot-large {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--orange), #FF8A50);
  box-shadow: 0 6px 20px rgba(232, 95, 28, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.showcase-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #fff;
}
.showcase-subtitle {
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.showcase-hero {
  max-width: 620px;
}
.showcase-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(232, 95, 28, 0.12);
  border: 1px solid rgba(232, 95, 28, 0.3);
  color: #FFA575;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px var(--orange);
  animation: pulse 2s infinite;
}
.showcase-hero h1 {
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
}
.showcase-lead {
  font-size: 15px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.75);
  margin: 0;
}

.showcase-features {
  display: grid;
  gap: 16px;
  max-width: 580px;
}
.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  transition: all var(--transition);
}
.feature-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(232, 95, 28, 0.3);
  transform: translateX(4px);
}
.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(232, 95, 28, 0.15);
  color: #FF8A50;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.feature-item strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}
.feature-item p {
  margin: 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.45;
}

.showcase-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}
.showcase-footer a {
  color: #FFA575;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition-fast);
}
.showcase-footer a:hover {
  color: #fff;
}

/* Lado Direito: Formulário de Autenticação */
.login-auth-side {
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  position: relative;
}
.auth-box {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: 0 16px 40px -10px rgba(15, 36, 65, 0.1), 0 0 1px 1px rgba(15, 36, 65, 0.05);
  border: 1px solid #E2E8F0;
  box-sizing: border-box;
}

.auth-header {
  text-align: left;
  margin-bottom: 26px;
}
.auth-mini-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--orange), #FF8A50);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(232, 95, 28, 0.3);
}
.auth-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--orange);
  background: var(--orange-light);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.auth-header h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.auth-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.login-flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon .field-icon {
  position: absolute;
  left: 14px;
  color: #94A3B8;
  pointer-events: none;
  transition: color var(--transition-fast);
}
.input-with-icon input {
  padding: 12px 14px 12px 42px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #CBD5E1;
  background: #FAFBFC;
  width: 100%;
  box-sizing: border-box;
  transition: all var(--transition-fast);
}
.input-with-icon input:focus {
  border-color: var(--orange);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(232, 95, 28, 0.12);
}
.input-with-icon input:focus ~ .field-icon {
  color: var(--orange);
}

.password-toggle-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: #94A3B8;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}
.password-toggle-btn:hover {
  color: var(--orange);
}

.auth-submit-btn {
  width: 100%;
  padding: 13px 20px;
  font-size: 14.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  box-shadow: 0 4px 14px rgba(232, 95, 28, 0.3);
}
.auth-submit-btn:hover {
  box-shadow: 0 6px 20px rgba(232, 95, 28, 0.4);
}

.auth-security-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  font-size: 12px;
  color: #64748B;
  font-weight: 500;
}
.auth-security-badge svg {
  color: #10B981;
}

/* Responsivo para Login */
@media (max-width: 960px) {
  .login-layout {
    grid-template-columns: 1fr;
  }
  .login-showcase {
    padding: 36px 24px;
  }
  .showcase-hero h1 {
    font-size: 26px;
  }
  .showcase-features {
    display: none;
  }
  .login-auth-side {
    padding: 24px 16px 40px;
  }
  .auth-box {
    padding: 28px 20px;
    box-shadow: var(--shadow-md);
  }
}

.full-span { width: 100%; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* Quick actions */
.quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}
.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.quick-action svg { width: 16px; height: 16px; color: var(--orange); }
.quick-action:hover {
  border-color: var(--orange);
  background: var(--orange-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { margin: 0; font-size: 14px; }

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: #CBD5E1;
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { color: var(--orange); }
.drag-handle svg { width: 16px; height: 16px; }
tr.dragging { opacity: 0.5; background: var(--orange-light) !important; }
tr.drag-over td { border-top: 2px solid var(--orange) !important; }

/* Line subtotal */
.line-subtotal {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Duplicate button */
.btn-duplicate {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  color: var(--muted);
  padding: 0;
}
.btn-duplicate svg { width: 14px; height: 14px; }
.btn-duplicate:hover { border-color: var(--info); color: var(--info); background: var(--info-bg); }

/* Metric card for reports */
.metric-card {
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  text-align: center;
}
.metric-card .metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--blue);
  margin: 8px 0 4px;
}
.metric-card .metric-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* Period filter */
.period-filter {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.period-filter label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.period-filter input[type="month"] { width: auto; padding: 8px 12px; font-size: 13px; }

/* ──────────────────────────────────────────────
   RESPONSIVE DESIGN (Mobile, Tablet & Desktop)
   ────────────────────────────────────────────── */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

@media (max-width: 1080px) {
  .summary-grid, .status-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-two { grid-template-columns: 1fr; }
  .print-grid { grid-template-columns: repeat(3, 1fr); }
  .bar-row { grid-template-columns: 120px 1fr 100px; }
  .schedule-profit-grid { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 900px) {
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .advanced-summary-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .gantt-row { grid-template-columns: 160px 1fr; gap: 10px; }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    height: 100vh;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { left: 0; }
  .mobile-toggle {
    display: flex;
    z-index: 1000;
  }
  .main-content {
    padding: 16px 12px 60px;
    padding-top: 68px;
    width: 100%;
    box-sizing: border-box;
  }
  
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 20px;
  }
  .topbar h1 { font-size: 22px; }
  .topbar-actions {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  .topbar-search {
    flex: 1;
  }
  .topbar-search input {
    width: 100%;
    box-sizing: border-box;
  }

  .mode-toggle-card {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 10px;
  }
  .mode-toggle-group {
    flex-direction: column;
    border-radius: var(--radius-md);
    width: 100%;
  }
  .mode-choice {
    width: 100%;
  }
  .mode-pill {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }

  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .form-row-2 { grid-template-columns: 1fr; gap: 10px; }
  .form-row-3 { grid-template-columns: 1fr; gap: 10px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .status-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .panel { padding: 16px 14px; margin-bottom: 16px; border-radius: var(--radius-md); }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .panel-header.spread {
    flex-direction: column;
    align-items: stretch;
  }
  .panel-header.spread > div {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }
  .panel-header.spread button {
    flex: 1;
    min-width: 130px;
  }

  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
  }
  .estimate-table {
    min-width: 680px;
  }

  .paper-letterhead {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .letter-strip { display: none; }
  .print-sheet {
    padding: 16px 14px;
    border-radius: var(--radius-md);
  }
  .sheet-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .view-switch-tabs {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
  }
  .view-switch-tabs .tab-btn {
    width: 100%;
    justify-content: center;
  }

  .action-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .action-row a, .action-row button {
    width: 100%;
    box-sizing: border-box;
    font-size: 12px;
    padding: 8px 12px;
  }

  .gantt-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .modal-box.large-modal, .modal-box {
    width: calc(100vw - 24px);
    max-height: 88vh;
    padding: 18px 16px;
    overflow-y: auto;
  }
  #modalAllocTable {
    min-width: 480px;
  }

  .calc-graphic {
    float: none;
    width: 100%;
    margin-top: 16px;
  }
  .toast {
    min-width: unset;
    width: calc(100vw - 32px);
    right: 16px;
  }
}

@media (max-width: 480px) {
  .advanced-summary-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
  .action-row { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 20px; }
  .card.mini strong { font-size: 22px; }
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,36,65,0.6);
  backdrop-filter: blur(3px);
  z-index: 900;
}
.sidebar-overlay.visible { display: block; }

/* ──────────────────────────────────────────────
   PRINT
   ────────────────────────────────────────────── */
@media print {
  @page {
    size: landscape A4;
    margin: 8mm;
  }
  .sidebar, .topbar, .action-row, .menu, .flash, .mobile-toggle,
  .toast-container, .quick-actions, .table-filter, .topbar-actions,
  .print-hide, .alerts-banner { display: none !important; }
  .app-shell { display: block !important; }
  .main-content { padding: 0 !important; max-width: 100% !important; margin: 0 !important; }
  body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  .paper-letterhead { box-shadow: none !important; border: 1px solid #E2E8F0 !important; border-radius: 8px !important; width: 100% !important; margin: 0 !important; }
  .print-sheet, .panel, .card { box-shadow: none !important; }
  .card.mini { border: 1px solid #E2E8F0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary-grid { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 12px !important; }
  .estimate-table th { background: #F8FAFC !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .status, .chip, .phase-chip, .alloc-tag, .complexity-badge, .gantt-bar, .gantt-track, .letter-strip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .gantt-bar { background: #E85F1C !important; color: #fff !important; }
  .gantt-track { background: #F1F5F9 !important; }
  .gantt-row { page-break-inside: avoid !important; }
  .estimate-table tr { page-break-inside: avoid !important; }
}

/* ──────────────────────────────────────────────
   JS TOOLTIP
   ────────────────────────────────────────────── */
.js-tooltip {
  display: none;
  position: fixed;
  transform: translate(-50%, -100%);
  background: var(--blue);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 99999;
  pointer-events: none;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ──────────────────────────────────────────────
   USER MANAGEMENT
   ────────────────────────────────────────────── */

/* Role badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.role-badge.role-super_admin {
  background: linear-gradient(135deg, var(--orange-light), #FFE0C2);
  color: var(--orange-dark);
  border: 1px solid rgba(232,95,28,0.15);
}
.role-badge.role-admin {
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid rgba(26,54,93,0.1);
}
.role-badge.role-viewer {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(37,99,235,0.1);
}

/* Sidebar role badge */
.sidebar-note .role-badge {
  margin-top: 8px;
  font-size: 10px;
  padding: 3px 8px;
}

/* User avatar */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.user-avatar.large {
  width: 56px;
  height: 56px;
  font-size: 22px;
  border-radius: 14px;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Status pill (active/inactive) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-pill.active {
  background: var(--success-bg);
  color: var(--success);
}
.status-pill.active::before {
  background: var(--success);
  box-shadow: 0 0 6px rgba(5,150,105,0.4);
  animation: pulse 2s infinite;
}
.status-pill.inactive {
  background: #F1F5F9;
  color: #94A3B8;
}
.status-pill.inactive::before {
  background: #94A3B8;
}

/* Inactive user row */
tr.user-inactive td {
  opacity: 0.5;
}
tr.user-inactive:hover td {
  opacity: 0.8;
}

/* Custom checkbox */
.custom-checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  width: 22px;
  height: 22px;
  font-size: 0;
}
.custom-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.custom-checkbox .checkmark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid #CBD5E1;
  background: #fff;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.custom-checkbox .checkmark::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--transition-fast);
  margin-top: -1px;
}
.custom-checkbox input:checked + .checkmark {
  background: var(--orange);
  border-color: var(--orange);
  box-shadow: 0 2px 8px rgba(232,95,28,0.3);
}
.custom-checkbox input:checked + .checkmark::after {
  transform: rotate(45deg) scale(1);
}
.custom-checkbox:hover .checkmark {
  border-color: var(--orange);
}

/* Selected row */
tr.row-selected td {
  background: var(--orange-light) !important;
}

/* Select all label */
.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
}
.select-all-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--orange);
  cursor: pointer;
}

/* ──────────────────────────────────────────────
   ESTIMATE MODE SWITCHER & ADVANCED CONTROLS
   ────────────────────────────────────────────── */
.mode-toggle-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.mode-toggle-group {
  display: flex;
  gap: 8px;
  background: #F1F5F9;
  padding: 4px;
  border-radius: 999px;
}
.mode-choice {
  cursor: pointer;
  margin: 0;
  display: inline-block;
  position: relative;
}
.mode-choice input[type="radio"] {
  display: none !important;
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  transition: all var(--transition-fast);
  user-select: none;
}
.mode-pill svg {
  width: 16px !important;
  height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  flex-shrink: 0;
}
.mode-choice input[type="radio"]:checked + .mode-pill {
  background: #fff;
  color: var(--orange);
  box-shadow: var(--shadow-sm);
}
.mode-hint {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Control Box */
.control-box {
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}
.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.control-header strong {
  font-size: 13px;
  color: var(--blue);
}
.radio-inline {
  display: flex;
  gap: 12px;
  font-size: 12px;
}
.radio-inline label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}
.radio-inline input[type="radio"] {
  width: auto;
  margin: 0;
}
.calc-info-pill {
  background: #fff;
  border: 1px dashed #CBD5E1;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}
.calc-info-pill strong {
  color: var(--blue);
  font-size: 12px;
  margin-top: 2px;
}

/* Allocation Button & Badge */
.btn-allocate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-allocate:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-light);
}
.alloc-badge-count {
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 6px;
}
.alloc-tag {
  display: inline-block;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  margin: 2px 4px 2px 0;
  color: var(--blue);
}

/* Complexity Badges */
.complexity-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.complexity-baixa { background: #ECFDF5; color: #047857; }
.complexity-média, .complexity-media { background: #FEF3C7; color: #D97706; }
.complexity-alta { background: #FEF2F2; color: #B91C1C; }

/* Advanced Summary & Profit Grid */
.summary-and-calc-container {
  margin-top: 24px;
}
.advanced-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.summary-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.summary-box.highlight-box {
  background: linear-gradient(135deg, var(--orange-light), #FFE8D6);
  border-color: #FDBA74;
}
.summary-box .s-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.summary-box.highlight-box .s-label { color: var(--orange-dark); }
.summary-box .s-val {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.summary-box.highlight-box .s-val { color: var(--orange); }
.summary-box .s-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.summary-box.highlight-box .s-sub { color: #9A3412; font-weight: 600; }

.schedule-profit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.detail-card {
  background: #FAFBFC;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.detail-card h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #EDF2F7;
  font-size: 13px;
}
.detail-row:last-child {
  border-bottom: none;
}
.detail-row span {
  color: var(--muted);
  font-weight: 500;
}
.detail-row strong {
  color: var(--text);
  font-weight: 700;
}

/* Alerts Box */
.alerts-container, .alerts-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}
.alert-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.alert-warning {
  background: #FFFBEB;
  color: #B45309;
  border: 1px solid #FDE68A;
}
.alert-danger {
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
}
.alert-success {
  background: #ECFDF5;
  color: #047857;
  border: 1px solid #A7F3D0;
}

/* View Switch Tabs (Proposal View) */
.view-switch-tabs {
  display: inline-flex;
  gap: 6px;
  background: #F1F5F9;
  padding: 4px;
  border-radius: 999px;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tab-btn:hover { color: var(--blue); }
.tab-btn.active {
  background: #fff;
  color: var(--orange);
  box-shadow: var(--shadow-sm);
}

/* Gantt Chart (Simplified & Responsive) */
.gantt-container {
  background: #FAFBFC;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
}
.gantt-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}
.gantt-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  align-items: center;
}
.gantt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-track {
  background: #EDF2F7;
  height: 24px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}
.gantt-bar {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--orange), #FF8A50);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(232,95,28,0.3);
}

/* Large Modal */
.modal-box.large-modal {
  max-width: 680px;
  width: 90vw;
}

/* ──────────────────────────────────────────────
   MULTI-TENANT & BUSINESS UNIT STYLES
   ────────────────────────────────────────────── */
.tenant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--t-color, var(--orange));
  background: color-mix(in srgb, var(--t-color, var(--orange)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--t-color, var(--orange)) 25%, transparent);
  white-space: nowrap;
}
.tenant-pill .t-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tenant-pill.global {
  color: #64748B;
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.tenant-code-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fff;
}

/* Topbar Tenant Selector */
.topbar-tenant-selector {
  position: relative;
}
.tenant-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tenant-select-btn:hover {
  border-color: var(--orange);
  background: #FFF7ED;
}
.tenant-select-btn .t-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.tenant-select-btn .chevron {
  color: var(--muted);
  transition: transform var(--transition-fast);
}

.tenant-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(15, 36, 65, 0.12);
  padding: 6px;
  z-index: 1000;
  display: none;
  animation: fadeInUp 0.2s ease-out;
}
.tenant-dropdown-menu.show {
  display: block;
}
.tenant-dropdown-header {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.tenant-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition-fast);
}
.tenant-dropdown-item:hover {
  background: #F8FAFC;
}
.tenant-dropdown-item.active {
  background: #FFF7ED;
  color: var(--orange);
  font-weight: 700;
}
.tenant-dropdown-item .t-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.tenant-dropdown-footer {
  padding: 8px 12px 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  text-align: center;
}
.tenant-dropdown-footer a {
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
  text-decoration: none;
}
.tenant-dropdown-footer a:hover {
  text-decoration: underline;
}

/* Tenant Cards in tenants.php */
.tenant-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.tenant-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 36, 65, 0.08);
  border-color: color-mix(in srgb, var(--t-card-color, var(--orange)) 40%, var(--line));
}
.tenant-card.inactive {
  opacity: 0.65;
  background: #F8FAFC;
}
.tenant-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.tenant-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tenant-meta {
  flex: 1;
}
.tenant-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.tenant-title-row h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--blue);
}
.tenant-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 18px;
  min-height: 38px;
}

.tenant-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  background: #F8FAFC;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}
.t-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.t-stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}
.t-stat-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.tenant-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}


