:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #15171a;
  --muted: #68707d;
  --line: #e3e6ea;
  --soft: #f8f9fb;
  --accent: #ff5a16;
  --accent-dark: #db4610;
  --danger: #d92d20;
  --sidebar: #111418;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  background: #0e1116;
}

.login-art {
  background:
    linear-gradient(90deg, rgba(14, 17, 22, .18), rgba(14, 17, 22, .92)),
    url("/admin-ext/assets/admin-login-bg.png") center / cover no-repeat;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-height: 100vh;
  padding: 56px;
  background: #fff;
  box-shadow: -24px 0 80px rgba(0, 0, 0, .22);
}

.login-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.login-desc {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

label {
  display: grid;
  gap: 8px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 90, 22, .7);
  box-shadow: 0 0 0 3px rgba(255, 90, 22, .12);
}

button,
.link-button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

button:hover,
.link-button:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

button.ghost,
.link-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button.ghost:hover,
.link-button:hover {
  border-color: var(--accent);
  background: #fff5ef;
  color: var(--accent-dark);
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar);
  color: #fff;
  padding: 22px 16px;
}

.brand {
  padding: 10px 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.35;
}

.brand span {
  display: inline-flex;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  padding: 5px 10px;
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
}

.nav-menu {
  display: grid;
  gap: 6px;
  padding-top: 18px;
}

.nav-menu button {
  justify-content: flex-start;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  padding: 0 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
}

.nav-menu button:hover,
.nav-menu button.active {
  background: rgba(255, 90, 22, .16);
  color: #fff;
}

.nav-divider {
  margin: 14px 10px 6px;
  color: rgba(255, 255, 255, .42);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-head,
.toolbar,
.upload-inline,
.head-actions,
.dialog-head,
.dialog-actions,
.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  min-height: 72px;
  margin-bottom: 26px;
}

.topbar h1,
.section-head h2 {
  margin: 0;
  line-height: 1.2;
}

.topbar h1 {
  font-size: 28px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar select {
  width: auto;
  min-width: 120px;
}

.view {
  min-width: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.metric-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric,
.panel,
.table-wrap,
.module-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric {
  padding: 20px;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

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

.module-card {
  min-height: 156px;
  padding: 22px;
  color: var(--ink);
  text-align: left;
}

.module-card:hover {
  border-color: rgba(255, 90, 22, .45);
  background: #fffaf7;
  transform: translateY(-1px);
}

.module-card span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.module-card strong {
  display: block;
  margin-top: 18px;
  font-size: 20px;
}

.module-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.7;
}

.section-head {
  margin-bottom: 14px;
}

.compact-head {
  align-items: flex-start;
}

.compact-head .hint {
  margin-bottom: 0;
}

.head-actions {
  justify-content: flex-end;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  min-height: 38px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.tabs button:hover,
.tabs button.active {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--ink);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.code-editor {
  min-height: calc(100vh - 245px);
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid #edf0f3;
  padding: 14px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td img {
  width: 88px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: var(--soft);
}

tr.selected-row td {
  background: #fff7ed;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

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

.panel {
  min-height: 230px;
  padding: 22px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf0f3;
  color: #4b5563;
  font-size: 13px;
}

.list-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row strong {
  color: var(--ink);
}

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

.split-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.compact-form {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 20px;
}

.compact-form h2 {
  margin: 0;
  font-size: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.status.ok {
  background: #ecfdf3;
  color: #027a48;
}

.status.muted {
  background: #f2f4f7;
  color: #667085;
}

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

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--soft);
}

.detail-grid span,
.message-row strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.message-list {
  display: grid;
  gap: 10px;
}

.message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--soft);
}

.message-row span {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reply-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
}

.reply-box button {
  align-self: end;
  min-width: 120px;
}

.reply-box textarea:disabled,
.reply-box button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.session-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.session-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.session-card:hover {
  border-color: #fed7aa;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .07);
}

.session-card.has-unread {
  border-color: #ff5a16;
  background: #fff7ed;
}

.session-card.selected-row {
  box-shadow: inset 4px 0 0 #ff5a16;
}

.session-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.session-title strong {
  overflow-wrap: anywhere;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 12px;
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 9px;
  background: #ff5a16;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.service-pager {
  margin-top: 14px;
}

.service-session-dialog {
  max-height: min(760px, calc(100vh - 48px));
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
}

.service-dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.service-dialog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 12px;
}

.session-dialog-messages {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.form-grid label:nth-child(3),
.form-grid label:nth-child(5) {
  grid-column: 1 / -1;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.media-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.media-thumb {
  display: grid;
  place-items: center;
  height: 130px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 800;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-body {
  display: grid;
  gap: 8px;
  padding: 12px;
  font-size: 12px;
}

.media-body code {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

dialog {
  width: min(820px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, .55);
}

.dialog {
  display: grid;
  gap: 16px;
  padding: 22px;
}

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

.dialog-head h2 {
  margin: 0;
}

.dialog-actions {
  justify-content: flex-end;
  padding-top: 8px;
}

.inline {
  align-items: flex-start;
}

.inline > label {
  flex: 1;
}

.preview {
  min-height: 42px;
}

.preview img,
.preview video {
  max-width: 240px;
  max-height: 140px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
}

.empty {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .metric-grid,
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .login-screen,
  .app-shell {
    display: block;
  }

  .login-art {
    min-height: 34vh;
  }

  .login-panel {
    min-height: auto;
    padding: 32px 22px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 20px 14px;
  }

  .topbar,
  .section-head,
  .toolbar,
  .upload-inline,
  .head-actions,
  .inline,
  .reply-box {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar select,
  .toolbar a,
  .toolbar button {
    width: 100%;
  }

  .metric-grid,
  .metric-grid.three,
  .module-grid,
  .form-grid,
  .filter-bar,
  .split-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-grid label:nth-child(3),
  .form-grid label:nth-child(5) {
    grid-column: auto;
  }

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

  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .tabs button {
    flex: 0 0 auto;
  }

  .reply-box {
    grid-template-columns: 1fr;
  }

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

  .session-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .session-card .row-actions {
    justify-content: stretch;
  }

  .session-card .row-actions button {
    flex: 1;
  }

  .service-dialog-head,
  .service-dialog-meta {
    flex-direction: column;
  }

  .session-dialog-messages {
    max-height: 52vh;
  }
}

@media (max-width: 640px) {
  #service-view .table-wrap {
    overflow-x: visible;
  }

  #service-view table,
  #service-view thead,
  #service-view tbody,
  #service-view tr,
  #service-view th,
  #service-view td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #service-view thead {
    display: none;
  }

  #service-view tr {
    padding: 12px 14px;
    border-bottom: 1px solid #edf0f3;
  }

  #service-view td {
    padding: 6px 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  #service-view td .row-actions {
    margin-top: 4px;
  }
}
