:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #d8e0ea;
  --line-soft: #e8edf4;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #059669;
  --green-soft: #e7f7ef;
  --amber: #b45309;
  --amber-soft: #fff4db;
  --red: #dc2626;
  --red-soft: #feecec;
  --violet: #7c3aed;
  --shadow: 0 12px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #eef3f8;
}

.login-screen.hidden {
  display: none;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.login-panel input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}

.login-panel input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

.login-message.error {
  color: var(--red);
}

.login-message.success {
  color: var(--green);
}

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

.app-shell.auth-locked {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.nav-btn,
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: #334155;
  background: transparent;
  text-align: left;
}

.nav-btn:hover,
.nav-item:hover {
  background: #f1f5f9;
}

.nav-btn.active,
.nav-item.active {
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 700;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
}

.file-label {
  display: inline-flex;
}

#importDataInput {
  display: none;
}

.nav-icon {
  width: 20px;
  text-align: center;
}

.main {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.page-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.top-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.ticket-flow-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
}

.topbar-actions,
.top-actions,
.toolbar,
.form-actions,
.dialog-actions,
.task-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.account-switch select {
  min-height: 34px;
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
}

.ticket-column-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ticket-column-hint {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

#ticketsView th[hidden],
#ticketsView td[hidden] {
  display: none !important;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 22px 28px;
  min-width: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 22px 0;
}

.metric-card,
.panel,
.person-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.03);
}

.metric-card {
  min-height: 88px;
  padding: 14px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 800;
}

.metric-link {
  display: inline-flex;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.metric-link:hover,
.count-link:hover,
.inline-link:hover {
  color: var(--blue);
  text-decoration: underline;
}

.metric-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.follow-panel {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(520px, 1.6fr);
  gap: 12px;
  padding: 14px 22px 0;
}

.follow-summary,
.today-task-board {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.03);
}

.follow-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
  padding: 12px;
}

.follow-stat {
  display: grid;
  gap: 6px;
  min-height: 78px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.follow-stat:hover {
  border-color: #b7c3d3;
  background: #fafcff;
}

.follow-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.follow-stat strong {
  font-size: 22px;
  line-height: 1;
}

.follow-stat em {
  width: max-content;
  font-style: normal;
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.board-head h2 {
  margin: 0;
  font-size: 16px;
}

.compact-task-table table {
  min-width: 900px;
}

.compact-task-table td.owner-cell {
  min-width: 120px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.view,
.view-panel {
  display: none;
}

.view.active,
.view-panel.active {
  display: block;
}

.view-panel {
  margin: 14px 22px 28px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-title {
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.data-table,
.table-wrap table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td,
.table-wrap th,
.table-wrap td {
  height: 42px;
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
}

.data-table th,
.table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #475569;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}

.data-table tr:hover td,
.table-wrap tr:hover td {
  background: #fafcff;
}

.col-actions {
  width: 170px;
}

#ticketsView .table-wrap table {
  min-width: 4280px;
}

#ticketsView th.id-col { width: 128px; }
#ticketsView th.product-col { width: 150px; }
#ticketsView th.shop-col { width: 160px; }
#ticketsView th.keyword-col { width: 280px; }
#ticketsView th.category-col { width: 210px; }
#ticketsView th.group-col { width: 90px; }
#ticketsView th.owner-col { width: 260px; }
#ticketsView th.source-col { width: 130px; }
#ticketsView th.link-col { width: 180px; }
#ticketsView th.supplier-col { width: 170px; }
#ticketsView th.money-col { width: 120px; }
#ticketsView th.expense-col { width: 145px; }
#ticketsView th.image-col { width: 130px; }
#ticketsView th.sku-col { width: 130px; }
#ticketsView th.priority-col { width: 110px; }
#ticketsView th.node-col { width: 120px; }
#ticketsView th.date-col { width: 145px; }
#ticketsView th.note-col { width: 240px; }

#ticketsView tbody tr {
  height: 96px;
}

#ticketsView tbody td {
  height: 96px;
  padding-top: 12px;
  padding-bottom: 12px;
  vertical-align: top;
}

#ticketsView .table-input,
#ticketsView .tag-input,
#ticketsView .owner-select,
#ticketsView .tag-add-btn,
#ticketsView .secondary-btn.small,
#ticketsView .primary-btn.small {
  height: 32px;
}

#ticketsView th.keyword-col,
#ticketsView td.keyword-cell {
  padding-left: 14px;
  padding-right: 16px;
}

