html {
  height: 100%;
}

body {
  background: radial-gradient(circle at top left, #e0e7ff 0%, #f8fafc 45%, #f1f5f9 100%);
  min-height: 100%;
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  font-size: 0.95rem;
}

.chat-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  height: 100vh;
  overflow: hidden;
}

.top-nav.floating {
  position: fixed;
  top: 0.75rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 30;
  pointer-events: none;
}

.brand-card {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(37, 99, 235, 0.2);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1);
  pointer-events: auto;
}

.brand-card strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.brand-card span {
  display: block;
  font-size: 0.68rem;
  color: #5f6b7a;
}

.admin-link {
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.82);
  color: #1d4ed8;
  padding: 0.25rem 0.65rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0.65;
  pointer-events: auto;
}

.admin-link:hover,
.admin-link:focus {
  opacity: 0.85;
  transform: translateY(-1px);
}

.admin-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 3.5rem clamp(1rem, 3vw, 2rem) 0.75rem;
  height: 100vh;
  overflow: hidden;
}

.agent-avatar {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.7rem;
  color: #ffffff;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
}

.chat-history {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 auto;
  width: min(1400px, 100%);
  scroll-behavior: smooth;
}

.message {
  display: flex;
  align-items: flex-end;
  width: 100%;
}

.message.fade-in {
  animation: fadeInUp 0.22s ease;
}

.message .bubble {
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  max-width: min(70%, 600px);
  line-height: 1.6;
  word-break: break-word;
  font-size: 0.85rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.message .bubble > :last-child {
  margin-bottom: 0;
}

.message.assistant .bubble {
  margin-right: auto;
  background: #f3f6ff;
  color: #1f2937;
  border: 1px solid rgba(37, 99, 235, 0.09);
}

.message.user .bubble {
  margin-left: auto;
  background: #e3efff;
  color: #0f1d40;
  border-top-right-radius: 6px;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.message.loading .bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #1f2937;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.message.loading .bubble::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.3);
  border-top-color: #2563eb;
  animation: spin 0.65s linear infinite;
}

.chat-media {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  padding: 0.45rem;
  margin-top: 0.4rem;
  background: rgba(248, 250, 252, 0.85);
  display: block;
}

.chat-media.chat-image img {
  max-width: 100%;
  display: block;
  border-radius: 8px;
}

.chat-media.chat-image span {
  display: block;
  font-size: 0.75rem;
  color: #475569;
  margin-top: 0.35rem;
}

.chat-media.chat-file {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.chat-media.chat-file a {
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: none;
}

.chat-media.chat-file a:hover {
  text-decoration: underline;
}

.chat-form {
  padding: 0.5rem 0 0.75rem;
  margin: 0 auto;
  width: min(1400px, 100%);
  position: sticky;
  bottom: 1rem;
  z-index: 10;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.95);
  padding: 0.7rem 0.8rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.composer-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  width: 100%;
}

.composer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.composer-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.7rem;
  color: #0f172a;
  background: rgba(248, 250, 252, 0.8);
  border-radius: 10px;
  padding: 0.25rem 0.5rem;
  width: fit-content;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.composer-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.chat-form textarea {
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  resize: none;
  min-height: 32px;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #0f172a;
  background: rgba(248, 250, 252, 0.5);
  flex: 1;
  padding: 0.5rem 0.7rem;
  width: 100%;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.chat-form textarea:focus {
  outline: none;
  opacity: 1;
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(255, 255, 255, 0.9);
}

.chat-form textarea::placeholder {
  color: #94a3b8;
  opacity: 0.8;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.composer-actions .hint {
  font-size: 0.68rem;
  color: #64748b;
  flex: 1;
}

.link-control {
  border: none;
  background: none;
  color: #1d4ed8;
  font-size: 0.7rem;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.link-control:hover,
.link-control:focus {
  color: #1e3a8a;
  outline: none;
}

.chat-form button {
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  min-width: auto;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  align-self: flex-end;
  height: fit-content;
  flex: 0 0 auto;
  width: auto;
}

.chat-form button .button-label {
  display: none;
}

.chat-form button .button-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-form button .button-icon svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.chat-form button.pending .button-icon {
  animation: spin 0.8s linear infinite;
}

.chat-form button.pending .button-label {
  display: none;
}

.chat-form button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.22);
}

.chat-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.22);
}

.status-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.24);
}

.status-dot.error {
  background: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.24);
}

.phone-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  backdrop-filter: blur(10px);
  padding: clamp(1.25rem, 5vw, 2.5rem);
}

