:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #667085;
  --line: #d9e0df;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --sage: #3f8f75;
  --sage-soft: #e6f3ee;
  --mint: #91caae;
  --blush: #faebe6;
  --gold: #b87916;
  --gold-soft: #fff2d8;
  --rose: #b54f61;
  --rose-soft: #fde9ed;
  --blue: #356c9a;
  --blue-soft: #e8f1f8;
  --shadow: 0 18px 40px rgba(31, 42, 54, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(145, 202, 174, 0.18), rgba(250, 235, 230, 0.5)),
    var(--paper);
}

.login-panel {
  width: min(440px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel img {
  width: 210px;
  height: 70px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 14px;
}

.login-panel form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.form-message {
  min-height: 20px;
  color: var(--rose);
  font-size: 13px;
  margin: 0;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 272px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #f3f6f2;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--line);
  overflow: hidden;
}

.brand-mark img {
  width: 33px;
  height: 33px;
  object-fit: contain;
}

.brand span,
.quick-panel p,
.overline,
.metric span,
label,
td small {
  color: var(--muted);
}

.brand span {
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 42px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
}

.nav-item.active,
.nav-item:hover {
  background: white;
  border-color: var(--line);
  box-shadow: 0 6px 16px rgba(31, 42, 54, 0.05);
}

.quick-panel {
  margin-top: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.eyebrow,
.overline {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar,
.section-head,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.topbar-logo {
  width: clamp(150px, 16vw, 230px);
  height: 58px;
  object-fit: contain;
  object-position: center;
  opacity: 0.95;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  margin-bottom: 0;
}

h2 {
  font-size: 22px;
  margin-bottom: 0;
}

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

.user-chip {
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border: 1px solid var(--line);
  min-height: 40px;
  border-radius: var(--radius);
}

.primary-button {
  border-color: var(--sage);
  background: var(--sage);
  color: white;
  padding: 0 16px;
  font-weight: 700;
}

.secondary-button {
  background: white;
  color: var(--ink);
  padding: 0 14px;
}

.danger-button {
  border-color: #f0c8cf;
  background: var(--rose-soft);
  color: #8f3044;
  padding: 0 14px;
}

.icon-button {
  width: 40px;
  background: white;
  font-size: 20px;
  line-height: 1;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(160px, 210px));
  gap: 12px;
  margin-bottom: 20px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  position: relative;
}

.password-field input {
  padding-right: 58px;
}

.password-field button {
  align-self: center;
  background: transparent;
  border: 0;
  color: var(--sage);
  font-size: 12px;
  font-weight: 800;
  min-height: 32px;
  padding: 0 10px;
  position: absolute;
  right: 6px;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin-top: 10px;
}

.accent-green {
  border-top: 4px solid var(--sage);
}

.accent-gold {
  border-top: 4px solid var(--gold);
}

.accent-rose {
  border-top: 4px solid var(--rose);
}

.accent-blue {
  border-top: 4px solid var(--blue);
}

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.board-toolbar {
  align-items: end;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.board-toolbar label {
  max-width: 280px;
}

.board-toolbar p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 9px;
}

.stage-column {
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 420px;
  padding: 12px;
}

.stage-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  margin-bottom: 12px;
}

.count-pill,
.priority-pill,
.source-pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.count-pill {
  background: #e7ece8;
}

.contact-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 8px 20px rgba(31, 42, 54, 0.06);
}

.contact-card.needs-attention {
  border-color: var(--rose);
  box-shadow: 0 0 0 2px rgba(181, 79, 97, 0.18), 0 8px 20px rgba(31, 42, 54, 0.06);
}

.attention-pill {
  background: var(--rose-soft);
  color: #8f3044;
}

.contact-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.contact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.priority-pill.alta {
  background: var(--rose-soft);
  color: #8f3044;
}

.priority-pill.media {
  background: var(--gold-soft);
  color: #86560b;
}

.priority-pill.baixa {
  background: var(--blue-soft);
  color: #28577f;
}

.source-pill {
  background: var(--sage-soft);
  color: var(--sage);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.card-actions button,
.card-actions a {
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.agenda-list,
.insights-grid {
  display: grid;
  gap: 12px;
}

.agenda-item,
.insight-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 8px;
}

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

.reply-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 12px;
  margin-bottom: 10px;
}

.reply-helper {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

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

.reply-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 16px;
}

.reply-card-head {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
}

.reply-card h3 {
  font-size: 18px;
  margin: 10px 0 0;
}

.reply-card p {
  color: #344054;
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
}

.reply-text {
  background: #fbfcfb;
  color: #344054;
  line-height: 1.55;
  min-height: 180px;
  overflow: auto;
  resize: vertical;
  white-space: pre-wrap;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e6ece9;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--sage);
}

.contact-dialog {
  width: min(920px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}

.contact-dialog::backdrop {
  background: rgba(24, 32, 31, 0.42);
}

#contactForm {
  padding: 22px;
}

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

.wide-field {
  margin-bottom: 12px;
}

.timeline-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  margin: 12px 0;
  padding: 14px;
}

.handoff-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sage-soft);
  margin: 12px 0;
  padding: 14px;
}

.compact-grid {
  margin-top: 10px;
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.timeline-head h3 {
  margin: 2px 0 0;
  font-size: 16px;
}

.timeline-list {
  display: grid;
  gap: 10px;
  max-height: 210px;
  overflow: auto;
  padding-right: 4px;
}

.timeline-item {
  border-left: 3px solid var(--sage);
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(31, 42, 54, 0.04);
  padding: 10px 12px;
}

.timeline-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.timeline-item p {
  margin: 0;
  white-space: pre-wrap;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.team-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 16px;
}

.checkbox-field {
  align-items: center;
  display: flex;
  gap: 8px;
}

.checkbox-field input {
  min-height: 0;
  width: auto;
}

.permissions-field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
}

.permissions-field legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 6px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  margin-top: 18px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }

  .main-nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .quick-panel {
    display: none;
  }

  .toolbar,
  .metric-grid,
  .board-toolbar,
  .reply-grid,
  .insights-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 40px 40px 1fr;
  }

  .toolbar,
  .metric-grid,
  .form-grid,
  .admin-layout,
  .reply-toolbar,
  .reply-grid,
  .insights-grid {
    grid-template-columns: 1fr;
  }

  .main-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .dialog-actions span {
    display: none;
  }
}