#ticketsView th.category-col,
#ticketsView td.category-cell {
  padding-left: 16px;
}

#ticketsView th.action-col,
#ticketsView td.action-cell {
  width: 190px;
  min-width: 190px;
}

#ticketsView td.action-cell {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  vertical-align: top;
}

#ticketsView .action-stack {
  display: grid;
  gap: 9px;
  min-height: 116px;
  align-content: start;
  padding: 4px 0;
}

#ticketsView .action-stack .secondary-btn,
#ticketsView .action-stack .primary-btn {
  width: 100%;
  min-height: 32px;
}

#ticketsView td.tag-cell {
  min-width: 180px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  vertical-align: top;
}

#ticketsView td.category-cell {
  vertical-align: top;
}

#ticketsView td.keyword-cell {
  min-width: 250px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  vertical-align: top;
}

#ticketsView td.category-cell .single-chip-wrap,
#ticketsView td.category-cell .table-input {
  min-width: 145px;
}

#ticketsView .table-textarea {
  width: 100%;
  min-width: 240px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 13px;
  line-height: 20px;
  resize: none;
  outline: none;
  white-space: pre-wrap;
  overflow: auto;
}

#ticketsView .table-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#ticketsView .table-text-readonly {
  min-width: 240px;
  max-width: 260px;
  line-height: 20px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#ticketsView td.tag-cell.note {
  min-width: 220px;
}

#tasksView .table-wrap table {
  min-width: 1280px;
}

.task-workbench,
.performance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  padding: 14px;
}

.task-main {
  display: grid;
  gap: 4px;
  min-width: 160px;
}

.task-main strong {
  color: var(--ink);
  font-weight: 800;
}

.task-main span {
  color: var(--muted);
  font-size: 12px;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-detail-panel,
.performance-detail {
  display: grid;
  align-self: start;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-head h2 {
  margin: 0;
  font-size: 16px;
}

.detail-head.compact {
  align-items: center;
}

.detail-card,
.perf-detail-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.detail-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  align-items: start;
}

.detail-row span {
  color: var(--muted);
  font-size: 12px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
}

.pager-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-task-row].selected td {
  background: #eef5ff;
}

.performance-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.perf-card {
  display: grid;
  gap: 6px;
  min-height: 86px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.perf-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.perf-card strong {
  font-size: 24px;
}

.perf-card em {
  width: max-content;
  font-style: normal;
}

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

.ai-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(420px, 0.8fr);
  gap: 14px;
  padding: 14px;
}

.ai-workbench {
  display: grid;
  gap: 14px;
  align-content: start;
}

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

