:root {
  color-scheme: dark;
  --bg: #070815;
  --panel: rgba(20, 23, 43, 0.88);
  --panel-strong: #161a31;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f8f8ff;
  --muted: #a6abc6;
  --violet: #7357ff;
  --cyan: #51d5ff;
  --green: #6ee7a5;
  --rose: #ff5f91;
  --warning: #ffc766;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(115, 87, 255, 0.24), transparent 34rem),
    linear-gradient(135deg, #070815 0%, #12142a 48%, #071a22 100%);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(23rem, 0.82fr) minmax(34rem, 1.38fr);
  gap: 1.1rem;
  width: min(1400px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0;
}

.brand-panel,
.workspace,
.order-panel,
.login-panel,
.member-help-panel,
.feature-list,
.ticket-console {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: calc(100vh - 2rem);
  padding: 1.45rem;
  border-radius: 8px;
}

.brand-mark {
  position: relative;
  width: 5.1rem;
  aspect-ratio: 1;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  box-shadow: 0 18px 42px rgba(81, 213, 255, 0.22);
}

.brand-bubble {
  position: absolute;
  inset: 1rem 0.75rem 1.25rem;
  border-radius: 1.1rem;
  background: #101329;
}

.brand-bubble::after {
  content: "";
  position: absolute;
  right: 0.55rem;
  bottom: -0.42rem;
  width: 0.86rem;
  height: 0.86rem;
  background: #101329;
  transform: rotate(45deg);
}

.brand-dot {
  position: absolute;
  top: 2.2rem;
  width: 0.48rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--text);
  z-index: 1;
}

.brand-dot-left {
  left: 2rem;
}

.brand-dot-right {
  right: 2rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #9aa5ff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(3.2rem, 4.6vw, 4.65rem);
  line-height: 0.96;
  white-space: nowrap;
}

h1 span {
  color: var(--violet);
}

h2 {
  margin-bottom: 0.8rem;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0.2rem;
  font-size: 0.98rem;
}

.lead {
  max-width: 38rem;
  color: #e4e5f3;
  font-size: 1.04rem;
  line-height: 1.55;
}

.order-panel,
.login-panel,
.member-help-panel,
.feature-list {
  border-radius: 8px;
  padding: 1rem;
}

.form-grid,
.login-form {
  display: grid;
  gap: 0.8rem;
}

.member-login-form {
  display: none;
}

body.login-required {
  overflow: hidden;
}

body.login-required::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 5, 18, 0.56);
}

body.login-required .workspace,
body.login-required .brand-panel > :not(.order-panel) {
  opacity: 0.35;
}

body.login-required .member-login-form {
  position: fixed;
  display: grid;
  z-index: 50;
  left: 50%;
  top: 50%;
  width: min(92vw, 62rem);
  min-height: min(82vh, 45rem);
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(35, 23, 83, 0.96), rgba(11, 13, 30, 0.97)),
    var(--panel-strong);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.62);
  padding: clamp(1.4rem, 4vw, 4rem);
  transform: translate(-50%, -50%);
}

body.login-required .member-login-form h2 {
  margin: 0 0 1.8rem;
  color: #bd5cc7;
  font-size: clamp(4rem, 12vw, 8.8rem);
  font-weight: 500;
  line-height: 0.9;
  text-align: center;
}

body.login-required .member-login-form .eyebrow {
  color: #8f9cff;
  text-align: center;
}

body.login-required .member-login-form label {
  color: #bd5cc7;
  font-size: clamp(1.3rem, 3vw, 2.1rem);
  font-weight: 500;
}

body.login-required .member-login-form input {
  min-height: 3.6rem;
  border-color: rgba(189, 92, 199, 0.25);
  background: rgba(8, 10, 26, 0.72);
  font-size: clamp(1rem, 1.6vw, 1.25rem);
}

body.login-required .member-login-form .primary-action {
  width: auto;
  min-width: 12rem;
  color: #eab7f0;
  background: transparent;
  border: 2px solid rgba(189, 92, 199, 0.9);
  box-shadow: 0 0 0 4px rgba(189, 92, 199, 0.15);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 500;
}

.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.8rem;
}

.login-actions span {
  color: #eab7f0;
  font-size: clamp(1.2rem, 2.4vw, 2rem);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

label {
  display: grid;
  gap: 0.4rem;
  color: #d9dcf1;
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 8, 21, 0.78);
  color: var(--text);
  outline: none;
  padding: 0.78rem 0.86rem;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 5.2rem;
}

.password-toggle {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  min-width: 3.8rem;
  border: 1px solid rgba(189, 92, 199, 0.46);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #eab7f0;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0.45rem 0.55rem;
  transform: translateY(-50%);
}

