:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-soft: #f8faf9;
  --surface-2: #eef1f4;
  --line: #d8dde5;
  --line-strong: #b8c1cc;
  --text: #20242a;
  --muted: #66707c;
  --green: #146c5f;
  --green-dark: #105b50;
  --red: #9f3434;
  --amber: #8b5d21;
  --blue: #235789;
  --slate: #5e6678;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body.authLocked {
  overflow: hidden;
}

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

button,
.buttonLike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #343b45;
  padding: 0 12px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.buttonLike:hover {
  border-color: var(--green);
  background: #eef6f3;
  color: var(--green);
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  outline: 2px solid rgba(20, 108, 95, 0.14);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

a {
  color: #0a66c2;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

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

h2 {
  font-size: 17px;
  line-height: 1.3;
}

h3 {
  font-size: 14px;
  line-height: 1.3;
}

p,
.mutedLine {
  color: var(--muted);
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px 32px;
}

.topbar,
.sectionHead,
.actions,
.filters,
.sectionHeadActions,
.inlineFormActions,
.rowActions,
.materialHead {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar {
  justify-content: space-between;
  min-height: 58px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
}

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

.flash {
  min-height: 36px;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
}

.flash.ok {
  border-color: #b7d6cc;
  background: #eef8f4;
  color: var(--green);
}

.flash.warn {
  border-color: #ead9ba;
  background: #fff9ed;
  color: var(--amber);
}

.flash.error {
  border-color: #e4beb8;
  background: #fff6f4;
  color: var(--red);
}

.flash.busy {
  border-color: #c6d7ea;
  background: #f0f6ff;
  color: var(--blue);
}

.workspaceLayout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 12px;
}

.content {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.sidePanel,
.band {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.sidePanel h2 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

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

.sideField span,
.briefGrid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sideHint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.projectBoard,
.projectMeta,
.materialList,
.usageLogList {
  display: grid;
  gap: 8px;
}

.projectBoardItem {
  width: 100%;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 9px;
  text-align: left;
}

.projectBoardItem:hover,
.projectBoardItem.active,
.projectBoardItem.dropTarget {
  border-color: var(--green);
  background: #eef6f3;
  color: var(--green);
}

.projectBoardItem.active {
  box-shadow: inset 3px 0 0 var(--green);
}

.projectBoardItem.dragging {
  opacity: 0.55;
}

.projectBoardItem span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.projectBoardItem small,
.projectDragHandle {
  color: var(--muted);
  font-size: 11px;
}

.projectDragHandle {
  cursor: grab;
  font-weight: 800;
}

.metaCard {
  display: grid;
  gap: 6px;
  border: 1px solid #dfe6e3;
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.metaCard strong {
  font-size: 14px;
}

.metaCard span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.sectionHead {
  justify-content: space-between;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
  padding: 14px 16px;
}

.sectionHead p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.sectionHeadActions {
  justify-content: flex-end;
}

.sectionHeadActions {
  display: none !important;
}

.sectionHeadActions.alwaysVisible {
  display: flex !important;
}

.briefGrid,
.materialFlow,
.filters,
.layout,
.usageLogList,
.materialList {
  padding: 14px 16px;
}

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

.briefGrid label {
  display: grid;
  gap: 6px;
}

.briefGrid textarea {
  min-height: 74px;
}

.materialFlow {
  display: grid;
  gap: 10px;
  padding-bottom: 0;
}

.materialStep {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #dfe6e3;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.stepBadge {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: #e8f3ef;
  color: var(--green);
  font-weight: 800;
}

.stepContent {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.stepActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.materialImportBar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, auto);
  gap: 8px;
}

.materialDropZone {
  display: grid;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.materialDropZone strong {
  font-size: 13px;
}

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

.materialDropZone:hover,
.materialDropZone:focus-visible,
.materialDropZone.isActive {
  border-color: var(--green);
  background: #eef6f3;
  outline: none;
}

.hiddenPicker {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.materialItem,
.usageLogItem {
  border: 1px solid #e0e6e2;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.materialHead {
  justify-content: space-between;
  margin-bottom: 6px;
}

.materialHead strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.materialItem .mutedLine {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.assetActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.assetActions a,
.assetActions button {
  min-height: 30px;
  font-size: 12px;
}

.filters {
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.filters input {
  flex: 1 1 320px;
}

.filters select {
  flex: 0 1 150px;
}

.layout {
  padding-top: 0;
}

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #e8ebf0;
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.5;
}

th {
  height: 42px;
  background: var(--surface-2);
  color: #4d5662;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbfdfc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.channelTable th:nth-child(1) { width: 34%; }
.channelTable th:nth-child(2) { width: 12%; }
.channelTable th:nth-child(3) { width: 13%; }
.channelTable th:nth-child(4) { width: 15%; }
.channelTable th:nth-child(5) { width: 12%; }
.channelTable th:nth-child(6) { width: 14%; }

.channelTitle {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.platform {
  font-weight: 700;
  color: var(--text);
}

.url {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.rowActions {
  justify-content: flex-start;
}

.completeButton {
  min-height: 30px;
  white-space: nowrap;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.p-high {
  border-color: #f3c5bf;
  background: #fff0ed;
  color: var(--red);
}

.p-mid {
  border-color: #ecd5a6;
  background: #fff8eb;
  color: var(--amber);
}

.p-low {
  border-color: #d3cfdd;
  background: #efedf4;
  color: var(--slate);
}

.s-pending,
.s-queued,
.s-running {
  border-color: #ecd5a6;
  background: #fff7e7;
  color: var(--amber);
}

.s-done,
.s-success {
  border-color: #b7d6cc;
  background: #eef8f4;
  color: var(--green);
}

.s-failed {
  border-color: #f3c5bf;
  background: #fff0ed;
  color: var(--red);
}

.s-manual,
.s-blocked,
.s-skip {
  border-color: #d3cfdd;
  background: #efedf4;
  color: var(--slate);
}

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

.usageLogItem div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.usageLogItem strong {
  overflow-wrap: anywhere;
}

.usageLogItem span,
.usageLogItem time,
.empty,
.notice,
.mutedRow {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 18px 12px;
  text-align: center;
}

.inlineFormPanel {
  display: grid;
  gap: 10px;
  margin: 0 16px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.inlineFormGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

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

.inlineFormActions {
  justify-content: flex-end;
}

#channelCreatePanel #newChannelPlatform,
#channelCreatePanel #newChannelPriority,
#channelCreatePanel #newChannelCategory,
#channelCreatePanel #newChannelAction,
#channelCreatePanel #newChannelNotes {
  display: none !important;
}

#channelCreatePanel .inlineFormGrid {
  grid-template-columns: minmax(0, 1fr);
}

#channelCreatePanel .inlineFormGrid.singleColumn {
  display: none;
}

.loginShell {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  padding: 24px;
  background: var(--bg);
}

.loginShell[hidden],
.loginError[hidden] {
  display: none;
}

.loginVisual {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.loginMockShell {
  width: min(780px, 88%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.loginMockTop,
.loginDashHead,
.loginQueue div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.loginMockTop {
  min-height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}

.loginMockTop span,
.loginDashHead span {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.loginMockBody {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  min-height: 400px;
}

.loginMockNav {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  background: #f8faf9;
}

.loginMockNav span {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #e8edf2;
}

.loginMockNav span:first-child {
  background: var(--green);
}

.loginDashboard {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 20px;
}

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

.loginDashHead strong {
  font-size: 22px;
}

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

.loginKpis div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.loginKpis span,
.loginQueue em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.loginKpis strong {
  font-size: 26px;
  line-height: 1;
}

.loginQueue {
  display: grid;
  gap: 8px;
}

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

.loginQueue div > span {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
}

.loginQueue strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loginPanel {
  align-self: center;
  display: grid;
  gap: 14px;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
}

.loginBrand {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.loginPanel h1 {
  font-size: 26px;
}

.loginCopy {
  color: var(--muted);
  line-height: 1.6;
}

.loginPanel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.authModeSwitch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.authModeTab.active,
.loginSubmit {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.loginSubmit:disabled {
  opacity: 0.72;
}

.loginError {
  display: flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid #e4beb8;
  border-radius: 8px;
  background: #fff6f4;
  color: var(--red);
  padding: 8px 10px;
  font-size: 13px;
}

@media (max-width: 980px) {
  .workspaceLayout,
  .loginShell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .materialStep {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .stepActions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .materialImportBar,
  .inlineFormGrid,
  .inlineFormGrid.singleColumn {
    grid-template-columns: 1fr;
  }

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

  .loginVisual {
    min-height: 360px;
  }

  .loginPanel {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 12px;
  }

  .topbar,
  .sectionHead,
  .filters,
  .usageLogItem {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button,
  .filters input,
  .filters select,
  .filters button,
  .sectionHeadActions button,
  .inlineFormActions button,
  .stepActions button {
    width: 100%;
  }

  .sidebar,
  .materialStep {
    grid-template-columns: 1fr;
  }

  .stepActions {
    grid-column: auto;
  }

  .briefGrid,
  .materialFlow,
  .filters,
  .layout,
  .usageLogList,
  .materialList {
    padding: 12px;
  }

  table {
    min-width: 760px;
  }

  .loginShell {
    padding: 12px;
  }

  .loginVisual {
    display: none;
  }
}