.ai-quick-card {
  display: grid;
  gap: 8px;
  min-height: 92px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.ai-quick-card:hover {
  border-color: #b7c3d3;
  background: #fafcff;
}

.ai-quick-card strong {
  font-size: 16px;
}

.ai-quick-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ai-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.ai-form label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.ai-form .span-2 {
  grid-column: 1 / -1;
}

.ai-form input,
.ai-form select,
.ai-form textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.ai-form textarea {
  resize: vertical;
  line-height: 1.6;
}

.ai-result-panel {
  display: grid;
  align-self: start;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.ai-result {
  min-height: 420px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
  color: var(--ink);
  line-height: 1.7;
}

.ai-source-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.ai-report {
  white-space: normal;
}

.fail-count {
  min-width: 28px;
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--red);
  background: var(--red-soft);
  font-weight: 800;
}

.table-input.number {
  min-width: 86px;
}

.link-edit-cell {
  display: grid;
  gap: 6px;
  min-width: 170px;
}

.btn,
.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: #1f2937;
  background: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover,
.segment:hover {
  border-color: #b7c3d3;
  background: #f8fafc;
}

.btn:disabled,
.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled,
.icon-btn:disabled,
.segment:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn.primary,
.primary-btn {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.btn.primary:hover,
.primary-btn:hover {
  background: #1d4ed8;
}

.btn.ghost,
.ghost-btn {
  border-color: transparent;
  background: transparent;
}

.secondary-btn {
  background: #fff;
}

.icon-btn {
  width: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.segment {
  min-height: 28px;
  border-color: transparent;
  padding: 0 10px;
  background: transparent;
  font-size: 12px;
}

.segment.active {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.btn.small,
.primary-btn.small,
.secondary-btn.small,
.ghost-btn.small {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.btn.warn,
.secondary-btn.warn {
  border-color: #f3c673;
  color: var(--amber);
  background: var(--amber-soft);
}

.btn.danger,
.secondary-btn.danger {
  border-color: #f5b5b5;
  color: var(--red);
  background: var(--red-soft);
}

.secondary-btn.ai {
  border-color: #c4b5fd;
  color: var(--violet);
  background: #f5f3ff;
}

.input,
.select,
.textarea,
.search-input,
.data-form input,
.data-form select,
.modal-form input,
.modal-form select,
.modal-form textarea,
.people-grid input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.textarea {
  min-height: 72px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus,
.search-input:focus,
.data-form input:focus,
.data-form select:focus,
.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus,
.people-grid input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.account-admin {
  display: grid;
  gap: 14px;
}

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

.account-form label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.account-form input,
.account-form select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.account-position-field {
  min-width: 0;
  margin: 0;
  padding: 8px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.account-position-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.account-position-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.account-position-option {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 5px !important;
  min-width: 0;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

.account-position-option:has(input:checked) {
  border-color: #8db3ff;
  color: var(--primary);
  background: #edf4ff;
}

.account-position-option input {
  width: 14px !important;
  height: 14px !important;
  margin: 0;
}

.position-badge-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.account-form input:focus,
.account-form select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.account-status-toggle {
  align-content: end;
  grid-template-columns: 18px auto;
  align-items: center;
  min-height: 58px;
  padding-bottom: 4px;
}

.account-status-toggle input {
  min-height: auto;
  padding: 0;
}

.account-form-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.account-table table {
  min-width: 1040px;
}

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

.search-input {
  width: min(320px, 100%);
}

.data-form,
.modal-form .form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.data-form label,
.modal-form label,
.person-card label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.modal-form label.locked-field {
  opacity: 0.62;
}

.data-form button {
  align-self: end;
}

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.badge.green {
  color: var(--green);
  background: var(--green-soft);
}

.badge.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.red {
  color: var(--red);
  background: var(--red-soft);
}

.badge.gray {
  color: #475569;
  background: #eef2f7;
}

.badge.violet {
  color: var(--violet);
  background: #f1eaff;
}

.owner-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  align-items: flex-start;
}

.owner-list.compact {
  width: 100%;
}

#ticketsView td.owner-cell,
#tasksView td.owner-cell {
  min-width: 240px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  vertical-align: top;
}

.owner-picker {
  display: grid;
  gap: 8px;
  width: 240px;
  min-width: 240px;
  max-width: 240px;
}

.owner-picked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: flex-start;
}

.owner-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  color: #334155;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.owner-pill.editable {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  width: 112px;
  padding: 0 0 0 10px;
  border-radius: 8px;
  background: #f1f3f5;
}

.owner-pill.single-owner-pill {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 220px;
  padding-right: 10px;
}

.owner-pill-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.owner-remove {
  width: 24px;
  height: 30px;
  border: 0;
  border-left: 1px solid #e1e6ed;
  color: #7b8794;
  background: transparent;
  font-size: 16px;
  line-height: 1;
}

.owner-remove:hover {
  color: var(--red);
  background: var(--red-soft);
}

.owner-select {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  background: #fff;
  color: #1f2937;
  outline: none;
}

.owner-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#ticketsView td.image-cell {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

#ticketsView td.expense-cell {
  min-width: 130px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.expense-btn {
  min-width: 86px;
}

.expense-chip {
  display: inline-grid;
  gap: 2px;
  min-width: 100px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 800;
  cursor: pointer;
}

.expense-chip span,
.expense-readonly {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.expense-chip strong {
  font-size: 13px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.span-2 {
  grid-column: span 2;
}

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

.field label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.bars {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px minmax(120px, 1fr) 42px;
  align-items: center;
  gap: 10px;
}

.count-link,
.inline-link {
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.count-link {
  justify-self: start;
}

.inline-link {
  display: inline;
  max-width: 100%;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 12px;
  padding: 14px;
}

.account-match-panel {
  grid-column: 1 / -1;
}

.account-match-table table {
  min-width: 820px;
}

.person-subtitle {
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.person-card {
  padding: 14px;
}

.person-card .field-list {
  display: grid;
  gap: 10px;
}

.person-multi-field {
  display: grid;
  gap: 6px;
}

.person-field-title {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.person-multi-list {
  display: grid;
  gap: 6px;
}

.person-multi-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 28px;
  gap: 6px;
  align-items: center;
}

.person-multi-row input {
  width: 100%;
  min-width: 0;
}

.person-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.person-icon-btn.add {
  color: var(--blue);
  background: var(--blue-soft);
}

.person-icon-btn.add:hover {
  border-color: var(--blue);
}

.person-icon-btn.remove {
  width: 28px;
  color: #94a3b8;
}

.person-icon-btn.remove:hover {
  border-color: #f5b5b5;
  color: var(--red);
  background: var(--red-soft);
}

.person-icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.person-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.person-title {
  font-size: 16px;
  font-weight: 800;
}

.dialog {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

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

#ticketDialog {
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
}

#ticketDialog .modal-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 32px);
  overflow: hidden;
}

.ticket-form-body {
  min-height: 0;
  overflow-y: auto;
  padding: 0 18px;
}

.ticket-form-section {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 20px;
  border-bottom: 1px solid var(--line-soft);
  padding: 18px 0;
}

.ticket-form-section:last-child {
  border-bottom: 0;
}

.ticket-form-section-head {
  display: flex;
  align-self: start;
  flex-direction: column;
  gap: 5px;
  padding-top: 2px;
}

.ticket-form-section-head strong {
  color: var(--ink);
  font-size: 14px;
}

.ticket-form-section-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ticket-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px 14px;
  min-width: 0;
}

.ticket-form-grid label {
  min-width: 0;
}

.ticket-form-grid input,
.ticket-form-grid select,
.ticket-form-grid textarea {
  box-sizing: border-box;
  width: 100%;
}

.ticket-form-grid textarea {
  min-height: 66px;
  line-height: 1.5;
  resize: vertical;
}

.ticket-form-grid .span-2 {
  grid-column: span 2;
}

.ticket-form-grid .span-3 {
  grid-column: span 3;
}

.ticket-form-grid .span-4 {
  grid-column: 1 / -1;
}

.account-lock-note {
  min-height: 36px;
  border: 1px solid #dbe7ff;
  border-radius: 6px;
  background: #f5f8ff;
  color: #3b5b92;
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 10px;
}

#ticketDialog [hidden] {
  display: none !important;
}

.ticket-form-grid .file-field input[type="file"] {
  overflow: hidden;
  padding: 5px 7px;
  color: var(--muted);
}

#ticketDialog .modal-foot {
  border-top: 1px solid var(--line-soft);
  background: #fff;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
}

.modal-form .span-2 {
  grid-column: span 2;
}

.form-section-title {
  grid-column: 1 / -1;
  margin-top: 4px;
  border-bottom: 1px solid var(--line-soft);
  padding: 6px 0 8px;
  color: #1f2937;
  font-size: 13px;
  font-weight: 800;
}

#ticketSummaryDialog {
  width: min(1040px, calc(100vw - 28px));
}

.summary-dialog {
  max-height: min(820px, calc(100vh - 42px));
  overflow: auto;
}

.summary-band {
  margin: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-item {
  min-width: 0;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 12px;
}

.summary-item.span-2 {
  grid-column: span 2;
}

.summary-item label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-value {
  min-height: 22px;
  color: var(--ink);
  line-height: 22px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.summary-value.muted {
  color: var(--muted);
}

.summary-main-image {
  display: inline-block;
  width: 136px;
  height: 104px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #f8fafc;
}

.summary-main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.summary-history {
  padding: 0 16px 18px;
}

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

.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

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

.review-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.review-reason {
  margin: 8px 0;
  color: var(--ink);
  line-height: 20px;
}

.price-range-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
}

.ticket-summary-link {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#expenseDialog {
  width: min(1040px, calc(100vw - 28px));
}

.expense-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px 0;
}

.choice-pill {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink) !important;
  background: #fff;
  cursor: pointer;
}

.choice-pill input {
  min-height: auto;
  padding: 0;
}

.expense-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
  padding: 14px 16px;
}

.expense-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.expense-section h3 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
}

