/* TMB GROUP AI Quoting Platform */
/* Server-ready, relative-path safe, no external dependencies. */

:root {
  --red: #ef3340;
  --orange: #fb8c00;
  --blue: #0072bc;
  --blue-dark: #005a9c;
  --ink: #07111f;
  --muted: #607085;
  --muted-light: #93a0b0;
  --line: #dce5ef;
  --bg: #f3f7fb;
  --white: #ffffff;
  --navy: #111747;
  --radius: 22px;
  --shadow: 0 18px 42px rgba(13, 31, 51, 0.08);
  --sidebar-width: 250px;
}

*, *::before, *::after {
  box-sizing: border-box;
  min-width: 0;
}

html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button, input, select { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: var(--white);
}

.brand-logo {
  display: block;
  width: 205px;
  max-width: 100%;
  height: auto;
}

.brand-kicker {
  margin: 24px 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.36em;
  overflow-wrap: anywhere;
}

.brand-title {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 42px;
}

.nav-button {
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #1d334b;
  cursor: pointer;
  padding: 15px 16px;
  text-align: left;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.nav-button:hover,
.nav-button.is-active {
  background: #eaf4ff;
  color: var(--blue-dark);
}

.content-area {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  padding: 28px 34px 44px;
}

.page {
  display: none;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.page.is-active { display: block; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 30px;
}

.page-heading { min-width: 0; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.38em;
  overflow-wrap: anywhere;
}

h1 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 900;
}

.lead {
  max-width: 1060px;
  margin: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.45;
}

.primary-button, .process-button {
  flex: 0 0 auto;
  min-width: 170px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: #fff;
  cursor: pointer;
  padding: 16px 28px;
  box-shadow: 0 20px 38px rgba(239, 51, 64, 0.2);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.15;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.metric-card, .panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.metric-card { padding: 24px; }

.metric-card p {
  min-height: 42px;
  margin: 0;
  color: #66768b;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

.metric-card strong {
  display: block;
  margin: 18px 0 10px;
  font-size: 44px;
  line-height: 0.95;
  font-weight: 900;
}

.metric-card span {
  color: var(--muted-light);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.content-grid {
  display: grid;
  gap: 22px;
}

.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.full-panel, .settings-bottom { margin-top: 22px; }

.panel { padding: 26px; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.panel h2, .panel-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.panel-header span {
  max-width: 48%;
  color: var(--muted-light);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  text-align: right;
  overflow-wrap: anywhere;
}

.muted-text, .body-copy {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.email-item, .mailbox-card, .source-card {
  margin-top: 12px;
  border: 1px solid #bfdaf1;
  border-radius: 16px;
  background: #f1f8ff;
  padding: 17px;
  overflow: hidden;
  cursor: pointer;
}

.email-item.is-active {
  border-color: #73b9f2;
  background: #e8f4ff;
}

.email-time {
  margin: 0 0 8px;
  color: var(--muted-light);
  font-size: 13px;
  font-weight: 800;
}

.email-title, .mailbox-card strong, .source-card strong {
  display: block;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.email-from, .mailbox-card span, .source-card span {
  display: block;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ai-layout {
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.ai-panel {
  min-width: 0;
  overflow: hidden;
  border-radius: 26px;
  background: linear-gradient(135deg, #111747 0%, #271c54 55%, #551343 100%);
  color: #fff;
  box-shadow: var(--shadow);
  padding: 30px;
}

.ai-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.ai-panel-top span {
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.4em;
  overflow-wrap: anywhere;
}

.ai-panel-top strong {
  flex: 0 0 auto;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--orange));
  padding: 12px 24px;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.ai-panel h2 {
  margin: 0 0 24px;
  color: #fff;
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.selected-email-card {
  border: 1px solid var(--blue);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.11);
  padding: 22px;
  overflow: hidden;
}

.selected-email-card p {
  margin: 0 0 10px;
  color: #fff;
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.selected-email-card p:last-child { margin-bottom: 0; }

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

.agent-grid div {
  min-height: 82px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.agent-grid small {
  display: block;
  margin-top: 9px;
  color: #c9d3e0;
  font-size: 13px;
  font-weight: 800;
}

.secondary-button {
  width: 100%;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 900;
}

.process-button {
  width: 100%;
  margin-top: 12px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-switch button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 900;
}

.mode-switch button.is-active {
  border-color: #b9d8f2;
  background: #eaf4ff;
  color: var(--blue-dark);
}

.response-panel h3 {
  margin: 18px 0 9px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

pre {
  min-height: 145px;
  max-height: 230px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f9fbfe;
  color: var(--ink);
  padding: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.download-button {
  display: inline-block;
  margin-top: 18px;
  border-radius: 999px;
  background: #eaf4ff;
  color: var(--blue-dark);
  padding: 14px 20px;
  text-decoration: none;
  font-size: 16px;
  font-weight: 900;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f2f6fa;
  color: #34465a;
  font-weight: 900;
}

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

.choice-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbff;
  padding: 18px;
}

.choice-card.is-active {
  border-color: #69b6f4;
  background: #eef7ff;
}

.choice-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.choice-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

label {
  display: block;
  margin-top: 16px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

label:first-child { margin-top: 0; }

input, select {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
}

.days-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.days-row span {
  border-radius: 999px;
  background: var(--blue-dark);
  color: #fff;
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 900;
}

.status-ok { color: #098b52 !important; font-weight: 900 !important; }
.status-warn { color: #d27a00 !important; font-weight: 900 !important; }

@media (max-width: 1500px) {
  :root { --sidebar-width: 235px; }
  .content-area { padding: 24px; }
  h1 { font-size: 48px; }
  .lead { font-size: 18px; }
  .ai-layout {
    grid-template-columns: 270px minmax(480px, 1fr);
    grid-template-areas:
      "inbox ai"
      "response response";
  }
  .inbox-panel { grid-area: inbox; }
  .ai-panel { grid-area: ai; }
  .response-panel { grid-area: response; }
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-columns, .ai-layout { grid-template-columns: 1fr; }
  .ai-layout {
    grid-template-areas:
      "inbox"
      "ai"
      "response";
  }
  .agent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .main-nav { display: grid; grid-template-columns: repeat(2, 1fr); }
  .content-area { padding: 18px 14px 34px; }
  .page-header { flex-direction: column; }
  .primary-button { width: 100%; }
  h1 { font-size: 38px; }
  .metric-grid, .choice-grid, .form-grid { grid-template-columns: 1fr; }
  .ai-panel h2 { font-size: 34px; }
}

@media (max-width: 520px) {
  .main-nav, .agent-grid, .mode-switch { grid-template-columns: 1fr; }
  .panel, .metric-card, .ai-panel { padding: 18px; }
}


/* v24 - configuração: campos sem texto cortado e botão de guardar */
.field-label {
  width: 100%;
  display: block;
  margin-top: 18px;
  white-space: normal;
  overflow: visible;
}

.config-input,
.field-label input,
.field-label select {
  width: 100%;
  min-height: 52px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: normal;
  overflow-wrap: normal;
  line-height: 1.35;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.save-button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: #fff;
  cursor: pointer;
  padding: 14px 22px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.15;
  box-shadow: 0 14px 28px rgba(239, 51, 64, 0.16);
}

.save-status {
  color: #098b52;
  font-size: 14px;
  font-weight: 800;
  min-height: 18px;
}

@media (max-width: 1180px) {
  .settings-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .save-button {
    width: 100%;
  }
}


/* v25 - configuração do modo manual */
.operation-mode-grid {
  align-items: stretch;
}

.mode-option {
  position: relative;
  display: block;
  cursor: pointer;
  user-select: none;
}

.mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-title {
  display: block;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.choice-copy {
  display: block;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.manual-config {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbff;
  padding: 18px;
}

.manual-config h3 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.manual-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  column-gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.manual-check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.manual-config.is-muted {
  opacity: 0.64;
}

.manual-config.is-muted .manual-check {
  color: var(--muted-light);
}
