:root {
  color-scheme: light;
  --bg: #eeeaff;
  --bg-2: #f8f6ff;
  --ink: #17151d;
  --muted: #6d667a;
  --soft: #91899d;
  --panel: rgba(255, 254, 253, .86);
  --panel-solid: #fffefd;
  --panel-2: #f4f0ff;
  --dark: #171518;
  --dark-2: #231f28;
  --line: rgba(80, 66, 132, .16);
  --line-strong: rgba(80, 66, 132, .3);
  --violet: #7162d9;
  --violet-soft: #dcd6ff;
  --blue: #5b7df0;
  --cyan: #6dbad0;
  --amber: #d59b45;
  --rose: #d8758d;
  --danger: #c95656;
  --ok: #5d8f77;
  --shadow: 0 22px 70px rgba(70, 58, 126, .16);
  --radius: 8px;
  --gap: clamp(10px, 1.1vw, 16px);
  --pad: clamp(12px, 1.4vw, 18px);
  --font-body: "Glow Sans TC Normal", "未來熒黑 Normal", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-num: "Space Grotesk", "Noto Sans TC", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111018;
  --bg-2: #171420;
  --ink: #f6f2ff;
  --muted: #bbb2c9;
  --soft: #938aa2;
  --panel: rgba(28, 24, 37, .88);
  --panel-solid: #211c2c;
  --panel-2: #2b2440;
  --dark: #0d0b12;
  --dark-2: #171321;
  --line: rgba(232, 224, 255, .14);
  --line-strong: rgba(232, 224, 255, .28);
  --violet: #a89cff;
  --violet-soft: #3b3260;
  --blue: #8fa3ff;
  --cyan: #82c7d8;
  --amber: #e1b46a;
  --rose: #e797aa;
  --danger: #e27b7b;
  --ok: #82b899;
  --shadow: 0 22px 70px rgba(0, 0, 0, .34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
  background:
    linear-gradient(rgba(78, 65, 132, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(78, 65, 132, .07) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.92), rgba(238,234,255,.78) 30%, rgba(238,234,255,1) 70%);
  background-size: 68px 68px, 68px 68px, 100% 900px;
  -webkit-tap-highlight-color: rgba(113, 98, 217, .18);
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(rgba(232, 224, 255, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 224, 255, .06) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(62, 53, 87, .92), rgba(24, 21, 34, .92) 32%, #111018 74%);
  -webkit-tap-highlight-color: rgba(168, 156, 255, .2);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 254, 253, .84);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: rgba(113, 98, 217, .58);
  background: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: .62;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(113, 98, 217, .32);
  outline-offset: 2px;
}

:root[data-theme="dark"] button {
  background: rgba(34, 29, 46, .88);
  color: var(--ink);
}

:root[data-theme="dark"] button:hover {
  border-color: rgba(168, 156, 255, .62);
  background: rgba(46, 39, 62, .96);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.app-root {
  min-height: 100dvh;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--dark);
  color: #fff;
  transform: translateY(-72px);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.app-shell {
  min-height: 100dvh;
  padding: clamp(12px, 2vw, 22px);
}

.workspace-app {
  min-height: calc(100dvh - clamp(24px, 4vw, 44px));
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 332px;
  grid-template-rows: auto 1fr;
  gap: var(--gap);
}

.brand-panel,
.topbar,
.workspace-main,
.ai-panel,
.side-nav,
.audit-drawer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-panel {
  grid-row: 1 / 3;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.brand-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 253, .58);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(113, 98, 217, .45);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #fff, var(--violet-soft));
  color: var(--violet);
  font-family: var(--font-num);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
}

.brand-name {
  min-width: 0;
}

.brand-name strong,
.brand-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-name strong {
  font-size: 12px;
  line-height: 1.2;
}

.brand-name span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.role-box,
.filters label,
.review-note label {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

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

textarea {
  min-height: 92px;
  resize: vertical;
}

:root[data-theme="dark"] select,
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea {
  background: #211c2c;
  color: var(--ink);
}

.role-access {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.48);
  color: var(--muted);
  font-size: 11px;
}

:root[data-theme="dark"] .brand-head,
:root[data-theme="dark"] .side-nav,
:root[data-theme="dark"] .panel-header,
:root[data-theme="dark"] .ai-head,
:root[data-theme="dark"] .ai-footer,
:root[data-theme="dark"] .role-access {
  background: rgba(34, 29, 46, .58);
}

:root[data-theme="dark"] .brand-mark {
  background: linear-gradient(145deg, #2c263c, var(--violet-soft));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}

.role-access strong {
  display: block;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.25;
}

.access-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.access-item {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255,255,255,.62);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

:root[data-theme="dark"] .access-item {
  background: rgba(34, 29, 46, .74);
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  margin: 12px;
  padding: 10px;
  box-shadow: none;
  background: rgba(255,255,255,.45);
  overflow: auto;
}

.nav-button {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  text-align: left;
  box-shadow: none;
}

.nav-button[aria-selected="true"] {
  border-color: rgba(113, 98, 217, .55);
  background: linear-gradient(180deg, #fff, #e8e3ff);
  box-shadow: 0 0 0 5px rgba(113, 98, 217, .12);
}

:root[data-theme="dark"] .nav-button[aria-selected="true"],
:root[data-theme="dark"] .action-button.primary,
:root[data-theme="dark"] .btn.primary {
  border-color: rgba(168, 156, 255, .55);
  background: linear-gradient(180deg, #342d49, #29233d);
  box-shadow: 0 0 0 5px rgba(168, 156, 255, .12);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--violet);
  font-family: var(--font-num);
  font-size: 12px;
}

.nav-copy {
  min-width: 0;
}

.nav-copy strong,
.nav-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-copy strong {
  font-size: 12px;
  line-height: 1.2;
}

.nav-copy span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.system-note {
  display: grid;
  gap: 8px;
  margin: 0 12px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 21, 24, .92);
  color: #f8f6ff;
  font-size: 11px;
}

.system-note span {
  color: #d7d0e3;
}

.topbar {
  grid-column: 2 / 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  min-width: 0;
  padding: 14px 16px;
  box-shadow: 0 14px 44px rgba(70, 58, 126, .12);
}

.page-title {
  min-width: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--cyan);
  box-shadow: 0 0 0 6px rgba(109, 186, 208, .18);
}

h1 {
  margin-top: 4px;
  overflow: hidden;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 500;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-wrap: nowrap;
  white-space: nowrap;
}

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

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill {
  background: rgba(255,255,255,.72);
  color: var(--muted);
}

:root[data-theme="dark"] .status-pill {
  background: rgba(34, 29, 46, .72);
}

.status-pill strong {
  color: var(--ink);
  font-family: var(--font-num);
  font-weight: 500;
}

.action-button,
.btn,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
}

.btn {
  min-height: 38px;
}

.btn small {
  display: block;
  color: inherit;
  font-size: 10px;
  opacity: .72;
}

.action-button.primary,
.btn.primary {
  border-color: rgba(113, 98, 217, .55);
  background: linear-gradient(180deg, #fff, #e8e3ff);
}

.workspace-main {
  grid-column: 2 / 3;
  min-width: 0;
  overflow: hidden;
}

.main-scroll {
  height: 100%;
  max-height: calc(100dvh - 128px);
  overflow: auto;
  padding: var(--pad);
  scrollbar-gutter: stable;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.kpi-card,
.panel,
.chart-zone,
.queue-item,
.recommendation,
.audit-table article,
.mini-card,
.project-card,
.workflow-card,
.kanban-column,
.kanban-card,
.detail-grid div,
.task-summary div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 253, .8);
  overflow: hidden;
}

:root[data-theme="dark"] .kpi-card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .chart-zone,
:root[data-theme="dark"] .queue-item,
:root[data-theme="dark"] .recommendation,
:root[data-theme="dark"] .audit-table article,
:root[data-theme="dark"] .mini-card,
:root[data-theme="dark"] .project-card,
:root[data-theme="dark"] .workflow-card,
:root[data-theme="dark"] .kanban-column,
:root[data-theme="dark"] .kanban-card,
:root[data-theme="dark"] .detail-grid div,
:root[data-theme="dark"] .task-summary div {
  background: rgba(33, 28, 43, .82);
}

.kpi-card,
.mini-card {
  padding: 13px;
}

.kpi-label,
dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.kpi-value {
  display: block;
  margin-top: 8px;
  font-family: var(--font-num);
  font-size: 30px;
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.kpi-context,
.mini-card small,
.project-card p,
.workflow-card p,
.kanban-card p,
.muted {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.dashboard-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr);
  gap: var(--gap);
  align-items: start;
}

.panel {
  margin-bottom: var(--gap);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .42);
}