.expense-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px;
}

.expense-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 16px 12px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.expense-summary strong {
  color: var(--ink);
  font-size: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 14px;
  padding: 14px;
}

.dashboard-block {
  min-width: 0;
}

.dashboard-block h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

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

.compact-table table {
  min-width: 460px;
}

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

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.dialog-title {
  font-size: 18px;
  font-weight: 800;
}

.dialog-actions {
  justify-content: flex-end;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line-soft);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: none;
  max-width: min(420px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.toast.show {
  display: block;
}

.link {
  color: var(--blue);
  text-decoration: none;
}

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

.image-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.image-upload-empty {
  display: grid;
  gap: 5px;
  justify-items: center;
  min-width: 118px;
  padding: 6px;
  border: 1px dashed transparent;
  border-radius: 6px;
  text-align: center;
}

.image-upload-empty .primary-btn {
  width: 118px;
}

.image-upload-empty > span,
.image-upload-wait {
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}

.image-upload-empty .image-paste-hint {
  color: #64748b;
  font-size: 10px;
}

.image-paste-target {
  outline: none;
}

.image-paste-target:focus-visible {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.image-paste-target.is-pasting {
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.image-upload-wait {
  display: inline-block;
  max-width: 118px;
  white-space: normal;
}

.image-actions span,
.image-actions a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-thumb-box {
  position: relative;
  display: inline-block;
  width: 74px;
  height: 58px;
  vertical-align: middle;
}

.image-thumb-preview {
  position: relative;
  display: block;
  width: 66px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #f1f5f9;
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.08);
}

.image-thumb-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumb-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.image-thumb-box:hover .image-thumb-preview::after,
.image-thumb-box:focus-within .image-thumb-preview::after {
  opacity: 1;
}

.image-eye {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 26px;
  height: 16px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50% / 65%;
  background: rgba(15, 23, 42, 0.18);
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.28);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.image-thumb-box:hover .image-eye,
.image-thumb-box:focus-within .image-eye {
  opacity: 1;
}

.image-eye::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
}

.image-delete-btn,
.image-change-btn {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  color: #fff;
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.image-thumb-box:hover .image-delete-btn,
.image-thumb-box:hover .image-change-btn,
.image-thumb-box:focus-within .image-delete-btn,
.image-thumb-box:focus-within .image-change-btn {
  opacity: 1;
  pointer-events: auto;
}

.image-delete-btn {
  top: -6px;
  right: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #334155;
  font-size: 15px;
  line-height: 1;
  transform: translate(3px, -2px);
}

.image-delete-btn:hover {
  background: var(--red);
}

.image-change-btn {
  right: 2px;
  bottom: 0;
  min-width: 34px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.92);
  font-size: 11px;
  font-weight: 800;
  transform: translate(4px, 3px);
}

.image-change-btn:hover {
  background: #1d4ed8;
}

.product-visual-col {
  width: 130px !important;
  min-width: 130px !important;
}

.product-visual-cell,
.task-product-image,
.task-detail-product-image {
  text-align: center !important;
  vertical-align: middle !important;
}

.product-visual-cell .image-upload-empty,
.product-visual-cell .image-upload-wait {
  margin: 0 auto;
}

.image-thumb-box.product-visual-thumb {
  width: 96px;
  height: 96px;
  margin: 0 auto;
}

.product-visual-thumb .image-thumb-preview {
  width: 88px;
  height: 88px;
  margin: 0 auto;
  background: #fff;
}

.product-visual-thumb .image-thumb-preview img,
.compact-product-thumb .image-thumb-preview img {
  object-fit: contain;
  background: #fff;
}

.image-thumb-box.compact-product-thumb {
  width: 72px;
  height: 72px;
  margin: 0 auto;
}

.compact-product-thumb .image-thumb-preview {
  width: 64px;
  height: 64px;
  margin: 0 auto;
}

.task-detail-product-image {
  display: grid;
  place-items: center;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--line);
}

