/*
 * Chiiss Core UI foundation
 * Loaded after the migrated Ocean styles so every Core page shares one
 * predictable visual system without changing business markup or behavior.
 */

:root {
  --core-canvas: #f5f7fb;
  --core-surface: #ffffff;
  --core-surface-subtle: #f8faff;
  --core-ink: #101828;
  --core-muted: #667085;
  --core-line: #e4e9f2;
  --core-line-strong: #cfd7e6;
  --core-blue: #1f3cff;
  --core-blue-hover: #1831d8;
  --core-blue-soft: #edf1ff;
  --core-radius-sm: 8px;
  --core-radius: 12px;
  --core-shadow-card: 0 1px 2px rgba(16, 24, 40, 0.03), 0 8px 24px rgba(31, 60, 255, 0.035);
  --core-shadow-float: 0 18px 48px rgba(16, 24, 40, 0.16);
}

html {
  min-width: 320px;
  background: var(--core-canvas);
}

body {
  height: auto;
  min-height: 100vh;
  overflow: auto;
  background: var(--core-canvas);
  color: var(--core-ink);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 100;
  padding: 9px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--core-blue);
  box-shadow: var(--core-shadow-float);
  transform: translate(-50%, -160%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

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

.app-shell {
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--core-canvas);
}

.sidebar {
  border-color: var(--core-line);
  box-shadow: 8px 0 28px rgba(16, 24, 40, 0.025);
}

.sidebar-brand {
  min-height: 76px;
  padding: 15px 18px;
  border-color: var(--core-line);
}

.sidebar-brand strong {
  color: var(--core-ink);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  padding: 14px 10px 20px;
  scrollbar-color: #cbd3e1 transparent;
  scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd3e1;
}

