* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: #fbf7f2;
  color: #3f2f23;
}

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

.sidebar {
  background: #f5efe6;
  border-right: 1px solid #e3d7c9;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #c2a070;
  color: #fff8e9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
}

.brand-subtitle {
  font-size: 12px;
  color: #8b6a4a;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  padding: 10px 14px;
  text-align: left;
  border-radius: 10px;
  color: #4b3625;
  cursor: pointer;
  font-weight: 600;
}

.nav-item:hover {
  background: #efe4d6;
}

.nav-item.active {
  background: #e7d7c2;
  border-color: #d8c3a7;
}

.sidebar-footer {
  margin-top: auto;
}

.status-pill {
  background: #efe4d6;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  text-align: center;
}

.content {
  padding: 28px 32px;
}

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

.page-title h1 {
  margin: 0;
  font-size: 26px;
}

.page-title p {
  margin: 6px 0 0;
  color: #7a5c41;
}

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

.search {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d8c3a7;
  background: #fff;
  min-width: 280px;
}

.btn {
  border: 1px solid #caa875;
  background: #caa875;
  color: #fff8e9;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: #b88b5a;
  border-color: #b88b5a;
}

.btn.ghost {
  background: transparent;
  color: #6e4f35;
}

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

.card {
  background: #fff8ef;
  border: 1px solid #ead9c4;
  border-radius: 14px;
  padding: 16px;
}

.card-title {
  color: #7a5c41;
  font-size: 14px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  margin: 8px 0;
}

.card-foot {
  color: #a0815b;
  font-size: 12px;
}

.panel {
  background: #fffdf8;
  border: 1px solid #ead9c4;
  border-radius: 14px;
  margin-top: 22px;
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.qr-wrapper {
  margin-top: 16px;
}

.qr-box {
  border: 1px dashed #d8c3a7;
  border-radius: 12px;
  padding: 12px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #8b6a4a;
}

.qr-box img {
  max-width: 200px;
  height: auto;
}

.status-message {
  margin-top: 12px;
  font-size: 13px;
  color: #8b6a4a;
}

.status-message[data-type="success"] {
  color: #2f7d32;
}

.status-message[data-type="error"] {
  color: #b23a30;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-content {
  background: #fffdf8;
  border: 1px solid #ead9c4;
  border-radius: 16px;
  padding: 20px;
  width: min(560px, 92vw);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

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

.modal-body {
  display: grid;
  gap: 16px;
}

.modal-step {
  display: none;
  gap: 12px;
}

.modal-step.active {
  display: grid;
}

.instance-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.instance-card {
  border: 1px solid #ead9c4;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.instance-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.instance-meta {
  font-size: 12px;
  color: #8b6a4a;
  margin-top: 6px;
}

.instance-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.table th, .table td {
  text-align: left;
  padding: 10px 6px;
  border-bottom: 1px solid #f0e4d6;
  font-size: 14px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.success {
  background: #e0caa8;
  color: #4a3626;
}

.pill.warning {
  background: #f2e2c8;
  color: #6a4d34;
}

.pill.neutral {
  background: #f5efe6;
  color: #6b4b34;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.timeline-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #f0e4d6;
  border-radius: 10px;
  background: #fff8ef;
}

.time {
  font-weight: 700;
  color: #6f4f35;
}

.chat-preview {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.chat-card {
  border: 1px solid #f0e4d6;
  border-radius: 12px;
  padding: 12px;
  background: #fff8ef;
}

.chat-name {
  font-weight: 700;
}

.chat-text {
  color: #6d4f36;
  margin: 6px 0;
}

.chat-meta {
  font-size: 12px;
  color: #9a7a57;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12px;
  color: #7a5c41;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d8c3a7;
  background: #fff;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .search {
    min-width: 100%;
  }
}