.panel-header h2,
.panel-header h3,
.section-heading h2,
.chart-tile h3 {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.panel-body {
  padding: 14px;
}

.mini-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.dark-panel {
  background: linear-gradient(145deg, var(--dark), var(--dark-2));
  color: #fbf9ff;
}

.dark-panel .panel-header {
  border-color: rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
}

.dark-panel .kpi-label,
.dark-panel .muted,
.dark-panel .mini-card small {
  color: #c8c1d4;
}

.dark-panel .mini-card {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.12);
}

.mini-chart {
  display: grid;
  gap: 10px;
}

.queue-list {
  display: grid;
  gap: 9px;
}

.queue-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.queue-item.done {
  opacity: .62;
}

.priority-dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--blue);
}

.priority-dot.watch {
  background: var(--amber);
}

.priority-dot.danger {
  background: var(--danger);
}

.queue-copy {
  min-width: 0;
}

.queue-copy strong,
.queue-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-copy strong {
  font-size: 12px;
}

.queue-copy span {
  color: var(--muted);
  font-size: 11px;
}

.chart-zone {
  grid-column: 1 / -1;
}

.chart-zone-body {
  padding: 14px;
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .75fr);
  gap: var(--gap);
  align-items: stretch;
}

.chart-tile {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.58);
  padding: 12px;
  overflow: hidden;
}

