:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #dce3ed;
  --text: #172033;
  --muted: #637083;
  --primary: #256f87;
  --primary-strong: #185267;
  --accent: #c44936;
  --green: #2f7d5b;
  --amber: #aa7525;
  --shadow: 0 12px 30px rgba(21, 34, 52, .08);
}

* { box-sizing: border-box; }

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

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

button { cursor: pointer; }

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  background: #13202d;
  color: #f8fbff;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 64px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.brand p {
  margin: 4px 0 0;
  color: #aab8c8;
  font-size: 12px;
}

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

.nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #dce8f5;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #223347;
  color: #fff;
}

.sidebar-foot {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions,
.toolbar,
.panel-head,
.dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 111, 135, .12);
}

.topbar input {
  width: min(340px, 48vw);
}

.primary-button,
.ghost-button,
.danger-button,
.text-button {
  border-radius: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
}

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

.primary-button:hover { background: var(--primary-strong); }

.primary-button.small { min-height: 32px; }

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

.sidebar .ghost-button {
  color: #eaf2fb;
  background: transparent;
  border-color: #384b60;
}

.danger-button {
  color: #fff;
  background: var(--accent);
}

.text-button {
  min-height: 30px;
  padding: 0 4px;
  color: var(--primary);
  background: transparent;
}

.file-button {
  display: grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.view { display: none; }
.view.active { display: block; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 16px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

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

.panel-head h3 { margin: 0; }

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

.funnel-row {
  display: grid;
  grid-template-columns: 82px 1fr 38px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

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

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

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

.list-item {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.list-item strong {
  font-size: 14px;
}

.list-item span,
.subtle {
  color: var(--muted);
  font-size: 12px;
}

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

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

th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

.badge {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--primary-strong);
  background: #e4f2f5;
  font-size: 12px;
}

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

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

.badge.red {
  color: var(--accent);
  background: #fae7e3;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 11px;
  background: transparent;
}

.segmented button.active {
  color: #fff;
  background: var(--primary);
}

.split-grid,
.writer-layout {
  display: grid;
  grid-template-columns: .95fr 1.05fr;
  gap: 16px;
}

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

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

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

.output-box {
  resize: vertical;
  min-height: 360px;
  line-height: 1.65;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
}

.day-cell {
  min-height: 132px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.day-cell strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.post-pill {
  margin-top: 6px;
  padding: 7px;
  border-radius: 7px;
  background: #eef5f7;
  font-size: 12px;
}

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

.kanban-column {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 440px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.kanban-column h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.task-card {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.card-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button,
.card-actions button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.danger-zone {
  display: grid;
  gap: 10px;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 25, 38, .25);
}

dialog::backdrop {
  background: rgba(10, 20, 32, .45);
}

.dialog-form {
  padding: 18px;
}

.dialog-form h3 {
  margin: 0 0 14px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: none;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #1f2c3b;
  box-shadow: var(--shadow);
}

.toast.show { display: block; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    display: block;
  }
  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 12px;
  }
  .sidebar-foot {
    grid-template-columns: repeat(2, 1fr);
    margin-top: 12px;
  }
  .topbar,
  .dashboard-grid,
  .split-grid,
  .writer-layout,
  .settings-grid {
    grid-template-columns: 1fr;
    display: grid;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
  .calendar-grid,
  .kanban {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main { padding: 14px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .topbar input {
    width: 100%;
  }
}