#ticketsView th,
#ticketsView td,
#tasksView th,
#tasksView td,
#libraryProductsPanel th,
#libraryProductsPanel td,
.compact-task-table th,
.compact-task-table td {
  text-align: center;
  vertical-align: middle;
}

#ticketsView tbody tr {
  height: 120px;
}

#ticketsView tbody td,
#ticketsView td.owner-cell,
#ticketsView td.keyword-cell,
#ticketsView td.category-cell,
#ticketsView td.action-cell,
#ticketsView td.tag-cell {
  height: 120px;
  vertical-align: middle;
}

#ticketsView .table-input,
#ticketsView .table-textarea,
#ticketsView .table-text-readonly,
#ticketsView .owner-select,
#ticketsView .owner-pill-text,
#ticketsView .tag-input,
#ticketsView .tag-chip {
  text-align: center;
}

#ticketsView .owner-picker,
#ticketsView .owner-picked,
#ticketsView .single-chip-wrap,
#ticketsView .tag-editor,
#ticketsView .tag-list,
#ticketsView .action-stack {
  justify-content: center;
  justify-items: center;
  align-content: center;
  margin-left: auto;
  margin-right: auto;
}

#ticketsView .action-stack {
  min-height: 96px;
}

.tag-editor {
  display: grid;
  gap: 6px;
  min-width: 170px;
  max-width: 100%;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 28px;
  align-items: center;
  min-width: 0;
}

