:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --line: #dde3e6;
  --text: #162022;
  --muted: #637176;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --sidebar: #172326;
}

html {
  font-size: 15px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
}

body.sidebar-open {
  overflow: hidden;
}

a {
  color: var(--brand-strong);
  text-decoration: none;
}

a:hover {
  color: var(--brand);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.app-sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1070;
  background: rgba(12, 18, 20, .54);
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: #fff;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--brand);
  font-weight: 800;
}

.sidebar-nav {
  display: grid;
  gap: .35rem;
}

.sidebar-nav a {
  color: #d9e3e6;
  border-radius: 8px;
  padding: .7rem .85rem;
  font-weight: 600;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, .11);
  color: #fff;
}

.app-main {
  min-width: 0;
}

.auth-shell {
  display: block;
}

.auth-shell .app-main {
  min-height: 100vh;
}

.topbar {
  min-height: 86px;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.topbar-title > div {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 750;
}

.mobile-menu-toggle {
  width: 42px;
  height: 42px;
  display: none;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mobile-menu-toggle span {
  width: 20px;
  height: 2px;
  display: block;
  border-radius: 999px;
  background: currentColor;
}

.mobile-menu-toggle:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .16);
  outline: 0;
}

.page-kicker {
  color: var(--muted);
  font-size: .85rem;
}

.content {
  padding: 1.5rem;
}

