:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --ink: #182321;
  --muted: #60706b;
  --line: #dce4e0;
  --teal: #007f78;
  --teal-dark: #005c58;
  --mint: #dff4ed;
  --amber: #f5a524;
  --rose: #d94848;
  --shadow: 0 18px 50px rgba(31, 50, 45, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body:not(.auth-ready) [data-protected] {
  display: none;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(220, 228, 224, 0.82);
  background: rgba(246, 248, 247, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 13px;
}

.nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
  color: var(--muted);
  font-weight: 650;
}

.nav a:hover {
  color: var(--teal-dark);
}

.nav a.active {
  color: var(--ink);
}

.nav-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: white;
  font-weight: 700;
}

.session-action {
  color: var(--teal-dark);
}

.hero {
  position: relative;
  min-height: min(760px, calc(100vh - 72px));
  display: flex;
  align-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(246, 248, 247, 0.96) 0%, rgba(246, 248, 247, 0.8) 36%, rgba(246, 248, 247, 0.14) 72%),
    linear-gradient(0deg, rgba(24, 35, 33, 0.25), rgba(24, 35, 33, 0.05));
}

.hero-content {
  position: relative;
  width: min(640px, calc(100% - 36px));
  margin-left: clamp(18px, 6vw, 80px);
  padding: 70px 0 110px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(56px, 11vw, 124px);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 22px;
}

.hero-copy {
  max-width: 600px;
  margin: 24px 0 0;
  color: #33443f;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.45;
}

.hero-actions,
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button,
.icon-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.button {
  padding: 0 18px;
}

.primary {
  background: var(--teal);
  color: white;
}

.primary:hover {
  background: var(--teal-dark);
}

.ghost,
.secondary {
  border: 1px solid rgba(0, 127, 120, 0.32);
  background: rgba(255, 255, 255, 0.78);
  color: var(--teal-dark);
}

.icon-button {
  width: 46px;
  background: var(--ink);
  color: white;
  font-size: 28px;
  line-height: 1;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.metrics div {
  min-height: 132px;
  padding: 28px clamp(18px, 3vw, 42px);
  background: white;
}

.metrics strong {
  display: block;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

.metrics span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.section,
.workspace,
.admin {
  padding: clamp(56px, 8vw, 104px) clamp(18px, 4vw, 56px);
}

.page-intro {
  padding: clamp(52px, 7vw, 86px) clamp(18px, 4vw, 56px) 34px;
}

.page-intro h1,
.page-admin h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 0.98;
}

.page-intro p {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.5;
}

.page-workspace {
  padding-top: 24px;
}

.login-page {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: clamp(40px, 7vw, 86px) clamp(18px, 4vw, 56px);
  background: #edf3f0;
}

.login-panel {
  width: min(520px, 100%);
  padding: clamp(26px, 5vw, 44px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 0.98;
}

.login-copy {
  margin: 18px 0 26px;
  color: var(--muted);
  line-height: 1.5;
}

.login-form,
.user-form {
  display: grid;
  gap: 16px;
}

.section-head {
  max-width: 820px;
  margin-bottom: 30px;
}

.section-head.compact {
  margin-bottom: 24px;
}

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

.service-card {
  min-height: 220px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 1px 0 rgba(31, 50, 45, 0.04);
}

.service-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  font-weight: 900;
}

.service-card p,
.timeline p {
  color: var(--muted);
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 22px;
  align-items: stretch;
  background: #edf3f0;
}

.request-panel,
.status-panel,
.filters,
.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.request-panel {
  padding: clamp(22px, 4vw, 38px);
}

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

label {
  display: grid;
  gap: 8px;
  color: #33443f;
  font-size: 14px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cfd9d5;
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 128px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(0, 127, 120, 0.18);
  border-color: var(--teal);
}

.readonly-field {
  background: #f0f5f3;
  color: #4b625b;
}

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

.status-panel {
  padding: 28px;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 26px 0 0;
  display: grid;
  gap: 22px;
}

.timeline li {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
}

.timeline span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 850;
}