.nav-group-label {
  margin: 24px 13px 8px;
  color: #8a97a8;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.nav-button {
  min-height: 42px;
  margin-bottom: 3px;
  padding: 0 12px;
  border-radius: 9px;
  color: #475467;
  transition: color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.nav-button:hover {
  background: #f4f6fa;
  transform: translateX(1px);
}

.nav-button.active {
  color: var(--core-blue);
  background: var(--core-blue-soft);
  box-shadow: inset 3px 0 0 var(--core-blue);
}

.sidebar-user {
  min-height: 78px;
  padding: 13px 14px;
  border-color: var(--core-line);
  background: rgba(255, 255, 255, 0.96);
}

.workspace {
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  min-height: 76px;
  padding: 12px clamp(20px, 2.2vw, 34px);
  border-color: var(--core-line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.015);
}

.breadcrumb {
  letter-spacing: 0.055em;
}

.topbar-leading h1 {
  margin-top: 4px;
  color: var(--core-ink);
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -0.018em;
}

.environment-badge {
  padding: 6px 10px;
  border-color: #b8c5ff;
  color: #2442d8;
  background: #f1f4ff;
}

.content {
  width: min(1600px, 100%);
  padding: clamp(20px, 2.2vw, 34px);
}

.core-ops-page {
  min-width: 0;
  color: var(--core-ink);
}

.core-page-title-duplicate,
.core-page-heading-only {
  display: none !important;
}

.product-summary-heading:has(> .core-page-title-duplicate) p {
  margin-top: 0;
}

.core-ops-page > .page > .page-header:has(.core-page-title-duplicate):not(.core-page-heading-only),
.core-ops-page > .page-header:has(.core-page-title-duplicate):not(.core-page-heading-only) {
  min-height: 40px;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.core-ops-page .card,
.core-ops-page .product-summary-panel,
.core-ops-page .product-summary-stats > div,
.core-ops-page .stat-card {
  border-color: var(--core-line);
  border-radius: var(--core-radius);
  box-shadow: var(--core-shadow-card);
}

.core-ops-page .card {
  overflow: clip;
}

.core-ops-page .card-header {
  min-height: 58px;
  padding: 15px 20px;
  border-color: var(--core-line);
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
}

.core-ops-page .card-header h3 {
  color: var(--core-ink);
  font-size: 16px;
  font-weight: 700;
}

.core-ops-page .card-body {
  padding: 20px;
}

.core-ops-page .page-header {
  margin-bottom: 18px;
}

.core-ops-page .page-header h1,
.core-ops-page .page-header h2 {
  color: var(--core-ink);
  font-size: 24px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.core-ops-page .btn,
.core-ops-page button.btn {
  border-radius: var(--core-radius-sm);
  font-weight: 650;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.core-ops-page .btn-primary {
  background: var(--core-blue);
  box-shadow: 0 4px 12px rgba(31, 60, 255, 0.14);
}

.core-ops-page .btn-primary:hover {
  background: var(--core-blue-hover);
  box-shadow: 0 6px 16px rgba(31, 60, 255, 0.2);
}

.core-ops-page .btn-outline {
  border-color: var(--core-line-strong);
  color: #475467;
  background: #fff;
}

.core-ops-page .btn-outline:hover {
  border-color: #aebcff;
  color: var(--core-blue);
  background: #f7f8ff;
}

.core-ops-page :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid rgba(31, 60, 255, 0.18);
  outline-offset: 2px;
}

.core-ops-page input:not([type="checkbox"]):not([type="radio"]),
.core-ops-page select,
.core-ops-page textarea {
  border-color: var(--core-line-strong);
  border-radius: var(--core-radius-sm);
  color: var(--core-ink);
  background-color: #fff;
}

.core-ops-page input:not([type="checkbox"]):not([type="radio"]):focus,
.core-ops-page select:focus,
.core-ops-page textarea:focus {
  border-color: var(--core-blue);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(31, 60, 255, 0.1);
}

.core-ops-page .tabs {
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--core-line);
  border-radius: 10px;
  background: #f5f7fb;
}

.core-ops-page .tab-btn {
  border-radius: 7px;
}

.core-ops-page .tab-btn.active {
  background: #fff;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.08);
}

.core-ops-page .tag,
.core-ops-page .badge {
  border-radius: 999px;
}

.core-ops-page .table-wrapper,
.core-ops-page .product-summary-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: #cbd3e1 #f6f8fb;
  scrollbar-width: thin;
}

.core-ops-page .table-wrapper::-webkit-scrollbar,
.core-ops-page .product-summary-table-wrap::-webkit-scrollbar {
  height: 8px;
}

.core-ops-page .table-wrapper::-webkit-scrollbar-track,
.core-ops-page .product-summary-table-wrap::-webkit-scrollbar-track {
  background: #f6f8fb;
}

.core-ops-page .table-wrapper::-webkit-scrollbar-thumb,
.core-ops-page .product-summary-table-wrap::-webkit-scrollbar-thumb {
  border: 2px solid #f6f8fb;
  border-radius: 999px;
  background: #bcc6d6;
}

.core-ops-page .table-wrapper > table,
.core-ops-page table.data-table {
  table-layout: auto;
}

.core-ops-page th {
  height: 44px;
  color: #69778c;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.core-ops-page td {
  color: #344054;
  font-size: 13px;
  line-height: 1.48;
}

.core-ops-page tbody tr {
  transition: background-color 120ms ease;
}

.core-ops-page tbody tr:hover td {
  background: #f8faff;
}

.core-ops-page .table-empty,
.core-ops-page .empty-state,
.core-ops-page .business-empty {
  color: var(--core-muted);
  background: linear-gradient(180deg, #fff 0%, #fafbfe 100%);
}

/* Data-heavy pages: keep columns readable and scroll the table instead of
 * squeezing identifiers, emails and actions into overlapping cells. */
#content[data-module="student-users"] .table-wrapper > table {
  min-width: 1280px;
}

#content[data-module="provider-full-process"] .table-wrapper > table,
#content[data-module="provider-experts"] .table-wrapper > table,
#content[data-module="provider-teachers"] .table-wrapper > table,
#content[data-module="provider-company"] .table-wrapper > table {
  min-width: 1120px;
}

#content[data-module="operators"] .card,
#content[data-module="space-mgmt"] .card,
#content[data-module="salary-rates"] .card,
#content[data-module="provider-permissions"] .card,
#content[data-module="operator-permissions"] .card {
  overflow-x: auto;
}

#content[data-module="course-ops"] .card {
  overflow: hidden;
}

#content[data-module="course-ops"] .card-body {
  overflow-x: auto;
}

#content[data-module="operators"] table {
  min-width: 920px;
}

#content[data-module="order-summary"] .table-wrapper > table,
#content[data-module="course-ops"] table {
  min-width: 1280px;
}