.tag-chip {
  display: inline-grid;
  grid-template-columns: 16px minmax(0, 1fr) 24px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-height: 30px;
  border-radius: 5px;
  background: #f1f3f5;
  color: #1f2937;
  overflow: hidden;
}

.tag-chip.readonly {
  grid-template-columns: 16px minmax(0, 1fr);
}

.tag-chip.single {
  width: 100%;
  grid-template-columns: 14px minmax(0, 1fr) 24px;
}

.single-chip-wrap {
  width: 100%;
  min-width: 0;
}

.tag-grip {
  color: #9aa4b2;
  font-size: 12px;
  text-align: center;
  line-height: 1;
}

.tag-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.35;
  padding: 0 4px;
}

.tag-remove {
  width: 24px;
  min-width: 24px;
  height: 28px;
  border: 0;
  border-left: 1px solid #e1e6ed;
  color: #7b8794;
  background: #eef1f4;
  font-size: 16px;
  line-height: 1;
}

.tag-remove:hover {
  color: var(--red);
  background: var(--red-soft);
}

.tag-empty {
  color: var(--muted);
  font-size: 12px;
}

.tag-add {
  display: flex;
  gap: 5px;
}

.tag-input {
  width: 100%;
  min-width: 86px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 7px;
  background: #fff;
  outline: none;
}

.tag-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.table-input {
  width: 100%;
  min-width: 92px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  outline: none;
}

.table-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tag-add-btn {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  white-space: nowrap;
}

.tag-add-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.library-view-tabs {
  display: flex;
  align-items: center;
  min-height: 48px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
}

.library-view-tab {
  align-self: stretch;
  min-width: 110px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #475569;
  background: transparent;
  font-weight: 700;
}

.library-view-tab.active {
  border-bottom-color: var(--blue);
  color: var(--blue);
}

.library-workload {
  display: grid;
  gap: 12px;
}

.library-workload[hidden],
.library-detail-drawer[hidden],
.library-drawer-backdrop[hidden] {
  display: none;
}

.library-workload-toolbar,
.library-workload-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.library-workload-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 10px 14px;
}