.auth-content {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.userbar {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.userbar-name {
  display: grid;
  text-align: left;
}

.userbar-name span {
  font-weight: 700;
}

.userbar-name small {
  color: var(--muted);
}

.page-actions,
.filter-bar,
.form-actions {
  display: flex;
  align-items: end;
  gap: .75rem;
  flex-wrap: wrap;
}

.page-tabs .nav-link {
  color: var(--text);
}

.page-tabs .nav-link.active {
  color: var(--brand);
  font-weight: 700;
}

.ticket-workflow-tabs {
  display: flex;
  align-items: stretch;
  gap: .55rem;
  overflow-x: auto;
  padding: .25rem .1rem .45rem;
  scrollbar-width: thin;
}

.ticket-workflow-tab {
  min-width: 132px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: .68rem .8rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(22, 32, 34, .04);
  white-space: nowrap;
}

.ticket-workflow-tab:hover {
  color: var(--brand-strong);
  border-color: rgba(15, 118, 110, .36);
}

.ticket-workflow-tab.active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.ticket-workflow-tab.active .badge {
  color: var(--brand-strong) !important;
  background: #fff !important;
}

.ticket-workflow-title {
  font-weight: 750;
}

.ticket-workflow-tab .badge {
  min-width: 2rem;
  border-radius: 999px;
}

.ticket-tab-all {
  color: #fff;
  background: var(--brand-strong);
}

.ticket-workflow-archive {
  border-style: dashed;
}

.searchable-select {
  position: relative;
  width: 100%;
  min-width: 220px;
}

.filter-bar .searchable-select {
  min-width: 190px;
}

.searchable-select-native {
  position: absolute !important;
  inset-inline-start: 0;
  bottom: 0;
  width: 1px !important;
  height: 1px !important;
  opacity: 0;
  pointer-events: none;
}

.searchable-select-control {
  width: 100%;
  min-height: calc(1.5em + .75rem + 2px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .375rem .75rem;
  color: var(--text);
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .375rem;
  text-align: right;
}

.searchable-select-control:focus,
.searchable-select.is-open .searchable-select-control {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .16);
  outline: 0;
}

.searchable-select-control.input-validation-error {
  border-color: var(--danger);
}

.searchable-select-control:disabled {
  color: var(--muted);
  background: #eef3f3;
  cursor: not-allowed;
}

.searchable-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.searchable-select-control.is-placeholder .searchable-select-value {
  color: var(--muted);
}

.searchable-select-caret {
  width: 0;
  height: 0;
  flex: 0 0 auto;
  border-top: .35rem solid var(--muted);
  border-inline-start: .3rem solid transparent;
  border-inline-end: .3rem solid transparent;
}

.searchable-select-menu {
  position: absolute;
  z-index: 1055;
  inset-inline: 0;
  top: calc(100% + 4px);
  padding: .5rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(22, 32, 34, .14);
}

.searchable-select-search {
  direction: rtl;
}

.searchable-select-options {
  max-height: 230px;
  margin-top: .5rem;
  overflow-y: auto;
  display: grid;
  gap: .15rem;
}

.searchable-select-option {
  width: 100%;
  padding: .45rem .55rem;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: right;
}

.searchable-select-option:hover,
.searchable-select-option.is-active {
  background: #eef3f3;
}

.searchable-select-option.is-selected {
  color: var(--brand-strong);
  background: #e2f3ef;
  font-weight: 700;
}

.searchable-select-empty {
  padding: .7rem .5rem;
  color: var(--muted);
  text-align: center;
}

.searchable-select-create {
  color: var(--brand-strong);
  border-top: 1px solid var(--line);
  border-radius: 0;
  font-weight: 750;
}

.searchable-select-create:hover,
.searchable-select-create.is-active {
  color: #fff;
  background: var(--brand);
}

.select-with-action {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.select-with-action .searchable-select {
  flex: 1 1 auto;
  min-width: 0;
}

.select-with-action > .btn {
  flex: 0 0 auto;
  min-height: calc(1.5em + .75rem + 2px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 1rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.metric-card strong {
  display: block;
  font-size: 1.85rem;
  line-height: 1.1;
}

.metric-card span {
  color: var(--muted);
  font-weight: 600;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-card .table {
  margin-bottom: 0;
}

.table thead th {
  color: #334145;
  background: #eef3f3;
  border-bottom-color: var(--line);
  font-size: .9rem;
}

.table td,
.table th {
  vertical-align: middle;
}

.contact-actions {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.inline-form {
  display: inline;
  margin: 0;
}

.action-link-button {
  padding: 0;
  color: var(--bs-link-color);
  background: transparent;
  border: 0;
  font: inherit;
  text-decoration: none;
}

.action-link-button:hover,
.action-link-button:focus {
  color: var(--bs-link-hover-color);
  text-decoration: underline;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr);
  gap: 1rem;
}

.definition-list {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: .65rem 1rem;
}

.definition-list dt {
  color: var(--muted);
  font-weight: 600;
}

.definition-list dd {
  margin: 0;
}

.note-list,
.activity-list {
  display: grid;
  gap: .75rem;
}

.note-item,
.activity-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .8rem;
  background: #fbfcfc;
}

.muted {
  color: var(--muted);
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.btn-whatsapp {
  color: #fff;
  background: #128c7e;
  border-color: #128c7e;
}

.btn-whatsapp:hover,
.btn-whatsapp:focus {
  color: #fff;
  background: #0d6f64;
  border-color: #0d6f64;
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
}

.whatsapp-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.modal-loading {
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.customer-quick-view {
  display: grid;
  gap: 1rem;
}

.customer-quick-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--line);
}

.customer-quick-heading h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 750;
}

.customer-quick-heading span {
  color: var(--muted);
  font-weight: 600;
}

.customer-quick-list {
  grid-template-columns: 120px minmax(0, 1fr);
}

.customer-quick-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
}

.customer-quick-stats > div {
  padding: .75rem;
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.customer-quick-stats strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.1;
}

.customer-quick-stats span {
  color: var(--muted);
  font-weight: 700;
}

.validation-summary-errors ul {
  margin-bottom: 0;
}

.validation-summary-valid {
  display: none;
}

.login-wrap {
  width: min(100%, 430px);
  margin: 0 auto;
}

.install-wrap {
  width: min(100%, 880px);
  margin: 0 auto;
}

.settings-panel {
  max-width: 920px;
}

.install-panel {
  padding: 1.35rem;
}

.install-heading {
  margin-bottom: 1.25rem;
  text-align: center;
}

.install-heading h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 750;
}

.install-heading p {
  margin: .4rem 0 0;
  color: var(--muted);
}

.install-section {
  padding-block: 1rem;
  border-top: 1px solid var(--line);
}

.install-section h3 {
  margin-bottom: .85rem;
  font-size: 1.05rem;
  font-weight: 750;
}

.login-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: var(--brand);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(15, 118, 110, .24);
}

.login-brand {
  text-align: center;
  margin-bottom: 1rem;
  color: var(--muted);
  font-weight: 700;
}

.login-wrap .panel {
  padding: 1.25rem;
}

.login-wrap h2 {
  text-align: center;
  font-weight: 750;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    width: min(82vw, 300px);
    max-width: 300px;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1080;
    height: 100vh;
    padding: 1rem;
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform .22s ease;
    box-shadow: -18px 0 42px rgba(0, 0, 0, .18);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: .9rem 1rem;
  }

  .topbar h1 {
    overflow: hidden;
    font-size: 1.25rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .userbar {
    justify-content: space-between;
  }

  .content {
    padding: 1rem;
  }

  .filter-bar .searchable-select {
    min-width: 100%;
  }

  .ticket-workflow-tabs {
    margin-inline: -1rem;
    padding-inline: 1rem;
  }

  .ticket-workflow-tab {
    min-width: 150px;
  }

  .select-with-action {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .definition-list {
    grid-template-columns: 1fr;
  }

  .customer-quick-list,
  .customer-quick-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .metric-grid,
  .sidebar-nav {
    grid-template-columns: 1fr;
  }
}