#content[data-module="guidance-ops"] .table-wrapper > table,
#content[data-module="space-mgmt"] table,
#content[data-module="salary-rates"] table {
  min-width: 980px;
}

#content[data-module="schools"] .table-wrapper > table,
#content[data-module="logs"] .table-wrapper > table {
  min-width: 1040px;
}

#content[data-module="provider-permissions"] table,
#content[data-module="operator-permissions"] table {
  min-width: 1080px;
}

#content[data-module="student-users"] td:nth-child(3),
#content[data-module="provider-full-process"] td:nth-child(3),
#content[data-module="provider-experts"] td:nth-child(3),
#content[data-module="provider-teachers"] td:nth-child(3),
#content[data-module="provider-company"] td:nth-child(3) {
  min-width: 190px;
  word-break: break-word;
}

#content[data-module="order-summary"] td:first-child,
#content[data-module="course-ops"] td:first-child {
  min-width: 138px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#content[data-module="order-summary"] td:last-child,
#content[data-module="student-users"] td:last-child {
  white-space: nowrap;
}

#content[data-module="student-users"] th:first-child,
#content[data-module="student-users"] td:first-child {
  min-width: 58px;
  white-space: nowrap;
}

#content[data-module="student-users"] th:nth-child(4),
#content[data-module="student-users"] td:nth-child(4) {
  min-width: 74px;
}

#content[data-module="student-users"] th:last-child,
#content[data-module="student-users"] td:last-child,
#content[data-module="order-summary"] th:last-child,
#content[data-module="order-summary"] td:last-child,
#content[data-module="course-ops"] th:last-child,
#content[data-module="course-ops"] td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #fff;
  box-shadow: -10px 0 16px -16px rgba(16, 24, 40, 0.7);
}

#content[data-module="student-users"] th:last-child,
#content[data-module="student-users"] td:last-child {
  min-width: 240px;
}

#content[data-module="order-summary"] th:last-child,
#content[data-module="order-summary"] td:last-child {
  min-width: 112px;
}

#content[data-module="course-ops"] th:last-child,
#content[data-module="course-ops"] td:last-child {
  min-width: 210px;
}

#content[data-module="student-users"] th:last-child,
#content[data-module="order-summary"] th:last-child,
#content[data-module="course-ops"] th:last-child {
  z-index: 2;
  background: #f8fafc;
}

#content[data-module="student-users"] tbody tr:hover td:last-child,
#content[data-module="order-summary"] tbody tr:hover td:last-child,
#content[data-module="course-ops"] tbody tr:hover td:last-child {
  background: #f8faff;
}

/* Reservation queues read better as balanced work cards on wide screens. */
#content[data-module="course-reservations"] .core-ops-page,
#content[data-module="guidance-reservations"] .core-ops-page,
#content[data-module="service-reservations"] .core-ops-page {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

#content[data-module="course-reservations"] .page-header,
#content[data-module="guidance-reservations"] .page-header,
#content[data-module="service-reservations"] .page-header {
  grid-column: 1 / -1;
}

#content[data-module="course-reservations"] .card,
#content[data-module="guidance-reservations"] .card,
#content[data-module="service-reservations"] .card {
  height: 100%;
  margin-bottom: 0 !important;
}

#content[data-module="course-reservations"] .card-body,
#content[data-module="guidance-reservations"] .card-body,
#content[data-module="service-reservations"] .card-body {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#content[data-module="course-reservations"] .card-body > :last-child,
#content[data-module="guidance-reservations"] .card-body > :last-child,
#content[data-module="service-reservations"] .card-body > :last-child {
  margin-top: auto !important;
  padding-top: 14px;
}

/* Finance and statistical pages use an even, responsive metric rhythm. */
#content[data-module="finance"] .stats-grid,
#content[data-module="statistics"] .stats-grid {
  gap: 14px;
}

#content[data-module="finance"] .stat-card,
#content[data-module="statistics"] .stat-card {
  min-height: 112px;
  padding: 20px;
}

#content[data-module="product-summary"] .product-summary-header {
  min-height: 40px;
}

#content[data-module="product-summary"] .product-summary-stats > div {
  min-height: 96px;
  padding: 18px 20px;
}

/* The message workspace must fill the available viewport and use the static
 * stylesheet; otherwise the strict Core CSP leaves the chat as raw markup. */