.library-workload-filters,
.segmented-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.segmented-control {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented-control button {
  min-width: 58px;
  height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  color: #475569;
  background: #fff;
  font-weight: 700;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.library-workload-filters select {
  width: 132px;
  height: 36px;
}

.library-workload-note {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.library-workload-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
}

.library-workload-metric {
  min-width: 0;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.library-workload-metric > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.library-workload-metric > strong {
  display: block;
  margin: 8px 0 10px;
  font-size: 26px;
  line-height: 1;
}

.library-workload-metric .count-link {
  max-width: 100%;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--blue-soft);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.library-workload-metric .count-link.green {
  color: #047857;
  background: #e7f7ef;
}

.library-workload-metric .count-link.amber {
  color: #b45309;
  background: #fff4db;
}

.library-workload-metric .count-link.red {
  color: #dc2626;
  background: #feecec;
}

.library-workload-metric .count-link.violet {
  color: #7c3aed;
  background: #f2eaff;
}

.library-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.library-section-head h2 {
  margin: 0;
  font-size: 16px;
}

.library-section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.library-matrix-table {
  min-width: 1120px;
  table-layout: fixed;
}

.library-matrix-table th:first-child {
  width: 130px;
}

.library-matrix-table th:nth-child(2) {
  width: 92px;
}

.library-matrix-table th:last-child {
  width: 120px;
}

.library-matrix-table th,
.library-matrix-table td {
  text-align: center;
}

.library-matrix-table td:first-child {
  text-align: left;
}

.library-group-link {
  min-width: 44px;
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
  font-weight: 800;
}

.library-count-pill {
  min-width: 38px;
  height: 30px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #1d4ed8;
  background: #eff6ff;
  font-weight: 800;
}

.library-count-pill.total {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.library-count-pill:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.library-workload-columns {
  display: grid;
  grid-template-columns: minmax(720px, 1.8fr) minmax(310px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.library-role-list {
  display: grid;
  gap: 4px;
  padding: 10px 14px 14px;
}

.library-role-row {
  display: grid;
  grid-template-columns: 78px minmax(80px, 1fr) 42px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.library-role-row:hover {
  background: #f8fafc;
}

.library-role-track {
  height: 8px;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}

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

.library-role-row strong {
  text-align: right;
}

.library-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.28);
}

.library-detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 41;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(680px, 92vw);
  height: 100vh;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -16px 0 40px rgba(15, 23, 42, 0.16);
  transform: translateX(100%);
  transition: transform 160ms ease;
}

.library-detail-drawer.open {
  transform: translateX(0);
}

.library-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 82px;
  border-bottom: 1px solid var(--line);
  padding: 18px 20px;
}

.library-drawer-head h2 {
  margin: 0;
  font-size: 19px;
}

.library-drawer-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.library-drawer-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  background: #f8fafc;
}

.library-drawer-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.library-drawer-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.library-drawer-body {
  overflow: auto;
  padding: 14px 20px 24px;
}

.library-detail-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.library-detail-card h3 {
  margin: 0;
  font-size: 14px;
}

.library-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.library-detail-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.library-reject-reason {
  margin: 9px 0 0;
  color: #991b1b;
  font-size: 12px;
}

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

  .metrics-grid,
  .follow-panel,
  .people-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

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

  .task-workbench,
  .performance-layout,
  .ai-layout {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .data-form,
  .modal-form .form-grid,
  .account-form,
  .dashboard-grid,
  .expense-sections {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .library-workload-metrics {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .library-workload-columns {
    grid-template-columns: 1fr;
  }

  .ticket-form-section {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 12px 14px;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
    padding: 8px;
  }

  .nav-btn {
    justify-content: center;
    padding: 0 8px;
  }

  .nav-icon {
    display: none;
  }

  .topbar,
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics-grid,
  .follow-panel,
    .performance-summary,
    .ai-quick-grid,
    .ai-form,
    .people-grid,
  .form-grid,
  .data-form,
  .modal-form .form-grid,
  .account-form,
  .dashboard-grid,
  .expense-sections,
  .expense-grid {
    grid-template-columns: 1fr;
  }

  .field.span-2 {
    grid-column: auto;
  }

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

  .library-workload-toolbar,
  .library-workload-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .library-workload-note {
    white-space: normal;
  }

  .library-workload-metrics,
  .library-drawer-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ticket-form-grid .span-2,
  .ticket-form-grid .span-3 {
    grid-column: auto;
  }
}

/* Promotion data: one product per row with an independent trend dashboard. */
#promotionView {
  margin: 14px 22px 28px;
  border: 0;
  background: transparent;
  overflow: visible;
}

#promotionView.active {
  display: grid;
  gap: 14px;
}

.promotion-entry-panel,
.promotion-detail-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
}

.promotion-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.promotion-section-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
}

.promotion-section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.promotion-range-label {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 6px;
  background: #e8f7ef;
  color: #078653;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.promotion-entry-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 16px;
}

.promotion-entry-form label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.promotion-entry-form input,
.promotion-entry-form select {
  width: 100%;
  height: 36px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 500;
}

.promotion-entry-form .span-2 {
  grid-column: span 2;
}

