:root {
  --app-black: #080808;
  --app-red: #c91522;
  --app-red-dark: #8f0f18;
  --app-border: #e7e7e7;
  --app-muted: #6d6d6d;
  --app-header-height: 96px;
}

html,
body {
  min-height: 100%;
}

body {
  background: #f7f7f7;
  color: #171717;
  font-weight: 400;
  letter-spacing: 0;
}

* {
  font-weight: 400 !important;
}

.app-block,
.app-sidebar,
.app-content,
.app-footer,
.login-panel,
.metric-card {
  padding: 20px;
}

.messages-stack {
  margin-bottom: 16px;
}

.table-surface {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  overflow-x: auto;
}

.table-surface .table th {
  color: var(--app-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.table-surface .table th,
.table-surface .table td {
  padding: 14px 16px;
  vertical-align: middle;
  white-space: nowrap;
}

.empty-state {
  color: var(--app-muted);
  padding: 28px 16px !important;
  text-align: center;
}

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

.table-actions .btn {
  min-height: 42px;
  min-width: 88px;
  padding: 10px 14px;
}

.repeat-row {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.repeat-row .form-control {
  flex: 1;
  min-width: 0;
}

.repeat-row .btn {
  flex: 0 0 auto;
  min-height: 46px;
}

.modal-content {
  border: 0;
  border-radius: 8px;
}

.modal-header {
  border-bottom-color: var(--app-border);
  padding: 20px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  background: #fff;
  border-top-color: var(--app-border);
  gap: 8px;
  padding: 16px 20px;
}

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

.permission-list-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.blocked-page {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 20px;
}

.blocked-page h1 {
  font-size: 1.9rem;
  margin-bottom: 12px;
}

.blocked-page p {
  color: var(--app-muted);
  margin-bottom: 20px;
}

.app-navbar {
  background: var(--app-black);
  border-bottom: 4px solid var(--app-red);
  margin: 0;
}

.app-navbar > .container-fluid {
  display: flex;
  justify-content: flex-start;
}

.navbar-brand {
  display: flex;
  flex: 0 0 auto;
  letter-spacing: 0;
  margin-right: 20px;
  padding-bottom: 0;
  padding-top: 0;
  text-align: left;
}

.app-logo {
  display: block;
  height: auto;
  max-width: 100%;
}

.app-logo-navbar {
  max-height: 52px;
  object-fit: contain;
  object-position: left center;
  width: 190px;
}

.app-shell {
  display: flex;
  min-height: calc(100vh - var(--app-header-height));
}

.app-sidebar {
  width: 280px;
  flex: 0 0 280px;
  background: #fff;
  color: #171717;
  border-right: 1px solid var(--app-border);
}

.sidebar-title {
  color: var(--app-muted);
  font-size: 0.78rem;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.sidebar-link {
  align-items: center;
  border-radius: 6px;
  color: #252525;
  display: flex;
  margin-bottom: 8px;
  min-height: 44px;
  padding: 10px 12px;
  text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--app-red);
  color: #fff;
}

.app-content {
  flex: 1;
  margin-left: auto;
  margin-right: auto;
  max-width: 1400px;
  min-width: 0;
  width: 100%;
}

.page-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-heading h1 {
  font-size: 1.9rem;
  margin: 0;
}

.page-subtitle {
  color: var(--app-muted);
  margin: 6px 0 0;
}

.eyebrow {
  color: var(--app-red);
  font-size: 0.8rem;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  min-height: 140px;
}

.metric-card span {
  color: var(--app-muted);
  display: block;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.metric-value {
  color: var(--app-black);
  display: block;
  font-size: 1.6rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.chat-layout {
  align-items: flex-start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.chat-panel,
.context-panel {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 20px;
}

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 4px;
}

.chat-message {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  max-width: 82%;
  padding: 14px;
}

.chat-message p {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.chat-message-customer {
  align-self: flex-start;
  background: #fafafa;
}

.chat-message-team {
  align-self: flex-end;
  background: #fff5f6;
  border-color: #f1b7bd;
}

.chat-message-internal {
  align-self: center;
  background: #f6f6f6;
  border-style: dashed;
  max-width: 100%;
}

.chat-meta {
  color: var(--app-muted);
  font-size: 0.82rem;
}

.chat-photo {
  border-radius: 6px;
  display: block;
  margin-top: 10px;
  max-height: 260px;
  max-width: 100%;
  object-fit: contain;
}

.chat-compose {
  border-top: 1px solid var(--app-border);
  margin-top: 20px;
  padding-top: 20px;
}

.context-panel h2 {
  color: var(--app-red);
  font-size: 0.95rem;
  margin: 20px 0 10px;
}

.context-panel h2:first-child {
  margin-top: 0;
}

.context-panel dl {
  display: grid;
  gap: 8px;
  grid-template-columns: 110px minmax(0, 1fr);
  margin: 0;
}

.context-panel dt {
  color: var(--app-muted);
}

.context-panel dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.context-card {
  border: 1px solid var(--app-border);
  border-radius: 6px;
  margin-bottom: 8px;
  padding: 10px;
}

.app-footer {
  align-items: center;
  background: #fff;
  border-top: 1px solid var(--app-border);
  color: #171717;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  width: 100%;
}

.app-footer .text-white-50 {
  color: var(--app-muted) !important;
}

.login-page {
  align-items: center;
  background: linear-gradient(135deg, #080808 0%, #171717 58%, #c91522 100%);
  display: flex;
  min-height: 100vh;
  padding: 20px;
}

.login-panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  margin: 0 auto;
  max-width: 440px;
  width: 100%;
}

.login-brand {
  align-items: center;
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
  overflow: hidden;
}

.login-logo {
  max-height: 180px;
  max-width: min(100%, 300px);
  object-fit: contain;
  width: 100%;
}

@media (max-width: 420px) {
  .login-logo {
    max-height: 150px;
    max-width: 260px;
  }
}

.form-control {
  border-radius: 6px;
  min-height: 46px;
}

.form-select {
  border-radius: 6px;
  min-height: 46px;
}

.required-label::after {
  color: var(--app-red);
  content: " *";
}

.is-required-invalid {
  border-color: var(--app-red) !important;
}

.required-feedback {
  color: var(--app-red);
  display: none;
  font-size: 0.82rem;
  margin-top: 6px;
}

.is-required-invalid + .required-feedback {
  display: block;
}

.btn {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  line-height: 1;
}

.btn-danger {
  background: var(--app-red);
  border-color: var(--app-red);
  border-radius: 6px;
  min-height: 46px;
}

.btn-danger:hover {
  background: var(--app-red-dark);
  border-color: var(--app-red-dark);
}

@media (max-width: 767.98px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    border-bottom: 1px solid var(--app-border);
    border-right: 0;
    width: 100%;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-message {
    max-width: 100%;
  }

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