:root {
  --bg: #eef4f1;
  --panel: #ffffff;
  --ink: #1a2724;
  --muted: #66736f;
  --line: #d8e3df;
  --brand: #164945;
  --brand-2: #24766e;
  --accent: #e7b94d;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(18, 48, 44, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 73, 69, 0.08), rgba(231, 185, 77, 0.12)),
    var(--bg);
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
}

.login-brand {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 42px;
  background: var(--brand);
  color: #f8fffd;
}

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

.brand-lockup img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.login-copy {
  align-self: center;
  max-width: 560px;
  transform: translateY(clamp(-72px, -7vh, -18px));
}

.login-copy h1 {
  margin: 0 0 16px;
  font-size: clamp(2.4rem, 5vw, 4.9rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-copy p {
  margin: 0;
  color: rgba(248, 255, 253, 0.82);
  font-size: 1.08rem;
  line-height: 1.65;
}

.login-panel-wrap {
  display: grid;
  place-items: center;
  padding: 28px;
}

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

.login-panel h2,
.page-title h1,
.modal h3 {
  margin: 0;
}

.login-panel p,
.page-title p {
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  font-size: 0.86rem;
  font-weight: 700;
  color: #40504c;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.field textarea {
  min-height: 130px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(36, 118, 110, 0.14);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: #40504c;
  font-weight: 800;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
}

.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 4px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--brand);
}

.secondary-btn {
  color: var(--brand);
  background: #e5efec;
}

.ghost-btn {
  color: var(--ink);
  background: transparent;
}

.error-text {
  min-height: 22px;
  color: var(--danger);
  font-weight: 700;
  margin-top: 10px;
}

.error-text.loading {
  color: var(--brand);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #123d39;
  color: #f8fffd;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand-lockup img {
  width: 54px;
  height: 54px;
}

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

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: rgba(248, 255, 253, 0.78);
  text-align: left;
  font-weight: 800;
}

.nav button.active,
.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.session-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.session-card strong,
.session-card span {
  display: block;
}

.session-card span {
  color: rgba(248, 255, 253, 0.72);
  font-size: 0.86rem;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.main {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.page-title h1 {
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  letter-spacing: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat,
.content-panel,
.ticket-card,
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(18, 48, 44, 0.08);
}

.stat {
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.content-panel {
  padding: 20px;
}

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

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

.segmented {
  display: flex;
  gap: 6px;
  background: #dfe9e5;
  border-radius: 8px;
  padding: 5px;
}

.segmented button {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.active {
  color: var(--brand);
  background: #fff;
}

.ticket-list {
  display: grid;
  gap: 12px;
}

.ticket-card {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.ticket-card h3 {
  margin: 0 0 8px;
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  width: fit-content;
  height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #e6f0ed;
  color: var(--brand);
  font-weight: 900;
  font-size: 0.78rem;
}

.status.aberto {
  color: #7b5e00;
  background: #fff9c2;
}

.status.agendado {
  color: #2563eb;
  background: #dbeafe;
}

.status.em-deslocamento {
  color: #374151;
  background: #e5e7eb;
}

.status.em-atendimento {
  color: #c2410c;
  background: #ffedd5;
}

.status.fechado {
  color: #166534;
  background: #dcfce7;
}

.status.cancelado {
  color: #991b1b;
  background: #fee2e2;
}

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

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

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 28, 26, 0.58);
  z-index: 10;
}

.modal {
  width: min(920px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  padding: 22px;
}

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

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

.info-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.info-box span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.info-box strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--brand-2);
  padding: 8px 0 8px 12px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #102f2c;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

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

  .login-brand {
    min-height: 360px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .stats-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .ticket-card,
  .topbar,
  .toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .main {
    padding: 18px;
  }
}