#content[data-module="messages"] {
  width: 100%;
  max-width: none;
  height: calc(100vh - 76px);
  padding: 20px;
}

#content[data-module="messages"] .core-ops-page,
#content[data-module="messages"] .imchat-root,
#content[data-module="messages"] .im-wrap {
  height: 100%;
  min-height: 0;
}

#content[data-module="messages"] .im-wrap {
  overflow: hidden;
  border: 1px solid var(--core-line);
  border-radius: var(--core-radius);
  box-shadow: var(--core-shadow-card);
}

#content[data-module="messages"] .im-side {
  width: 330px;
  border-color: var(--core-line);
}

#content[data-module="messages"] .im-side-hd {
  min-height: 60px;
  border-bottom: 1px solid #f0f2f6;
}

#content[data-module="messages"] .im-newbtn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--core-blue);
  font-weight: 650;
}

#content[data-module="messages"] .im-side-tools {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f6;
}

#content[data-module="messages"] .im-gsearch {
  height: 38px;
  border-color: var(--core-line);
  border-radius: 9px;
  background: #f7f8fb;
}

#content[data-module="messages"] .im-conv {
  margin: 2px 8px;
  padding: 10px;
  border-radius: 9px;
}

#content[data-module="messages"] .im-conv-body {
  padding-bottom: 0;
}

#content[data-module="messages"] .im-main {
  background: #fff;
}

#content[data-module="messages"] .im-mobile-back {
  display: none;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #475467;
  background: #f2f4f7;
  font-size: 25px;
  line-height: 1;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 236px minmax(0, 1fr);
  }

  .content {
    padding: 22px;
  }

  #content[data-module="messages"] .im-side {
    width: 300px;
  }
}

@media (max-width: 900px) {
  #content[data-module="course-reservations"] .core-ops-page,
  #content[data-module="guidance-reservations"] .core-ops-page,
  #content[data-module="service-reservations"] .core-ops-page {
    grid-template-columns: 1fr;
  }

  #content[data-module="messages"] .im-side {
    width: 280px;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
  }

  .topbar {
    min-height: 66px;
    padding: 10px 14px;
  }

  .topbar-leading h1 {
    font-size: 18px;
  }

  .content {
    padding: 16px 12px 24px;
  }

  .core-ops-page .card,
  .core-ops-page .product-summary-panel,
  .core-ops-page .stat-card {
    border-radius: 10px;
  }

  .core-ops-page .card-header,
  .core-ops-page .card-body {
    padding-left: 14px;
    padding-right: 14px;
  }

  .core-ops-page th,
  .core-ops-page td {
    padding-left: 12px;
    padding-right: 12px;
  }

  #content[data-module="messages"] {
    height: calc(100dvh - 66px);
    padding: 8px;
  }

  #content[data-module="messages"] .im-wrap {
    border-radius: 10px;
  }

  #content[data-module="messages"] .im-side {
    width: 100%;
    min-width: 0;
  }

  #content[data-module="messages"] .im-main {
    display: none;
  }

  #content[data-module="messages"] .im-wrap:has(.im-main .im-thd) .im-side {
    display: none;
  }

  #content[data-module="messages"] .im-wrap:has(.im-main .im-thd) .im-main {
    display: flex;
  }

  #content[data-module="messages"] .im-mobile-back {
    display: inline-flex;
  }

  #content[data-module="messages"] .im-conv {
    margin-inline: 4px;
    padding-inline: 7px;
  }

  #content[data-module="messages"] .im-ava {
    width: 38px;
    height: 38px;
  }

  #content[data-module="student-users"] th:last-child,
  #content[data-module="student-users"] td:last-child,
  #content[data-module="order-summary"] th:last-child,
  #content[data-module="order-summary"] td:last-child,
  #content[data-module="course-ops"] th:last-child,
  #content[data-module="course-ops"] td:last-child {
    position: static;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
@media (max-width: 520px) {
  .topbar-actions {
    gap: 4px;
  }

  .core-ops-page .product-summary-stats,
  #content[data-module="finance"] .stats-grid,
  #content[data-module="statistics"] .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  #content[data-module="messages"] .im-conv-time,
  #content[data-module="messages"] .im-conv-last {
    display: initial;
  }
}