.timeline strong {
  display: block;
  margin-bottom: 4px;
}

.timeline p {
  margin: 0;
}

.admin {
  background: var(--bg);
}

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

.session-line {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.admin-actions {
  margin: 0;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.filters {
  padding: 18px;
  display: grid;
  gap: 16px;
  box-shadow: none;
}

.filter-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px;
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
}

.filter-stats strong {
  font-size: 32px;
}

.ticket-board {
  min-width: 0;
}

.table-shell {
  overflow-x: auto;
  box-shadow: none;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1) {
  width: 17%;
}

th:nth-child(2) {
  width: 18%;
}

th:nth-child(3) {
  width: 14%;
}

th:nth-child(4),
th:nth-child(5),
th:nth-child(6) {
  width: 13%;
}

th:nth-child(7) {
  width: 12%;
}

th,
td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  font-size: 14px;
}

.ticket-id {
  display: block;
  font-weight: 850;
}

.ticket-desc {
  display: block;
  max-width: 280px;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.table-status-select {
  min-height: 34px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 850;
}

.ticket-row-link {
  cursor: pointer;
}

.ticket-row-link:hover td {
  background: #f3faf7;
}

.ticket-row-link:focus-visible {
  outline: 3px solid rgba(0, 127, 120, 0.22);
  outline-offset: -3px;
}

.ticket-open-link {
  display: block;
  color: inherit;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
}

.priority-low {
  background: #eaf1ee;
  color: #4b625b;
}

.priority-medium {
  background: #dff4ed;
  color: #006a62;
}

.priority-high {
  background: #fff1cc;
  color: #8a5800;
}

.priority-critical {
  background: #ffe2e2;
  color: #a52525;
}

.status-new {
  background: #e6f7ff;
  color: #00658a;
}

.status-work {
  background: #e8f4df;
  color: #3d721c;
}

.status-wait {
  background: #fff3d9;
  color: #7a570c;
}

.status-closed {
  background: #eceff1;
  color: #56646a;
}

.sla-risk {
  color: var(--rose);
  font-weight: 850;
}

.empty-state {
  display: none;
  margin-top: 14px;
  padding: 20px;
  border: 1px dashed #b8c8c2;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: block;
}

.users-section {
  padding: 0 clamp(18px, 4vw, 56px) clamp(56px, 8vw, 104px);
  background: var(--bg);
}

.users-section.users-page {
  padding-top: clamp(56px, 8vw, 104px);
}

.users-page h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 0.98;
}

.users-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.user-form {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.users-table-shell {
  box-shadow: none;
}

.users-table {
  min-width: 760px;
}

.users-table th:nth-child(1),
.users-table th:nth-child(2),
.users-table th:nth-child(3),
.users-table th:nth-child(4),
.users-table th:nth-child(5),
.users-table th:nth-child(6),
.users-table th:nth-child(7) {
  width: auto;
}

.password-inline-form {
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.password-inline-form input {
  min-height: 36px;
  padding: 8px 10px;
}

.client-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(56px, 8vw, 104px) clamp(18px, 4vw, 56px) 28px;
}

.client-hero h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 0.98;
}

.client-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 0 clamp(18px, 4vw, 56px) 22px;
}

.profile-card {
  min-height: 106px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.profile-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-card strong {
  font-size: clamp(20px, 2vw, 28px);
}

.client-tickets {
  padding: 0 clamp(18px, 4vw, 56px) clamp(56px, 8vw, 104px);
}

.ticket-detail-page {
  padding: clamp(56px, 8vw, 104px) clamp(18px, 4vw, 56px);
}

.ticket-detail-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.ticket-detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ticket-detail-head h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 86px);
  line-height: 0.95;
}

.ticket-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.ticket-detail-main,
.ticket-detail-side,
.detail-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.ticket-detail-main {
  min-height: 240px;
  padding: clamp(22px, 4vw, 34px);
}

.ticket-detail-main h2 {
  font-size: clamp(28px, 4vw, 46px);
}

.ticket-detail-main p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.staff-comment {
  margin-top: 22px;
  padding: 16px;
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
}