.password-toggle:hover {
  border-color: rgba(189, 92, 199, 0.9);
  background: rgba(189, 92, 199, 0.15);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(81, 213, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(81, 213, 255, 0.13);
}

.primary-action,
.send-action,
.ghost-action,
.danger-action,
.icon-action {
  border: 0;
  border-radius: 8px;
  color: var(--text);
  font-weight: 900;
}

.primary-action,
.send-action {
  background: linear-gradient(135deg, var(--violet), #8a49ff);
  padding: 0.82rem 1rem;
}

.ghost-action,
.icon-action {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  padding: 0.62rem 0.78rem;
}

.danger-action {
  background: rgba(255, 95, 145, 0.18);
  border: 1px solid rgba(255, 95, 145, 0.42);
  padding: 0.7rem 0.9rem;
}

.workspace {
  display: grid;
  gap: 1rem;
  min-height: calc(100vh - 2rem);
  padding: 1rem;
  border-radius: 8px;
}

.topbar,
.chat-head,
.sidebar-head,
.session-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.session-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2.35rem;
  border-radius: 999px;
  background: rgba(110, 231, 165, 0.13);
  color: var(--green);
  padding: 0 0.9rem;
  font-weight: 900;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(20rem, 1fr) minmax(17rem, 0.62fr);
  gap: 1rem;
}

.feature-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

.feature-list article {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.75rem;
  align-items: start;
}

.feature-list article > div {
  min-width: 0;
}

.feature-list h3,
.feature-list p {
  overflow-wrap: anywhere;
}

.feature-list p,
.member-help-panel p,
.ticket-button span,
.message-meta,
.empty-state,
.login-panel p {
  color: var(--muted);
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(81, 213, 255, 0.15);
  color: var(--cyan);
  font-weight: 1000;
}

.ticket-console {
  display: grid;
  grid-template-columns: minmax(12.5rem, 0.38fr) minmax(0, 1fr);
  min-height: 31rem;
  overflow: hidden;
  border-radius: 8px;
}

.ticket-sidebar {
  border-right: 1px solid var(--line);
  background: rgba(8, 10, 24, 0.42);
  padding: 0.9rem;
}

.ticket-list {
  display: grid;
  gap: 0.45rem;
}

.ticket-button {
  display: grid;
  gap: 0.2rem;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0.72rem;
  text-align: left;
}

.ticket-button:hover,
.ticket-button.active {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.ticket-button.closed {
  opacity: 0.62;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 900;
}

.status-pill {
  border-radius: 999px;
  padding: 0.16rem 0.45rem;
  color: #06100b;
  background: var(--green);
  font-size: 0.68rem;
}

.status-pill.closed {
  background: var(--warning);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.chat-head {
  border-bottom: 1px solid var(--line);
  padding: 1rem;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 22rem;
  max-height: 50vh;
  overflow-y: auto;
  padding: 1rem;
}

.message {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 0.72rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 2.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #fff;
  font-weight: 1000;
}

.message-body {
  min-width: 0;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.16rem;
  font-size: 0.78rem;
}

.message-meta strong {
  color: var(--text);
}

.message-text {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  border-top: 1px solid var(--line);
  padding: 1rem;
}

.form-error {
  min-height: 1.1rem;
  margin: 0;
  color: var(--rose);
  font-size: 0.84rem;
  font-weight: 800;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100%;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
}

.hidden {
  display: none !important;
}

.admin-shell {
  display: grid;
  gap: 1rem;
  width: min(1320px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0;
}

.admin-entry {
  margin-top: 0.8rem;
}

.admin-topbar,
.admin-login-screen,
.admin-stats,
.admin-console {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.admin-login-screen {
  display: grid;
  gap: 1rem;
  width: min(34rem, 100%);
  margin: 0 auto;
  padding: 1.2rem;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
}

.admin-title {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.35rem);
  white-space: normal;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 900;
  padding: 0 0.9rem;
  text-decoration: none;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
}

.admin-stats article {
  background: rgba(7, 8, 21, 0.34);
  padding: 1rem;
}

.admin-stats span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--cyan);
  font-size: 2rem;
  font-weight: 1000;
}

.admin-stats p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.admin-console {
  display: grid;
  grid-template-columns: minmax(18rem, 0.42fr) minmax(0, 1fr);
  min-height: 38rem;
  overflow: hidden;
}

.admin-orders {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(8, 10, 24, 0.42);
  padding: 1rem;
}

.admin-orders .ticket-list {
  max-height: calc(100vh - 20rem);
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.35rem;
  scrollbar-color: rgba(189, 92, 199, 0.82) rgba(255, 255, 255, 0.07);
  scrollbar-width: thin;
}

.admin-orders .ticket-list::-webkit-scrollbar {
  width: 0.55rem;
}

.admin-orders .ticket-list::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.admin-orders .ticket-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(189, 92, 199, 0.82);
}

.admin-chat .messages {
  max-height: 58vh;
}

@media (max-width: 1050px) {
  .app-shell,
  .dashboard-grid,
  .ticket-console,
  .admin-console {
    grid-template-columns: 1fr;
  }

  .brand-panel,
  .workspace {
    min-height: auto;
  }

  .workspace {
    align-content: start;
  }

  .topbar {
    order: 1;
  }

  .ticket-console {
    order: 2;
  }

  .dashboard-grid {
    order: 3;
  }

  .feature-list {
    grid-template-columns: 1fr;
  }

  .ticket-sidebar,
  .admin-orders {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-orders .ticket-list {
    max-height: 22rem;
  }

  .ticket-list {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 0.8rem, 1180px);
    padding: 0.4rem 0;
  }

  .brand-panel,
  .workspace,
  .order-panel,
  .login-panel,
  .ticket-sidebar,
  .chat-head,
  .messages,
  .message-form {
    padding: 0.8rem;
  }

  .topbar,
  .chat-head,
  .session-actions,
  .admin-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .message-form {
    grid-template-columns: 1fr;
  }

  .login-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(3rem, 15vw, 4rem);
    white-space: normal;
  }

  .admin-shell {
    width: min(100% - 0.8rem, 1320px);
    padding: 0.4rem 0;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }
}
