:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --soft: #f8faf9;
  --line: #dce4e0;
  --text: #18231f;
  --muted: #66736f;
  --green: #10a66a;
  --green-dark: #087a4c;
  --blue: #2e6bed;
  --orange: #e4822f;
  --red: #d94d45;
  --shadow: 0 14px 34px rgba(20, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.app-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px;
  background: #14211c;
  color: #fff;
}

.brand,
.rail-nav a,
.workspace-card,
.topbar,
.role-tabs,
.top-actions,
.metric,
.panel-toolbar,
.row-main,
.row-meta,
.ticket-head,
.timeline-item,
.system-footer {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  min-height: 48px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--green);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
}

.rail-nav {
  display: grid;
  gap: 5px;
  margin-top: 26px;
}

.rail-nav a {
  gap: 9px;
  min-height: 38px;
  padding: 0 10px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: 8px;
}

.rail-nav a.active,
.rail-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.workspace-card {
  display: grid;
  gap: 5px;
  margin-top: 28px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 8px;
}

.workspace-card span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.workspace {
  padding: 16px;
}

.topbar {
  gap: 14px;
  min-height: 64px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar > div:first-child {
  min-width: 0;
  margin-right: auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

.topbar span,
.panel-toolbar span,
.row-meta,
.ticket-grid span,
.system-footer {
  color: var(--muted);
}

.role-tabs {
  gap: 4px;
  padding: 4px;
  background: #eef2f0;
  border-radius: 8px;
}

.role-tabs button,
.top-actions button,
.panel-toolbar button,
.filter-bar button,
.ticket-head button,
.primary-action,
.secondary-action,
.submit-action,
.phone-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 720;
}

.role-tabs button {
  background: transparent;
  border-color: transparent;
}

.role-tabs button.active {
  background: #fff;
  box-shadow: 0 6px 16px rgba(20, 33, 28, 0.08);
}

.top-actions {
  gap: 8px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.metric {
  gap: 9px;
  min-height: 72px;
  padding: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  margin-left: auto;
  font-size: 24px;
}

.ops-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1fr) minmax(320px, 0.82fr);
  gap: 12px;
  margin-top: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.queue-panel,
.detail-panel,
.agent-panel,
.board-panel,
.insight-panel,
.integration-panel,
.customer-panel,
.customer-status,
.customer-agent {
  padding: 14px;
}

.panel-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-toolbar strong,
.panel-toolbar span {
  display: block;
}

.panel-toolbar span {
  margin-top: 3px;
  font-size: 12px;
}

.filter-bar {
  display: flex;
  gap: 7px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.filter-bar button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.filter-bar button.active {
  color: #fff;
  background: #14211c;
  border-color: #14211c;
}

.record-list {
  display: grid;
  gap: 8px;
}

.record-row {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.record-row.selected,
.record-row:hover {
  background: #effaf5;
  border-color: rgba(16, 166, 106, 0.36);
}

.row-main {
  gap: 10px;
  align-items: flex-start;
}

.row-main div {
  min-width: 0;
}

.row-main strong,
.row-main small {
  display: block;
}

.row-main strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main small {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 24px;
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.priority.p1 {
  background: var(--red);
}

.priority.p2 {
  background: var(--orange);
}

.priority.p3 {
  background: var(--blue);
}

.row-meta {
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.ticket-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ticket-head span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.ticket-head h2 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.25;
}

.ticket-head button {
  width: 34px;
  padding: 0;
}

.ticket-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.ticket-grid div {
  display: grid;
  gap: 4px;
  min-height: 66px;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-grid span {
  font-size: 12px;
}

.ticket-grid strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raw-feedback {
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.raw-feedback > div {
  margin-bottom: 8px;
}

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

textarea {
  min-height: 112px;
  padding: 11px;
  resize: vertical;
  line-height: 1.6;
}

input,
.select-control {
  min-height: 40px;
  padding: 0 11px;
}

textarea:focus,
input:focus {
  border-color: rgba(16, 166, 106, 0.7);
  box-shadow: 0 0 0 3px rgba(16, 166, 106, 0.1);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.timeline-item {
  gap: 8px;
  align-items: flex-start;
  min-height: 78px;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timeline-item.done {
  border-color: #cae6da;
}

.timeline-item.active {
  border-color: #f1cda9;
  background: #fff8ef;
}

.timeline-item strong,
.timeline-item span {
  display: block;
}

.timeline-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.agent-panel {
  display: flex;
  flex-direction: column;
}

.agent-head {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #eef8f3;
  border: 1px solid #cfe5da;
  border-radius: 8px;
}

.agent-head div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.agent-head span {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.agent-head strong {
  font-size: 24px;
}

.confidence-track {
  height: 8px;
  overflow: hidden;
  background: #d8e8df;
  border-radius: 999px;
}

.confidence-track i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.agent-fields {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.agent-fields div {
  display: grid;
  gap: 5px;
}

.agent-fields dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.agent-fields dd {
  margin: 0;
  color: #293631;
  font-size: 13px;
  line-height: 1.55;
}

.message-card-preview {
  display: grid;
  gap: 7px;
  margin-top: auto;
  padding: 12px;
  background: #f6f8ff;
  border: 1px solid #dce3ff;
  border-radius: 8px;
}

.message-card-preview span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.message-card-preview p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.action-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.primary-action {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.secondary-action {
  background: #fff;
}

.ops-dock {
  display: grid;
  grid-template-columns: 1fr 0.72fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.dock-title {
  margin-bottom: 10px;
}

.workflow-columns {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.workflow-columns div,
.integration-grid div {
  display: grid;
  gap: 5px;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workflow-columns span,
.integration-grid span {
  color: var(--muted);
  font-size: 12px;
}

.workflow-columns strong,
.integration-grid strong {
  font-size: 18px;
}

.alert-card {
  min-height: 74px;
  padding: 11px;
  color: #6f4b27;
  background: #fff8ef;
  border: 1px solid #f3d1ad;
  border-radius: 8px;
  line-height: 1.5;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.customer-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  margin-top: 12px;
}

.customer-panel {
  grid-row: span 2;
}

.customer-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.customer-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.customer-form .full {
  grid-column: span 2;
}

.select-control {
  display: flex;
  align-items: center;
  color: var(--text);
}

.submit-action {
  width: 100%;
  margin-top: 12px;
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.customer-status {
  display: grid;
  place-items: center;
}

.phone-card {
  width: min(100%, 260px);
  padding: 18px;
  background: #fff;
  border: 9px solid #14211c;
  border-radius: 28px;
}

.phone-chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  color: var(--green-dark);
  background: #eaf6f0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.phone-card h2 {
  margin-top: 16px;
  font-size: 24px;
}

.phone-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.status-line {
  margin-top: 12px;
  color: #31423c;
  font-size: 13px;
}

.phone-card button {
  width: 100%;
  margin-top: 16px;
  color: #fff;
  background: #14211c;
  border-color: #14211c;
}

.system-footer {
  gap: 7px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1280px) {
  .app-frame {
    grid-template-columns: 1fr;
  }

  .app-rail {
    position: static;
    height: auto;
  }

  .rail-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .ops-layout,
  .ops-dock,
  .customer-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .workspace,
  .app-rail {
    padding: 12px;
  }

  .topbar,
  .metric-row,
  .ticket-grid,
  .timeline,
  .workflow-columns,
  .integration-grid,
  .customer-form,
  .rail-nav,
  .action-stack {
    grid-template-columns: 1fr;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .customer-form .full {
    grid-column: auto;
  }
}