.staff-comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.staff-comment p {
  margin: 8px 0 0;
  color: #315d57;
  font-size: 16px;
}

.ticket-detail-side {
  padding: 20px;
}

.status-form {
  display: grid;
  gap: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.detail-field {
  min-height: 92px;
  padding: 16px;
}

.detail-field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-field strong {
  font-size: 18px;
}

.ticket-history-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.history-tree {
  list-style: none;
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
}

.history-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  padding-bottom: 20px;
}

.history-item:last-child {
  padding-bottom: 0;
}

.history-dot {
  position: relative;
  z-index: 1;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #b8d4cd;
  border-radius: 999px;
  background: var(--mint);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
}

.history-branch {
  position: absolute;
  top: 36px;
  bottom: 0;
  left: 17px;
  width: 2px;
  background: #d7e5e0;
}

.history-item article {
  min-width: 0;
  padding: 0 0 2px;
}

.history-item time {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-item strong {
  display: block;
  font-size: 18px;
}

.history-item p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.history-item small {
  display: inline-block;
  margin-top: 8px;
  color: #4b625b;
  font-weight: 750;
}

.modal-open {
  overflow: hidden;
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  padding: clamp(16px, 3vw, 34px);
}

.history-modal.visible {
  display: grid;
  place-items: center;
}

.history-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 40, 36, 0.56);
}

.history-dialog {
  position: relative;
  z-index: 1;
  width: min(820px, 100%);
  max-height: min(760px, calc(100vh - 34px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: clamp(22px, 4vw, 34px);
  box-shadow: 0 24px 80px rgba(16, 30, 26, 0.24);
}

.history-dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.history-dialog h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

.icon-button {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.ticket-chat {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: clamp(22px, 4vw, 34px);
}

.ticket-chat h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

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

.chat-message {
  max-width: min(760px, 100%);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.chat-message.client-message {
  justify-self: start;
  border-color: #cfe1dc;
  background: var(--mint);
}

.chat-message.staff-message {
  justify-self: end;
  border-color: #d8d7e7;
  background: #f5f4fb;
}

.chat-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.chat-message-head span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.chat-message-head em {
  font-style: normal;
  color: var(--teal-dark);
}

.chat-message-head time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.chat-message p {
  margin: 0;
  color: #31504a;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--rose);
  cursor: pointer;
  font-weight: 800;
}

.text-button:hover {
  text-decoration: underline;
}

.text-button.positive {
  color: var(--teal-dark);
  text-align: left;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(130%);
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
  z-index: 20;
}

.toast:empty {
  display: none;
}

.toast.visible {
  transform: translateY(0);
}

@media (max-width: 980px) {
  .metrics,
  .service-grid,
  .workspace,
  .admin-layout,
  .users-layout,
  .client-summary,
  .ticket-detail-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }

  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-action {
    margin-left: auto;
  }

  .session-action {
    width: auto;
  }

  .hero {
    min-height: 690px;
    align-items: end;
  }

  .hero img {
    object-position: 60% center;
  }

  .hero-scrim {
    background:
      linear-gradient(0deg, rgba(246, 248, 247, 0.98) 0%, rgba(246, 248, 247, 0.92) 46%, rgba(246, 248, 247, 0.22) 100%),
      linear-gradient(90deg, rgba(246, 248, 247, 0.2), rgba(246, 248, 247, 0.05));
  }

  .hero-content {
    width: calc(100% - 36px);
    margin: 0 18px;
    padding: 280px 0 54px;
  }

  .ticket-form,
  .metrics {
    grid-template-columns: 1fr;
  }

  .admin-head {
    display: grid;
  }

  .client-hero {
    align-items: start;
    display: grid;
  }

  .ticket-detail-head {
    align-items: start;
    display: grid;
  }

  .ticket-detail-actions {
    width: 100%;
    display: grid;
  }

  .history-dialog {
    max-height: calc(100vh - 24px);
  }

  .history-dialog-head {
    display: grid;
  }

  .button {
    width: 100%;
  }

}