:root[data-theme="dark"] .chart-tile {
  background: rgba(33, 28, 43, .82);
}

.chart-tile-wide {
  grid-column: 1 / -1;
}

.chart-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.chart-line-wrap {
  height: 178px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(113, 98, 217, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113, 98, 217, .08) 1px, transparent 1px);
  background-size: 100% 33.33%, 25% 100%;
  overflow: hidden;
}

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

.chart-stroke {
  fill: none;
  stroke: var(--violet);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-area {
  fill: rgba(113, 98, 217, .15);
}

.chart-point {
  fill: var(--panel-solid);
  stroke: var(--violet);
  stroke-width: 3;
}

.line-chart {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  height: 178px;
  padding-top: 10px;
  align-items: end;
}

.line-chart div {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 7px;
  height: 100%;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.line-chart i,
.line-chart b {
  align-self: end;
  display: block;
  width: 100%;
  min-height: 8px;
  border-radius: 999px 999px 4px 4px;
}

.line-chart i {
  height: calc(var(--open) * 1%);
  background: linear-gradient(180deg, var(--cyan), var(--violet));
}

.line-chart b {
  height: calc(var(--done) * 1%);
  background: linear-gradient(180deg, var(--ok), var(--cyan));
}

.line-chart small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 52px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  margin-top: 10px;
}

.mini-chart .bar-row {
  margin-top: 0;
}

.bar-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row div,
.bar-track,
.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(113, 98, 217, .12);
}

.bar-row i,
.bar-fill,
.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
}

.chart-fill.ok {
  background: linear-gradient(90deg, var(--ok), var(--cyan));
}

.chart-fill.watch {
  background: linear-gradient(90deg, var(--amber), var(--violet));
}

.chart-fill.danger {
  background: linear-gradient(90deg, var(--danger), var(--rose));
}