.promotion-save-btn {
  align-self: end;
  min-height: 36px;
}

.promotion-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.promotion-toolbar select,
.promotion-custom-range input {
  height: 34px;
  min-width: 120px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.promotion-toolbar .search-input {
  width: min(300px, 100%);
  height: 34px;
}

.promotion-custom-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.promotion-custom-range[hidden] {
  display: none;
}

.promotion-table-wrap {
  max-height: none;
}

.promotion-table {
  width: 100%;
  min-width: 2760px;
  table-layout: fixed;
}

.promotion-table th,
.promotion-table td {
  height: auto;
  min-height: 58px;
  padding: 12px 10px;
  white-space: normal;
  vertical-align: top;
}

.promotion-table th:nth-child(1) { width: 90px; }
.promotion-table th:nth-child(2) { width: 150px; }
.promotion-table th:nth-child(3) { width: 105px; }
.promotion-table th:nth-child(4) { width: 90px; }
.promotion-table th:nth-child(5) { width: 230px; }
.promotion-table th:nth-child(6) { width: 180px; }
.promotion-table th:nth-child(7) { width: 100px; }
.promotion-table th:nth-child(8) { width: 150px; }
.promotion-table th:nth-child(9),
.promotion-table th:nth-child(10),
.promotion-table th:nth-child(11),
.promotion-table th:nth-child(12),
.promotion-table th:nth-child(13),
.promotion-table th:nth-child(14),
.promotion-table th:nth-child(15),
.promotion-table th:nth-child(16),
.promotion-table th:nth-child(17),
.promotion-table th:nth-child(18) { width: 128px; }
.promotion-table th:nth-child(19) { width: 130px; }

.promotion-title-cell strong,
.promotion-title-cell span {
  display: block;
}

.promotion-title-cell strong {
  margin-bottom: 4px;
  color: #172033;
  line-height: 20px;
}

.promotion-title-cell span,
.promotion-keyword {
  color: #64748b;
  font-size: 12px;
  line-height: 18px;
  overflow-wrap: anywhere;
}

.promotion-product-thumb,
.promotion-product-placeholder {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
}

.promotion-product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.promotion-chart-row > td {
  padding: 0;
  background: #f4f7fb;
}

.promotion-chart-sticky {
  position: sticky;
  left: 0;
  width: calc(100vw - 286px);
  min-width: 760px;
  box-sizing: border-box;
  padding: 12px;
}

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

.promotion-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.promotion-chart-head h3 {
  margin: 0;
  font-size: 15px;
}

.promotion-chart-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.promotion-chart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.promotion-scale-mode {
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

.promotion-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
  padding: 12px 14px 4px;
}

.promotion-search-term-card,
.promotion-metric-card {
  min-width: 0;
  min-height: 66px;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f8fafc;
}

.promotion-search-term-card span,
.promotion-metric-card span {
  display: block;
  margin-bottom: 5px;
  color: #64748b;
  font-size: 11px;
}

.promotion-search-term-card strong,
.promotion-metric-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 15px;
  line-height: 20px;
}

.promotion-metric-card {
  position: relative;
  cursor: pointer;
}

.promotion-metric-card input {
  position: absolute;
  top: 9px;
  right: 9px;
}

.promotion-metric-card:has(input:checked) {
  border-color: #2f66eb;
  background: #eef4ff;
}

.promotion-chart-shell {
  height: 300px;
  margin: 12px 14px 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fff;
}

.promotion-trend-chart {
  display: block;
  width: 100%;
  height: 100%;
}

.promotion-chart-empty {
  display: grid;
  height: 100%;
  place-items: center;
  color: #64748b;
  font-size: 13px;
}

.promotion-chart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 14px;
  color: #64748b;
  font-size: 12px;
}

.promotion-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.promotion-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.promotion-chart-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

@media (max-width: 1180px) {
  .promotion-entry-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .promotion-chart-sticky {
    width: 100%;
    min-width: 720px;
  }
}

@media (max-width: 720px) {
  #promotionView {
    margin: 12px;
  }

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

  .promotion-entry-form .span-2 {
    grid-column: auto;
  }

  .promotion-section-head,
  .promotion-chart-head,
  .promotion-chart-foot {
    align-items: stretch;
    flex-direction: column;
  }
}