.phone-card {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 28px;
  padding: clamp(1.45rem, 4vw, 2.3rem);
  max-width: 380px;
  width: 100%;
  box-shadow: 0 40px 110px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.phone-card h2 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.phone-card p {
  margin: 0;
  color: #475569;
  line-height: 1.5;
}

.phone-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.phone-form label {
  font-weight: 600;
}

.phone-form input {
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
}

.phone-form button {
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
}

.error-message {
  min-height: 1.4rem;
  font-size: 0.85rem;
  color: #dc2626;
}

.hidden {
  display: none !important;
}

.landing-footer {
  display: none;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 1.2rem 1.2rem;
}

.admin-card {
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  padding: 1rem;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.feedback {
  color: #dc2626;
}

.hidden {
  display: none;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.2rem;
}

.admin-grid article {
  background: #fff;
  padding: 1rem;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-grid table {
  width: 100%;
  border-collapse: collapse;
}

.admin-grid th,
.admin-grid td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.empty-cell,
.empty-message {
  text-align: center;
  color: #64748b;
  font-style: italic;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.open {
  background: #dcfce7;
  color: #15803d;
}

.badge.submitted {
  background: #fef3c7;
  color: #92400e;
}

.badge.won {
  background: #bbf7d0;
  color: #166534;
}

.badge.lost {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.canceled {
  background: #e2e8f0;
  color: #475569;
}

.badge.closed {
  background: #e0e7ff;
  color: #4338ca;
}

.badge.draft {
  background: #e0f2fe;
  color: #0ea5e9;
}

.admin-licenses .licenses-header h2,
.admin-budgets .budgets-header h2 {
  margin-bottom: 0.25rem;
}

.admin-licenses .licenses-header p,
.admin-budgets .budgets-header p {
  margin: 0;
  color: #64748b;
  font-size: 0.85rem;
}

.management-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  background: rgba(248, 250, 252, 0.85);
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.24);
}

.management-form .form-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.management-form fieldset {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  margin: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.management-form fieldset + fieldset {
  margin-top: 0.75rem;
}

.management-form fieldset legend {
  font-weight: 600;
  padding: 0 0.4rem;
  color: #0f172a;
}

.management-form textarea,
.management-form input {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
}

.management-form .form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-actions.compact {
  justify-content: space-between;
}

.form-actions.compact .feedback {
  margin: 0;
}

.management-form .ghost.small {
  padding: 0.35rem 0.75rem;
}

.admin-budgets .budgets-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.admin-budgets .budget-card {
  margin: 0;
  position: relative;
  padding-bottom: 2rem;
}

.budget-card .card-actions {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  gap: 0.45rem;
}

.action-button {
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.action-button.danger {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.action-button.secondary {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.2);
}

.action-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.badge.closed {
  background: #fee2e2;
  color: #991b1b;
}

.budget-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.budget-card h3 {
  margin-bottom: 0.3rem;
}

@media (max-width: 960px) {
  .chat-main {
    padding: 3.5rem clamp(0.8rem, 4vw, 1.5rem) 0.75rem;
  }

  .chat-history,
  .chat-form {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .top-nav.floating {
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
  }

  .chat-main {
    padding: 3.5rem 0.75rem 0.75rem;
  }

  .chat-history {
    padding: 0.75rem 0.3rem;
  }

  .chat-form {
    padding: 0.5rem 0 0.6rem;
    bottom: 0.75rem;
  }

  .composer {
    padding: 0.6rem 0.75rem;
  }

  .composer-actions {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    justify-content: flex-start;
  }

  .chat-form button {
    width: auto;
  }

  .composer-input-wrapper {
    flex-direction: row;
  }

  .composer-meta {
    width: 100%;
    justify-content: center;
  }

  .composer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-controls {
    justify-content: center;
  }

  .brand-card {
    padding: 0.35rem 0.55rem;
  }

  .brand-card strong {
    font-size: 0.72rem;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0 2rem 2rem;
}

.admin-card {
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  padding: 2rem;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.feedback {
  color: #dc2626;
}

.hidden {
  display: none;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.admin-grid article {
  background: #fff;
  padding: 1.5rem;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.admin-grid table {
  width: 100%;
  border-collapse: collapse;
}

.admin-grid th,
.admin-grid td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.open {
  background: #dcfce7;
  color: #15803d;
}

.badge.submitted {
  background: #fef3c7;
  color: #92400e;
}

.badge.won {
  background: #bbf7d0;
  color: #166534;
}

.badge.lost {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.canceled {
  background: #e2e8f0;
  color: #475569;
}

.badge.closed {
  background: #e0e7ff;
  color: #4338ca;
}

.badge.draft {
  background: #e0f2fe;
  color: #0ea5e9;
}

.status-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 180px;
}

.status-select {
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #dbeafe;
  background: #fff;
  color: #0f172a;
  font-size: 0.85rem;
  min-width: 170px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.status-select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Budgets table layout fixes */
#budgets-table th:nth-child(4),
#budgets-table td:nth-child(4) {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#budgets-table th:nth-child(5),
#budgets-table td:nth-child(5) {
  min-width: 190px;
  text-align: center;
}

#budgets-table th:nth-child(6),
#budgets-table td:nth-child(6) {
  width: 80px;
  text-align: center;
}

#budgets-table th:nth-child(8),
#budgets-table td:nth-child(8) {
  text-align: right;
}

#budgets-table td:nth-child(5) .status-select {
  white-space: nowrap;
  width: 100%;
}

.new-budget-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.new-budget-form .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
}

.new-budget-form .item-adder {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.new-budget-form .item-adder input,
.new-budget-form .item-adder select {
  min-width: 200px;
}

.inline-fieldset {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem;
  background: #f8fafc;
}

.inline-fieldset legend {
  font-weight: 600;
  padding: 0 0.4rem;
  color: #0f172a;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.pill-list li {
  background: #e5edff;
  color: #1e3a8a;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #dbeafe;
}

.pill-list li.empty-pill {
  background: #f1f5f9;
  color: #64748b;
  border-style: dashed;
}

.pill-list button {
  border: none;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
  font-size: 0.85rem;
}

/* --- Buttons & Controls (consistent across pages) --- */
button,
.button,
.primary,
.secondary,
.ghost,
.action-button {
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff !important;
  border: 1px solid #1d4ed8;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

.primary:hover:not(:disabled),
.primary:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.45);
}

.secondary {
  background: #e0ebff;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe;
}

.secondary:hover:not(:disabled),
.secondary:focus-visible {
  background: #d5e4ff;
  transform: translateY(-1px);
}

.ghost {
  background: #fff;
  color: #0f172a !important;
  border: 1px solid #e2e8f0;
}

.ghost:hover:not(:disabled),
.ghost:focus-visible {
  background: #f8fafc;
  transform: translateY(-1px);
}

.action-button {
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  border: 1px solid #dbeafe;
  background: #eef2ff;
  color: #1e3a8a;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.action-button.danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fbcfd0;
}

.link-control {
  border: none;
  background: transparent;
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: none;
  padding: 0.15rem 0.25rem;
}

.link-control:hover,
.link-control:focus {
  color: #1e40af;
  text-decoration: underline;
}

button:disabled,
.primary:disabled,
.secondary:disabled,
.ghost:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.budget-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.budget-card h3 {
  margin-bottom: 0.5rem;
}

@media (max-width: 1100px) {
  .chat-layout {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .hero {
    text-align: center;
    align-items: center;
  }

  .hero p {
    max-width: 600px;
  }
}

@media (max-width: 720px) {
  .top-nav {
    flex-direction: column;
    gap: 1rem;
  }

  .chat-window {
    border-radius: 20px;
    height: 85vh;
  }

  .chat-form .input-wrapper {
    flex-direction: column;
    align-items: stretch;
    border-radius: 16px;
  }

  .chat-form button {
    align-self: flex-end;
  }
}

/* ---- Admin redesign: tabs, KPIs, tables ---- */
.admin-tabs {
  display: inline-flex;
  gap: 0.35rem;
  background: rgba(248, 250, 252, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.24);
  padding: 0.25rem;
  border-radius: 10px;
  width: fit-content;
  margin-bottom: 0.75rem;
}

.admin-tabs .tab-button {
  border: 0;
  background: transparent;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #334155;
  cursor: pointer;
}

.admin-tabs .tab-button.active {
  background: #2563eb;
  color: #fff;
}

.tab-panel.hidden { display: none; }

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1rem;
}

.panel-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.9rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.chart-wrapper {
  position: relative;
  height: 240px;
  padding: 0.25rem;
}

.chart-wrapper canvas {
  width: 100%;
  height: 100%;
}

.chart-wrapper .hint {
  text-align: center;
  margin-top: 0.5rem;
}

#license-editor-view {
  padding: 0;
}

#tab-licenses > .panel-card + .panel-card {
  margin-top: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel-header h3 {
  margin: 0;
}

.panel-header p {
  margin: 0.15rem 0 0;
  color: #475569;
  font-size: 0.85rem;
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.license-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  grid-template-areas:
    "form photo"
    "docs docs"
    "rules rules";
  align-items: stretch;
  gap: 1rem;
  padding: 0.9rem;
}

.license-card--form {
  grid-area: form;
}

.license-card--photo {
  grid-area: photo;
}

.license-card--docs {
  grid-area: docs;
}

.license-card--rules {
  grid-area: rules;
}

.license-card header {
  margin-bottom: 0.4rem;
}

.license-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.license-card .hint {
  margin: 0;
}

.license-card .hint.small {
  display: block;
  color: #64748b;
}

.licenses-list-card {
  margin-bottom: 1rem;
}

.editor-layout {
  display: grid;
  gap: 1rem;
}

.photo-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.media-card .hint {
  color: #475569;
  font-size: 0.85rem;
}

.license-media {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.license-media.hidden {
  display: none;
}

.media-section header h4 {
  margin: 0 0 0.15rem 0;
}

.media-section header p {
  margin: 0 0 0.4rem 0;
  font-size: 0.82rem;
  color: #64748b;
}

.photo-preview {
  border: 1px dashed rgba(148, 163, 184, 0.6);
  border-radius: 12px;
  padding: 0.75rem;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: rgba(248, 250, 252, 0.6);
}

.photo-preview.empty {
  color: #94a3b8;
  font-size: 0.85rem;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
}

.documents-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.documents-list.empty {
  border-style: dashed;
  color: #94a3b8;
  padding: 0.75rem;
}

.document-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  gap: 0.5rem;
}

.document-item:last-child {
  border-bottom: 0;
}

.document-label strong {
  display: block;
  font-size: 0.9rem;
  color: #0f172a;
}

.document-label span {
  font-size: 0.75rem;
  color: #64748b;
}

.document-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.document-actions a {
  font-size: 0.8rem;
  color: #2563eb;
  text-decoration: none;
}

.upload-form {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.upload-form input[type="file"] {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.45rem;
  background: rgba(248, 250, 252, 0.7);
}

.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.photo-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.photo-actions input[type="file"] {
  display: none;
}

.attachments-section {
  margin-top: 1.2rem;
}

.license-card.attachments-section,
.license-card.rules-section {
  margin-top: 0;
}

.attachments-section .hint {
  color: #475569;
  margin-bottom: 0.6rem;
}

.rules-section {
  margin-top: 1.2rem;
}

.rules-section header h4 {
  margin-bottom: 0.25rem;
}

.rules-section .hint {
  color: #475569;
}

.license-rules {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1fr);
  gap: 1rem;
  margin-top: 0.6rem;
}

.license-rules.hidden {
  display: none;
}

.rule-form-card,
.rule-list-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.9rem;
  background: #fdfefe;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.rule-config {
  margin-top: 0.8rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.6);
  background: rgba(248, 250, 252, 0.8);
}

.rule-config.hidden {
  display: none;
}

.rule-config h5 {
  margin: 0 0 0.35rem 0;
  font-size: 0.9rem;
  color: #0f172a;
}

.conditional-field.hidden {
  display: none;
}

.rule-list-header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rules-list.empty::after {
  content: "Nenhuma regra cadastrada.";
  display: block;
  padding: 0.6rem;
  border: 1px dashed #e2e8f0;
  border-radius: 10px;
  color: #64748b;
  background: rgba(248, 250, 252, 0.8);
  font-size: 0.85rem;
  text-align: center;
}

.rule-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.65rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rule-item.inactive {
  opacity: 0.6;
}

.rule-item h6 {
  margin: 0;
  font-size: 0.95rem;
}

.rule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: #475569;
}

.rule-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  color: #1d4ed8;
  background: rgba(219, 234, 254, 0.6);
}

.rule-actions {
  display: flex;
  gap: 0.4rem;
}

.rule-actions button {
  font-size: 0.78rem;
}

.hint.small {
  font-size: 0.78rem;
}

.upload-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.kpi-card {
  background: linear-gradient(180deg, #f8fafc, #ffffff);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.8rem;
}

.kpi-card h3 {
  margin: 0 0 0.25rem 0;
  font-size: 0.9rem;
  color: #475569;
}

.kpi-value {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.8rem;
}

#filter-text {
  flex: 1;
  min-width: 0;
}

#filter-status {
  width: 180px;
}

.toolbar input[type="search"],
.toolbar select {
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  font-size: 0.85rem;
  background: #fff;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: none;              /* tira a borda das células */
}

.admin-table thead tr {
  border-bottom: 1px solid #e5e7eb; /* linha sob o cabeçalho, opcional */
}

.admin-table tbody tr {
  border-bottom: 1px solid #e5e7eb; /* linha única por linha de dados */
}

.admin-table thead {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 1;
}
.admin-table.compact th, .admin-table.compact td {
  padding: 0.45rem 0.5rem;
  font-size: 0.88rem;
}

.admin-table td .table-actions { display: flex; gap: 0.6rem; }

@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  .license-editor-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "form"
      "photo"
      "docs"
      "rules";
  }
  .license-rules { grid-template-columns: 1fr; }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
  padding: 1rem;
}

.modal-card {
  width: min(860px, 96vw);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.modal-content {
  padding: 0.9rem 1rem 1rem;
}

.bd-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.bd-total { text-align: right; }

@media (max-width: 720px) {
  .bd-grid { grid-template-columns: 1fr; text-align: left; }
  .bd-total { text-align: left; }
}