.chart-fill.info {
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.num {
  font-family: var(--font-num);
  font-weight: 500;
  text-align: right;
}

.donut-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.donut {
  position: relative;
  width: 128px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--ok) 0 52%, var(--amber) 52% 78%, var(--danger) 78% 100%);
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: inherit;
  background: var(--panel-solid);
}

.legend-list {
  display: grid;
  gap: 8px;
  min-width: 0;
  font-size: 11px;
}

.legend-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--blue);
}

.legend-dot.ok {
  background: var(--ok);
}

.legend-dot.watch {
  background: var(--amber);
}

.legend-dot.danger {
  background: var(--danger);
}

.column-chart {
  height: 178px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  padding-top: 10px;
}

.chart-column {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 7px;
  height: 100%;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.chart-column-bar {
  align-self: end;
  min-height: 8px;
  height: var(--h);
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, var(--cyan), var(--violet));
}

.chart-column span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-details {
  display: grid;
  gap: 10px;
}

.chart-details summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.summary-table {
  display: grid;
  gap: 8px;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-row strong {
  color: var(--ink);
  font-family: var(--font-num);
  font-weight: 500;
}

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

.risk-list p {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.risk-list p:last-child {
  border-bottom: 0;
}

.badge.high,
.badge.P0,
.badge.danger {
  border-color: rgba(201, 86, 86, .34);
  background: rgba(201, 86, 86, .12);
  color: #8a3838;
}

.badge.medium,
.badge.P1,
.badge.P2,
.badge.watch,
.badge.doing,
.badge.review {
  border-color: rgba(213, 155, 69, .34);
  background: rgba(213, 155, 69, .15);
  color: #7b5520;
}

.badge.low,
.badge.done,
.badge.P3,
.badge.ok {
  border-color: rgba(93, 143, 119, .28);
  background: rgba(93, 143, 119, .12);
  color: #355f4b;
}

.badge.ai,
.badge.role,
.badge.neutral,
.badge.backlog,
.badge.info {
  border-color: rgba(113, 98, 217, .34);
  background: rgba(113, 98, 217, .12);
  color: #5145ac;
}

:root[data-theme="dark"] .badge.high,
:root[data-theme="dark"] .badge.P0,
:root[data-theme="dark"] .badge.danger {
  color: #f0b5b5;
}

:root[data-theme="dark"] .badge.medium,
:root[data-theme="dark"] .badge.P1,
:root[data-theme="dark"] .badge.P2,
:root[data-theme="dark"] .badge.watch,
:root[data-theme="dark"] .badge.doing,
:root[data-theme="dark"] .badge.review {
  color: #f3d39b;
}

:root[data-theme="dark"] .badge.low,
:root[data-theme="dark"] .badge.done,
:root[data-theme="dark"] .badge.P3,
:root[data-theme="dark"] .badge.ok {
  color: #bce5cc;
}

:root[data-theme="dark"] .badge.ai,
:root[data-theme="dark"] .badge.role,
:root[data-theme="dark"] .badge.neutral,
:root[data-theme="dark"] .badge.backlog,
:root[data-theme="dark"] .badge.info {
  color: #d5ceff;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--gap);
}

.section-heading.compact {
  align-items: center;
}

.section-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.project-grid,
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.project-card,
.workflow-card,
.kanban-card {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.project-card h3,
.workflow-card h3,
.kanban-card h3,
.mini-card strong,
.recommendation h3 {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recommendation h3,
.kanban-card h3,
.workflow-card h3,
.project-card h3 {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

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

.progress {
  margin: 8px 0;
}

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

.detail-grid div,
.task-summary div {
  padding: 10px;
}

dd {
  margin: 6px 0 0;
  font-family: var(--font-num);
}

.data-table {
  display: grid;
  gap: 8px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(130px, .7fr) minmax(120px, .55fr) minmax(110px, .55fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255,255,255,.58);
  color: var(--ink);
  text-align: left;
}

:root[data-theme="dark"] .table-row {
  background: rgba(33, 28, 43, .82);
}

.task-table .table-row {
  grid-template-columns: minmax(230px, 1.4fr) minmax(120px, .7fr) minmax(130px, .7fr) minmax(130px, .7fr) minmax(110px, .5fr) minmax(150px, .75fr);
}

.table-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.table-row.selectable {
  width: 100%;
  cursor: pointer;
}

.table-row.selected {
  outline: 2px solid rgba(113, 98, 217, .5);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px;
  gap: 10px;
  margin-bottom: var(--gap);
}

.filters label,
.review-note label {
  margin-top: 0;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.kanban-column {
  min-width: 180px;
  min-height: 420px;
  padding: 10px;
}

.kanban-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.kanban-card {
  margin-top: 9px;
  background: #fff;
}

:root[data-theme="dark"] .kanban-card {
  background: rgba(34, 29, 46, .9);
}

.kanban-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.kanban-actions button {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 11px;
}

.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.audit-filters button {
  min-height: 34px;
  padding: 6px 10px;
}

.audit-filters button.active,
.audit-filters button[aria-pressed="true"] {
  border-color: rgba(113, 98, 217, .55);
  color: var(--violet);
}

.audit-table {
  display: grid;
  gap: 8px;
}

.audit-table article {
  display: grid;
  grid-template-columns: 132px minmax(160px, .8fr) minmax(140px, .8fr) minmax(220px, 1fr) max-content;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.audit-table.drawer article {
  grid-template-columns: 1fr;
  align-items: start;
}

.audit-table time,
.audit-table p {
  color: var(--muted);
}

.review-note {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.ai-panel {
  grid-column: 3 / 4;
  grid-row: 1 / 3;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.ai-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.45);
}

.ai-head h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.ai-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ai-feed {
  overflow: auto;
  padding: 12px;
}

.recommendation {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
}

.recommendation h3,
.kanban-card h3,
.workflow-card h3,
.project-card h3 {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.recommendation p,
.recommendation small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.rec-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.ai-footer {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.45);
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  background: rgba(13, 11, 18, .22);
}

.drawer-scrim.open {
  display: block;
}

.audit-drawer {
  position: fixed;
  z-index: 40;
  right: 22px;
  bottom: 22px;
  width: min(760px, calc(100vw - 44px));
  max-height: min(70dvh, 680px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  transform: translateY(calc(100% + 28px));
  transition: transform 180ms ease;
}

.audit-drawer.open {
  transform: translateY(0);
}

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

.drawer-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.drawer-head h2 {
  margin-top: 3px;
  font-size: 14px;
  line-height: 1.25;
}

.drawer-body {
  overflow: auto;
  padding: 12px;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
}

@media (max-width: 1180px) {
  .workspace-app {
    grid-template-columns: 224px minmax(0, 1fr);
  }

  h1 {
    font-size: 28px;
  }

  .ai-panel {
    grid-column: 1 / 3;
    grid-row: 3 / 4;
    min-height: 390px;
  }

  .ai-feed {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 10px;
    overflow-x: auto;
  }

  .recommendation {
    margin-bottom: 0;
  }
}

@media (max-width: 920px) {
  .workspace-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
  }

  .brand-panel,
  .topbar,
  .workspace-main,
  .ai-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .brand-panel {
    display: block;
  }

  .side-nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(190px, 1fr);
    overflow-x: auto;
  }

  .system-note {
    display: none;
  }

  .main-scroll {
    max-height: none;
  }

  .dashboard-grid,
  .split-grid,
  .kpi-strip,
  .chart-grid,
  .project-grid,
  .workflow-grid,
  .filters,
  .detail-grid,
  .task-summary {
    grid-template-columns: 1fr;
  }

  .table-row,
  .task-table .table-row,
  .audit-table article {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .top-actions,
  .rec-actions,
  .kanban-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .action-button,
  .btn,
  .top-actions .status-pill {
    width: 100%;
    justify-content: center;
  }

  .panel-header,
  .section-heading,
  .chart-tile-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .bar-row {
    grid-template-columns: 88px minmax(0, 1fr) 44px;
  }

  h1 {
    font-size: 18px;
  }

  .kpi-value {
    font-size: 26px;
  }

  .audit-drawer {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    max-height: min(62dvh, 540px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
